Skip to content

Commit

Permalink
docs: add ability to use headers to print query plans (#2804)
Browse files Browse the repository at this point in the history
Update docs on what headers can be set to return query plans in
extensions

---------

Co-authored-by: Maria Elisabeth Schreiber <[email protected]>
  • Loading branch information
smyrick and Meschreiber authored Dec 5, 2023
1 parent 71224f4 commit 28d1709
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/source/query-plans.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,15 @@ You can view the query plan for a particular operation in any of the following w
* Note that you must [register your federated graph](./managed-federation/setup/) with GraphOS to view query plans in the Explorer.
* As direct output from the `@apollo/gateway` library (see below)

### Outputting query plans with headers

With [the Apollo Router](/router/) `v0.16.0+` and [`@apollo/gateway`](/apollo-server/using-federation/api/apollo-gateway/) `v2.5.4+`, you can pass the following headers to return the query plans in the GraphQL response extensions:

* Including the `Apollo-Query-Plan-Experimental` header returns the query plan in the response extensions
* Additionally including the `Apollo-Query-Plan-Experimental-Format` header with one of the supported options changes the output format:
* A value of `prettified` returns a human-readable string of the query plan
* A value of `internal` returns a JSON representation of the query plan

### Outputting query plans with `@apollo/gateway`

Your gateway can output the query plan for each incoming operation as it's calculated. To do so, add the following to the file where you initalize your `ApolloGateway` instance:
Expand Down

0 comments on commit 28d1709

Please sign in to comment.