Skip to content

Commit ea73b9a

Browse files
maon-fpFabian Breitkreutz
andauthored
docs(express.mdx): describe renderGraphiQL option usage (#6822)
Co-authored-by: Fabian Breitkreutz <[email protected]>
1 parent c23f517 commit ea73b9a

File tree

1 file changed

+24
-0
lines changed
  • packages/web/docs/src/content/gateway/deployment/node-frameworks

1 file changed

+24
-0
lines changed

packages/web/docs/src/content/gateway/deployment/node-frameworks/express.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,30 @@ app.listen(4000, () => {
3030
})
3131
```
3232

33+
## Offline Usage
34+
35+
By default, GraphiQL code is served from a CDN because to decrease bundle size. If you want to use
36+
GraphiQL from a local version, you need to install it manually.
37+
38+
You need to pass imported `renderGraphiQL` to `createGatewayRuntime` like below:
39+
40+
```ts filename="Render GraphiQL offline"
41+
import express from 'express'
42+
import { createGatewayRuntime } from '@graphql-hive/gateway-runtime'
43+
import { renderGraphiQL } from '@graphql-yoga/render-graphiql'
44+
45+
const app = express()
46+
47+
const serveRuntime = createGatewayRuntime({ renderGraphiQL })
48+
49+
// Bind Hive Gateway to the graphql endpoint to avoid rendering the playground on any path
50+
app.use(serveRuntime.graphqlEndpoint, serveRuntime)
51+
52+
app.listen(4000, () => {
53+
console.log('Running a GraphQL API server at http://localhost:4000/graphql')
54+
})
55+
```
56+
3357
## Using Helmet
3458

3559
If you are using [Helmet](https://helmetjs.github.io/) to set your

0 commit comments

Comments
 (0)