Complete the code to define a GraphQL query that fetches the current user's ID.
query { currentUser { [1] } }The id field uniquely identifies the current user, which is essential for context-based authentication.
Complete the code to add a context argument to the resolver function signature.
const resolver = (parent, args, [1]) => { /* authentication logic */ }info instead of context for authentication data.The context argument provides authentication info and user data to the resolver.
Fix the error in the authentication check inside the resolver.
if (![1].user) { throw new Error('Not authenticated'); }
args.user instead of context.user.parent or info for authentication data.The context object holds the user info needed to check authentication.
Fill both blanks to create a context object that includes the authenticated user and request headers.
const context = ({ [1] }) => { return { user: getUser([2].headers.authorization) }; };res or response instead of req.The req object contains HTTP request data including headers, which is used to get the user.
Fill all three blanks to define a GraphQL directive for requiring authentication.
directive @[1] on [2] | [3]
QUERY as a directive location, which is invalid.auth.The @auth directive is commonly used on FIELD_DEFINITION and OBJECT to enforce authentication.