Complete the code to define a resolver that returns a user's name.
const resolvers = { Query: { user: () => [1] } };The resolver must return an object matching the schema type. Here, it returns an object with a name property.
Complete the resolver to fetch a list of books from data.
const resolvers = { Query: { books: () => [1] } };The resolver returns the variable booksList which holds the array of books.
Fix the error in the resolver to correctly return the user's email.
const resolvers = { User: { email: (parent) => [1] } };The resolver accesses the email property from the parent object, which holds the user data.
Fill both blanks to define a resolver that fetches a post by ID from data.
const resolvers = { Query: { post: (_, args) => [1].find(p => p.[2] === args.id) } };The resolver searches the posts array for a post where the id matches the argument args.id.
Fill all three blanks to create a resolver that returns the titles of all books published after a given year.
const resolvers = { Query: { recentBooks: (_, args) => [1].filter(book => book.[2] > args.[3]).map(book => book.title) } };The resolver filters the books array for books with publishedYear greater than the argument year, then maps to their titles.