File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import express from 'express';
3
3
import { graphqlExpress , graphiqlExpress } from 'graphql-server-express' ;
4
4
import bodyParser from 'body-parser' ;
5
5
6
+ import { getMiddlewareForQueryMap } from 'extractgql/lib/server' ;
7
+
6
8
import {
7
9
GITHUB_CLIENT_ID ,
8
10
GITHUB_CLIENT_SECRET ,
@@ -19,6 +21,9 @@ import { subscriptionManager } from './subscriptions';
19
21
20
22
import schema from './schema' ;
21
23
24
+ import queryMap from '../extracted_queries.json' ;
25
+ import config from './config' ;
26
+
22
27
let PORT = 3010 ;
23
28
if ( process . env . PORT ) {
24
29
PORT = parseInt ( process . env . PORT , 10 ) + 100 ;
@@ -33,6 +38,13 @@ app.use(bodyParser.json());
33
38
34
39
setUpGitHubLogin ( app ) ;
35
40
41
+ if ( config . persistedQueries ) {
42
+ app . use (
43
+ '/graphql' ,
44
+ getMiddlewareForQueryMap ( queryMap )
45
+ ) ;
46
+ }
47
+
36
48
app . use ( '/graphql' , graphqlExpress ( ( req ) => {
37
49
// Get the query, the same way express-graphql does it
38
50
// https://github.com/graphql/express-graphql/blob/3fa6e68582d6d933d37fa9e841da5d2aa39261cd/src/index.js#L257
You can’t perform that action at this time.
0 commit comments