Complete the code to access the context argument in a resolver function.
const resolver = (parent, args, [1]) => { return [1].userId; }
The context argument provides shared data like authentication info to resolvers.
Complete the code to extract the user role from the context argument.
function checkRole(_, __, [1]) { return [1].user.role; }
The context holds the current user's data, including roles.
Fix the error in accessing the context argument in this resolver.
const resolver = (parent, args, info) => { return [1].userId; }context (undefined) or args/parent instead of info.Although named info, the third argument holds the context with user data (true info metadata is fourth). Use info here.
Fill both blanks to correctly use context and args in a resolver.
const resolver = (parent, [1], [2]) => { return [2].user.id === [1].id; }
args holds input arguments, context holds user info.
Fill all three blanks to destructure context and use args in a resolver.
const resolver = (_, [1], [2]) => { const { user } = [3]; return user.id === [1].id; }
We destructure user from context and compare with args.
