Skip to content

Commit d184235

Browse files
committed
Working on logic problem
1 parent f3bb3fe commit d184235

1 file changed

Lines changed: 32 additions & 13 deletions

File tree

graphQLApollo/index.js

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff 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) => {

0 commit comments

Comments
 (0)