Complete the code to define a nested resolver for the 'author' field inside 'Book' type.
const resolvers = {
Book: {
author: (parent, args, context, info) => [1]
}
};The resolver for 'author' should fetch the author data using the 'authorId' from the parent 'Book' object, typically via a database call in context.
Complete the resolver to fetch nested comments for a 'Post' type.
const resolvers = {
Post: {
comments: (parent, args, context) => [1]
}
};The 'comments' resolver should fetch comments related to the post using the post's 'id' from the parent object.
Fix the error in the nested resolver to correctly fetch the 'profile' for a 'User'.
const resolvers = {
User: {
profile: (parent, args, context) => [1]
}
};The resolver should use the user's 'id' from the parent to fetch the profile. Using 'args.id' or 'parent.profile' is incorrect here.
Fill both blanks to correctly resolve nested 'orders' and their 'items' for a 'Customer'.
const resolvers = {
Customer: {
orders: (parent, args, context) => [1]
},
Order: {
items: (parent, args, context) => [2]
}
};The 'orders' resolver fetches orders by customer id, and the 'items' resolver fetches items by order id from the parent object.
Fill all three blanks to correctly resolve nested 'categories', 'products', and 'reviews' in a GraphQL schema.
const resolvers = {
Category: {
products: (parent, args, context) => [1]
},
Product: {
reviews: (parent, args, context) => [2]
},
Review: {
author: (parent, args, context) => [3]
}
};Each resolver fetches related data using the parent's id or authorId. Categories fetch products, products fetch reviews, and reviews fetch their author.