Complete the code to define a simple GraphQL query that returns a string.
type Query { greeting: [1] }The String type is used to return text in GraphQL queries.
Complete the resolver function to return the greeting string.
const resolvers = { Query: { greeting: () => [1] } };The resolver must return a string value. It should be a string literal inside quotes.
Fix the error in the resolver to correctly return the user's name.
const resolvers = { Query: { userName: (parent, args, context, info) => [1] } };The user's name is typically stored in the context object under user.name.
Fill both blanks to define a resolver that returns a list of posts with titles.
const resolvers = { Query: { posts: () => [1].map(post => post.[2]) } };The resolver maps over postsData and returns the title of each post.
Fill all three blanks to create a resolver that filters users by age greater than 18 and returns their names.
const resolvers = { Query: { adultUserNames: () => users.filter(user => user.[1] [2] [3]).map(user => user.name) } };The resolver filters users where age is greater than 18, then returns their name.