-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
46 lines (40 loc) · 1.13 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import express from 'express';
import { graphqlExpress, graphiqlExpress } from 'apollo-server-express';
import bodyParser from 'body-parser';
import schema from './data/schema';
import compression from 'compression';
import { Engine } from 'apollo-engine';
const GRAPHQL_PORT = 3000;
const ENGINE_API_KEY = 'service:Applification-GQL-10:r-tCdvKQ8X2VLplhTMcYxg';
const engine = new Engine({
engineConfig: {
apiKey: ENGINE_API_KEY,
stores: [
{
name: 'inMemEmbeddedCache',
inMemory: {
cacheSize: 20971520
}
}
],
queryCache: {
publicFullQueryStore: 'inMemEmbeddedCache'
}
},
graphqlPort: GRAPHQL_PORT
});
engine.start();
const graphQLServer = express();
graphQLServer.use(engine.expressMiddleware());
graphQLServer.use(compression());
graphQLServer.use(
'/graphql',
bodyParser.json(),
graphqlExpress({ schema, tracing: true, cacheControl: true })
);
graphQLServer.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));
graphQLServer.listen(GRAPHQL_PORT, () =>
console.log(
`GraphiQL is now running on http://localhost:${GRAPHQL_PORT}/graphiql`
)
);