graphile / crystal

🔮 Graphile's Crystal Monorepo; home to Grafast, PostGraphile, pg-introspection, pg-sql2 and much more!
https://graphile.org/
Other
12.63k stars 572 forks source link

Output executed Postgres queries? #310

Closed mgallagher closed 6 years ago

mgallagher commented 7 years ago

Forgive me if there's an answer for this somewhere, but it might be nice to have an option to show the SQL that gets sent to Postgres from PostGraphQL. Any idea how this might be done?

benjie commented 7 years ago

We use the debug module, so you can run export DEBUG="postgraphql:*" (assuming bash shell) before running postgraphql to see various output. For postgres queries specifically you want DEBUG=postgraphql:postgres; but DEBUG=postgraphql:postgres:explain is also handy.

mgallagher commented 7 years ago

Excellent. Thank you @benjie! This works perfectly :)

lcjnil commented 7 years ago

@benjie this should be mentioned in document

benjie commented 7 years ago

@lcjnil I totally agree. Pull requests are welcome 👍

deslee commented 6 years ago

FYI: It should now be export DEBUG="postgraphile:*" in case anyone is looking at this issue in 2018.

benjie commented 6 years ago

This is now documented here: https://www.graphile.org/postgraphile/debugging/#step-4-viewing-the-generated-sql