Complete the code to add a custom error extension in a GraphQL error.
throw new GraphQLError('Invalid input', { extensions: { [1]: 'BAD_USER_INPUT' } });
The code field inside extensions is used to specify a custom error code in GraphQL errors.
Complete the code to include a custom error extension with a numeric HTTP status code.
throw new GraphQLError('Unauthorized', { extensions: { code: 'UNAUTHENTICATED', [1]: 401 } });
The status field is commonly used to represent HTTP status codes in custom error extensions.
Fix the error in the code to correctly add a custom error extension with a reason string.
throw new GraphQLError('Failed', { extensions: { code: 'FAILURE', reason [1] 'Timeout' } });
In JavaScript objects, key-value pairs use a colon ':' to separate the key and value.
Fill both blanks to create a custom error with code and a nested details object.
throw new GraphQLError('Error', { extensions: { [1]: 'BAD_REQUEST', [2]: { field: 'email', issue: 'invalid format' } } });
The code key holds the error code string, and details is a common key for nested error info.
Fill all three blanks to throw a GraphQL error with uppercase code, numeric status, and a user-friendly message.
throw new GraphQLError('Access denied', { extensions: { [1]: 'FORBIDDEN', [2]: 403, [3]: 'You do not have permission to access this resource.' } });
code is the uppercase error code, status is the HTTP status number, and message is the user-friendly error message.