-
Notifications
You must be signed in to change notification settings - Fork 1
/
test3-apollo.js
50 lines (40 loc) · 974 Bytes
/
test3-apollo.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
47
48
49
50
// var { ApolloServer, gql } = require('apollo-server');
// var typeDefs = gql
// ` type Query {
// hello: String
// }
// schema {
// query: Query
// }`
// ;
// var resolvers = {
// Query: {
// hello(root) {
// return 'world';
// }
// }
// };
// const server = new ApolloServer({ typeDefs, resolvers });
// server.listen().then(({ url }) => {
// console.log(`🚀 Server ready at ${url}`);
// });
var { ApolloServer, gql } = require('apollo-server-express');
var typeDefs = gql
` type Query {
hello: String
}
schema {
query: Query
}`
;
var resolvers = {
Query: {
hello(root) {
return 'world';
}
}
};
const app = require('express')();
const server = new ApolloServer({ typeDefs, resolvers });
server.applyMiddleware({ app });
app.listen(4000, () => console.log('Now browse to localhost:4000/graphql'));