File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,24 @@ const resolvers = {
1515 books ( ) {
1616 return db . books
1717 } ,
18+ authors ( ) {
19+ return db . authors
20+ } ,
21+ addressAuthor ( parent , args , context ) {
22+ let resAddress = db . authors . find ( author => {
23+ return author . name === args . name
24+ } )
25+ if ( resAddress ) {
26+ return resAddress
27+ } else {
28+ throw new GraphQLError ( 'NOT FOUND' , {
29+ extensions : {
30+ code : 'BAD_REQUEST' ,
31+ argumentName : 'name' ,
32+ } ,
33+ } ) ;
34+ }
35+ } ,
1836 book ( parent , args , context ) {
1937 //console.log(parent, "\n", context)
2038 let result = db . books . find ( ( b ) => {
Original file line number Diff line number Diff line change @@ -24,5 +24,7 @@ export const typeDefs = `#graphql
2424 type Query {
2525 books: [Book]
2626 book(id: Int!): Book
27+ authors: [Author]
28+ addressAuthor(name: String!): Address
2729 }
2830`
You can’t perform that action at this time.
0 commit comments