Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 05e932c

Browse files
committed
added the ability to handle persisted queries
1 parent 9c11408 commit 05e932c

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

api/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import express from 'express';
33
import { graphqlExpress, graphiqlExpress } from 'graphql-server-express';
44
import bodyParser from 'body-parser';
55

6+
import { getMiddlewareForQueryMap } from 'extractgql/lib/server';
7+
68
import {
79
GITHUB_CLIENT_ID,
810
GITHUB_CLIENT_SECRET,
@@ -19,6 +21,9 @@ import { subscriptionManager } from './subscriptions';
1921

2022
import schema from './schema';
2123

24+
import queryMap from '../extracted_queries.json';
25+
import config from './config';
26+
2227
let PORT = 3010;
2328
if (process.env.PORT) {
2429
PORT = parseInt(process.env.PORT, 10) + 100;
@@ -33,6 +38,13 @@ app.use(bodyParser.json());
3338

3439
setUpGitHubLogin(app);
3540

41+
if (config.persistedQueries) {
42+
app.use(
43+
'/graphql',
44+
getMiddlewareForQueryMap(queryMap)
45+
);
46+
}
47+
3648
app.use('/graphql', graphqlExpress((req) => {
3749
// Get the query, the same way express-graphql does it
3850
// https://github.com/graphql/express-graphql/blob/3fa6e68582d6d933d37fa9e841da5d2aa39261cd/src/index.js#L257

0 commit comments

Comments
 (0)