forked from glennreyes/graphpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
35 lines (29 loc) · 716 Bytes
/
Copy pathserver.js
File metadata and controls
35 lines (29 loc) · 716 Bytes
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
import { ApolloServer } from 'apollo-server';
import { once } from 'ramda';
import { config, context, resolvers, typeDefs } from './srcFiles';
if (!(resolvers && Object.keys(resolvers).length > 0)) {
throw Error(
`Couldn't find any resolvers. Please add resolvers to your src/resolvers.js`,
);
}
let options = {};
if (config) {
// Renaming to avoid shadowing
const {
context: _context,
resolvers: _resolvers,
typeDefs: _typeDefs,
...rest
} = config;
options = rest;
}
const server = new ApolloServer({
...options,
context,
typeDefs,
resolvers,
});
server
.listen({ port: 4000 })
.then(({ url }) => console.log(`🚀 Server ready at ${url}`));
export default server;