-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
96 lines (76 loc) · 2.2 KB
/
server.js
File metadata and controls
96 lines (76 loc) · 2.2 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const { ApolloServer, gql } = require("apollo-server");
// import schema from './data/schema';
import resolvers from './data/resolvers';
// Provide resolver functions for your schema fields
// const resolvers = {
// Query: {
// annoucement: () =>
// }
// };
// const typeDefs = gql`
// # Comments in GraphQL are defined with the hash (#) symbol.
// # This "Book" type can be used in other type declarations.
// type Household {
// householdName: String
// city: String
// }
// # The "Query" type is the root of all GraphQL queries.
// # (A "Mutation" type will be covered later on.)
// type Query {
// households: [Household]
// }
// `;
const typeDefs = gql`
type Query {
household(city: String, householdName: String, state: String, street: String, zip: String): Household
allHouseholds: [Household]
}
type Household {
city: String
householdName: String
state: String
street: String
zip: String
neighbors: [Neighbor]
}
type Neighbor {
firstName: String
lastName: String
household: Household
}`
;
const server = new ApolloServer({
typeDefs,
resolvers });
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
// import express from 'express';
// import { graphqlExpress, graphiqlExpress } from 'apollo-server-express';
// import bodyParser from 'body-parser';
// import schema from './data/schema';
// import resolvers from './data/schema';
// import { ApolloEngine } from 'apollo-engine';
// const GRAPHQL_PORT = 3000;
// const ENGINE_API_KEY = 'Y27QKqz3tb0UWiXulDbz8w'; // TODO
// const engine = new ApolloEngine({
// apiKey: process.env.ENGINE_API_KEY,
// });
// const graphQLServer = express();
// graphQLServer.use(compression());
// graphQLServer.use('/graphql', bodyParser.json(), graphqlExpress({ schema }));
// graphQLServer.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));
// engine.listen(GRAPHQL_PORT, () =>
// console.log(
// `GraphiQL is now running on http://localhost:${GRAPHQL_PORT}/graphiql`
// )
// );
// engine.listen({ port: 3000,
// graphqlPaths: ['/api/graphql'],
// expressApp: app,
// launcherOptions: {
// startupTimeout: 3000,
// },
// }, () => {
// console.log('Listening!');
// });