Accessing `pgClient` in hooks for `explain` data
See original GitHub issueSummary
We’re using the embeddable Apollo Explorer in place of GraphiQL (for a number of reasons that are off topic) and we’d like to add the explain
data onto result data.
Additional context
We already know that we can use the postgraphile:http:end
hook to mutate result data. However, we’re hitting a wall trying to find the right hook or right method to access pgClient._explainResults
. We’re starting postgraphile with allowExplain: true
fwiw.
I’ve tried to trace through contexts to figure out where postgraphile might be exposing that, but I’m coming up empty. (It’s a bit dizzying trying to follow what is sent where and how contexts are constructed, without being intimately familiar with it).
Any pointers to solve this one?
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Apache Airflow | Getting Results From PostgreSQL Using Hooks
In this video, we are going to see how can we get data from PostgreSQL using a Hook from our DAG. If you...
Read more >Using a PostgreSQL client to connect to your DB cluster
You can use the pgAdmin client to access your data in native PostgreSQL dialect. To connect to the cluster with the pgAdmin client....
Read more >Airflow Hooks Explained 101: A Complete Guide - Learn | Hevo
In summary, this blog presented a complete overview of developing and maintaining Airflow hooks, using one example of a PostgreSQL Airflow hook.
Read more >Connecting – node-postgres
... methods for connecting to database instances using short-lived authentication tokens. ... const { Client } = require('pg') client = new Client({ host: ......
Read more >PostGraphile | makeExtendSchemaPlugin (graphile-utils)
When defining a field on an existing table-backed type defined by PostGraphile, it's useful to access data from the underlying table in the ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
awesome. got it. here’s the last bit, which must be placed before
app.use(postgraphile)
:I haven’t figured out how to hack Apollo Explorer to inject
explain
into the results pane (it seems to be ignoring anything that’s not"data"
) but this will allow someone to log the explain at the very least:Thanks @benjie
Turns out it’s
X-PostGraphile-Explain: on
; set here in the GraphiQLfetcher
: https://github.com/graphile/postgraphile/blob/a33712580ae3304d9f68cedaf4816a0661dfbad1/postgraphiql/src/components/PostGraphiQL.js#L376Which results in
explain
being set to true on the withPostGraphileContext options: https://github.com/graphile/postgraphile/blob/ed6ecb4596088120969795a9ec30cb625ef93eae/src/postgraphile/http/createPostGraphileHttpRequestHandler.ts#L152Which then uses the
startExplain
/stopExplain
methods that we patch onto the Postgres client:https://github.com/graphile/postgraphile/blob/263ba7477bc2133eebdf89d29acd0460e58501ec/src/postgraphile/withPostGraphileContext.ts#L481-L508
(Note that this will not work with schema-only usage because we don’t mod the postgres client with schema-only usage.)