Skip to content

Commit f02409e

Browse files
authored
Expose the query plan in graphql extensions for Hive GW Rust QP (#7337)
1 parent e934822 commit f02409e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

packages/web/docs/src/content/gateway/other-features/rust-query-planner.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,32 @@ export const gateway = createGatewayRuntime({
7575

7676
</Tabs>
7777

78+
## Exposing the Query Plan
79+
80+
To view the generated query plan when using the Rust Query Planner, you can use the `useQueryPlan`
81+
plugin from `@graphql-hive/router-runtime` as follows:
82+
83+
```ts filename="gateway.config.ts"
84+
import { defineConfig } from '@graphql-hive/gateway'
85+
import { unifiedGraphHandler, useQueryPlan } from '@graphql-hive/router-runtime'
86+
87+
export const gatewayConfig = defineConfig({
88+
unifiedGraphHandler,
89+
plugins: ({ log }) => [
90+
useQueryPlan({
91+
// Query plan available callback
92+
onQueryPlan(queryPlan) {
93+
log.debug({ queryPlan }, 'Generated Query Plan')
94+
},
95+
// Expose the query plan in the graphql result extensions
96+
expose: true,
97+
// or expose based on request.
98+
expose: req => req.headers.get('hive-expose-query-plan') === 'true'
99+
})
100+
]
101+
})
102+
```
103+
78104
## Compared to JavaScript Query Planner
79105

80106
Hive Gateway uses the [JavaScript Query Planner](https://the-guild.dev/graphql/stitching) by

0 commit comments

Comments
 (0)