-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (26 loc) · 840 Bytes
/
index.js
File metadata and controls
30 lines (26 loc) · 840 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
// To instantiate an Apollo GraphQL server we need to first import the server.
const {ApolloServer} = require ('apollo-server');
const {typeDefs} = require('./schema');
const {Query} = require('./resolvers/Query');
const {Product} = require('./resolvers/Product');
const {Category} = require('./resolvers/Category');
const {products, categories, reviews} = require('./db');
// Instantiate a new Apollo GraphQL server using a 'Type Definition' and a 'Resolver'.
const server = new ApolloServer({
typeDefs,
resolvers: {
Query,
Product,
Category
},
context: {
hello: () => console.log('Hello world!'),
products,
categories,
reviews
}
});
// Listen to the server asynchronously.
server.listen().then( ({url}) => {
console.log("Server is ready at " + url);
})