Skip to content

Commit 773d4e4

Browse files
Fabian Breitkreutzardatan
authored andcommitted
docs(express.mdx): describe renderGraphiQL option usage
1 parent 7e753a5 commit 773d4e4

File tree

1 file changed

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

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,29 @@ 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+
44+
const app = express()
45+
46+
const serveRuntime = createGatewayRuntime({ renderGraphiQL })
47+
48+
// Bind Hive Gateway to the graphql endpoint to avoid rendering the playground on any path
49+
app.use(serveRuntime.graphqlEndpoint, serveRuntime)
50+
51+
app.listen(4000, () => {
52+
console.log('Running a GraphQL API server at http://localhost:4000/graphql')
53+
})
54+
```
55+
3356
## Using Helmet
3457

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

0 commit comments

Comments
 (0)