Complete the code to access the GraphQL query info argument in a resolver.
resolve(parent, args, context, [1]) { return args.id; }
The info argument provides details about the GraphQL query, such as the field name and schema.
Complete the code to get the field name from the info argument inside a resolver.
const fieldName = [1].fieldName;The info argument contains the fieldName property which tells which field is being resolved.
Fix the error in accessing the selection set from the info argument.
const selections = info.fieldNodes[0].[1].selections;
The fieldNodes[0] object has a selectionSet property that contains the selections of the query.
Fill both blanks to extract the names of selected fields from the info argument.
const fieldNames = info.fieldNodes[0].[1].selections.map(sel => sel.[2].value);
The selectionSet contains the selections, and each selection has a name property for the field name.
Fill all three blanks to check if a specific field is requested in the query using the info argument.
const selections = info.fieldNodes[0].[1].selections; const requestedFields = selections.map(sel => sel.[2].value); const hasField = requestedFields.includes([3]);
We access the selectionSet to get selections, then map to get each field's name.value. Finally, we check if the field 'email' is included.