Closed borsemayur2 closed 3 years ago
How can i add user object in the resolver while resolving book query
user
book
const data = { todos: [ { id: 1, title: "todo1", user: 1 }, { id: 2, title: "todo2", user: 2 }, ], users: [ { id: 1, name: "ABC" }, { id: 2, name: "XYZ" }, ], }; const types = gql` type User { id: Int! name: String! todos: [Todo!]! } type Todo { id: Int! title: String! user: User! } type Query { todos: [Todo!]! todo(id: Int): Todo! users: [User!]! user(id: Int): User! } `; const resolvers = { Query: { todos: (parent: any, args: any, context: any, info: any) => { return data.todos ; }, todo: (parent: any, args: any, context: any, info: any) => { return data.todos[args.id - 1]; }, users: (parent: any, args: any, context: any, info: any) => { return data.users; }, user: (parent: any, args: any, context: any, info: any) => { return data.users[args.id - 1]; }, }, }
I've posted in issues as there is no tab for discussions
issues
discussions
How can i add
user
object in the resolver while resolvingbook
query