// GraphiQL middleware (manual route) app.get('/graphiql', (req, res) => res.send( <!DOCTYPE html> <html> <head> <title>GraphiQL</title> <link href="https://unpkg.com/graphiql/graphiql.min.css" rel="stylesheet" /> </head> <body style="margin: 0; height: 100vh;"> <div id="graphiql" style="height: 100vh;"></div> <script crossorigin src="https://unpkg.com/react/umd/react.development.js"></script> <script crossorigin src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script> <script crossorigin src="https://unpkg.com/graphiql/graphiql.min.js"></script> <script> const fetcher = GraphiQL.createFetcher( url: '/graphql' ); ReactDOM.render( React.createElement(GraphiQL, fetcher: fetcher ), document.getElementById('graphiql') ); </script> </body> </html> ); );
app.use('/graphql', express.json(), expressMiddleware(server)); graphiql install
| Option | Type | Default | Description | |--------|------|---------|-------------| | endpointURL | string | /graphql | GraphQL endpoint URL | | subscriptionsEndpoint | string | null | WebSocket URL for subscriptions | | query | string | "" | Pre-filled query | | variables | object | {} | Pre-filled variables JSON | | headers | object | {} | HTTP headers for requests | | editorTheme | string | "graphiql" | Theme (light/dark/custom) | // GraphiQL middleware (manual route) app