mirror of
https://github.com/graphql-hive/console
synced 2026-05-23 09:08:34 +00:00
Add docs for header propagation (#5602)
This commit is contained in:
parent
6e87471f07
commit
6f410010ef
2 changed files with 44 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ export default {
|
|||
index: 'Overview',
|
||||
performance: 'Performance/Cache',
|
||||
security: 'Security',
|
||||
'header-propagation': 'Header Propagation',
|
||||
testing: 'Testing & Debugging',
|
||||
'custom-plugins': 'Custom Plugins',
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
# Header Propagation
|
||||
|
||||
Hive Gateway can forward headers from the incoming request to the outgoing request, also you can
|
||||
forward the headers from the upstream responses to the client.
|
||||
|
||||
## From the client to the subgraphs
|
||||
|
||||
You can configure headers to be propagated from the incoming request to the outgoing request. You
|
||||
can do either per subgraph or globally.
|
||||
|
||||
```ts filename="gateway.config.ts"
|
||||
import { defineConfig } from '@graphql-hive/gateway'
|
||||
|
||||
export const gatewayConfig = defineConfig({
|
||||
propagateHeaders: {
|
||||
fromClientToSubgraphs({ request, subgraphName }) {
|
||||
if (subgraphName === 'subgraph1') {
|
||||
return {
|
||||
'x-custom-header': request.headers.get('x-custom-header')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## From the subgraphs to the client
|
||||
|
||||
You can configure headers to be propagated from the upstream responses to the client.
|
||||
|
||||
```ts filename="gateway.config.ts"
|
||||
import { defineConfig } from '@graphql-hive/gateway'
|
||||
|
||||
export const gatewayConfig = defineConfig({
|
||||
propagateHeaders: {
|
||||
fromSubgraphsToClient({ response }) {
|
||||
return {
|
||||
'x-custom-header': response.headers.get('x-custom-header')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
Loading…
Reference in a new issue