Complete the code to specify the authentication provider in the GraphQL schema directive.
type Query @auth(provider: "[1]") { user: User }
The @auth directive uses the provider argument to specify which federated authentication provider to use. Here, "google" is the correct provider name.
Complete the code to request the user's email from the federated authentication token.
query getUser { user(email: [1]) { id name } }In federated authentication, the user's email is often accessed from the context object that holds the authentication token data.
Fix the error in the authentication directive by completing the missing argument.
type Mutation @auth([1]: "github") { updateUser(name: String): User }
The @auth directive requires the provider argument to specify the federated authentication service.
Fill both blanks to complete the federated authentication header and token extraction.
headers: { Authorization: "Bearer [1]" }, context: { user: [2] }The Authorization header uses the token value, and the context user is extracted from authToken.
Fill all three blanks to complete the federated authentication resolver with token validation and user extraction.
resolve(parent, args, context) { const [1] = context.headers["[2]"];
if (![1]) throw new Error("No token");
return getUserFromToken([1]); }The resolver extracts the token from the 'Authorization' header into the variable 'authToken' and uses it to get the user.