Queries are not compiled to WAM code. They are meta-interpreted on the fly by the top-level (so no WAM code is produced). To see the WAM code which would be generated by the compiler create a file with a clause whose head contains all name variables of the query and the body corresponds to the query. For instance for the query:
?- append(X,Y,[a,b,c]).
create a Prolog file containing
query(X,Y) :- append(X,Y,[a,b,c]).
and compile it to a WAM file to see the result.