File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- export default books =
2- [ {
1+ const books =
2+ [ {
33 "_id" : {
44 "$oid" : "66e179c074a9720c956c04a1"
55 } ,
@@ -448,4 +448,6 @@ export default books =
448448 "author" : "Carlie Clarey" ,
449449 "pages" : 587 ,
450450 "price" : 1.66
451- } ]
451+ } ]
452+
453+ export default { books }
Original file line number Diff line number Diff line change @@ -8,19 +8,27 @@ import { typeDefs } from './schema/schema.js';
88// data
99import db from './data/_db.js'
1010
11+ //resolvers
12+ const resolvers = {
13+ Query : {
14+ books ( ) {
15+ return db . books
16+ } ,
17+ }
18+ }
19+
1120// The ApolloServer constructor requires two parameters: your schema
1221// definition and your set of resolvers.
1322const server = new ApolloServer ( {
14- typeDefs,
15- resolvers,
16- } ) ;
17- // Passing an ApolloServer instance to the `startStandaloneServer` function:
18- // 1. creates an Express app
19- // 2. installs your ApolloServer instance as middleware
20- // 3. prepares your app to handle incoming requests
21- const { url } = await startStandaloneServer ( server , {
22- listen : { port : 4000 } ,
23- } ) ;
24-
25- console . log ( `Server ready at: ${ url } ` ) ;
26-
23+ typeDefs,
24+ resolvers,
25+ } ) ;
26+ // Passing an ApolloServer instance to the `startStandaloneServer` function:
27+ // 1. creates an Express app
28+ // 2. installs your ApolloServer instance as middleware
29+ // 3. prepares your app to handle incoming requests
30+ const { url } = await startStandaloneServer ( server , {
31+ listen : { port : 4000 } ,
32+ } ) ;
33+
34+ console . log ( `Server ready at: ${ url } ` ) ;
Original file line number Diff line number Diff line change 11export const typeDefs = `#graphql
22 type Book {
3- id: {
4- ID!
5- }
3+ id: ID!
64 title: String!
75 author: String
8- pages: int
9- price: float
6+ pages: Int
7+ price: Float
8+ }
9+
10+ type Query {
11+ books: [Book]
1012 }
1113`
You can’t perform that action at this time.
0 commit comments