File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,20 +19,39 @@ const resolvers = {
1919 return db . authors
2020 } ,
2121 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- }
22+ let resAddress = db . authors . forEach ( author => {
23+ if ( author . name === args . name ) {
24+ console . log ( author )
25+ for ( let i = 0 ; i < db . address . length ; i ++ ) {
26+ if ( db . address [ i ] . id === author . address ) {
27+ console . log ( "YES" )
28+ return db . address [ i ]
29+ }
30+ }
31+ } } )
32+ console . log ( resAddress )
3533 } ,
34+
35+ // ;(author => {
36+ // if (author.name === args.name) {
37+ // console.log(author)
38+ // let resultAddress = db.address.find((a) => {
39+ // return a.city === args.id
40+ // })
41+ // return db.address.street
42+ // }
43+ // })
44+ // if(resAddress) {
45+ // return resAddress
46+ // } else {
47+ // throw new GraphQLError('NOT FOUND', {
48+ // extensions: {
49+ // code: 'BAD_REQUEST',
50+ // argumentName: 'name',
51+ // },
52+ // });
53+ // }
54+ // },
3655 book ( parent , args , context ) {
3756 //console.log(parent, "\n", context)
3857 let result = db . books . find ( ( b ) => {
You can’t perform that action at this time.
0 commit comments