0
0
GraphQLquery~10 mins

Info argument in GraphQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to access the GraphQL query info argument in a resolver.

GraphQL
resolve(parent, args, context, [1]) { return args.id; }
Drag options to blanks, or click blank then click option'
Ainfo
Broot
Ccontext
Dparams
Attempts:
3 left
💡 Hint
Common Mistakes
Using context instead of info to access query details.
Confusing root or parent with info argument.
2fill in blank
medium

Complete the code to get the field name from the info argument inside a resolver.

GraphQL
const fieldName = [1].fieldName;
Drag options to blanks, or click blank then click option'
Aargs
Bcontext
Cinfo
Dparent
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to get fieldName from args or context which do not have it.
3fill in blank
hard

Fix the error in accessing the selection set from the info argument.

GraphQL
const selections = info.fieldNodes[0].[1].selections;
Drag options to blanks, or click blank then click option'
AselectionSet
Bselection
Cfields
Dnodes
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'selection' instead of 'selectionSet' causes undefined errors.
Trying to access 'fields' or 'nodes' which do not exist.
4fill in blank
hard

Fill both blanks to extract the names of selected fields from the info argument.

GraphQL
const fieldNames = info.fieldNodes[0].[1].selections.map(sel => sel.[2].value);
Drag options to blanks, or click blank then click option'
AselectionSet
Bname
CfieldName
Dfields
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fieldName' instead of 'name' inside the map function.
Using 'fields' which is not a valid property here.
5fill in blank
hard

Fill all three blanks to check if a specific field is requested in the query using the info argument.

GraphQL
const selections = info.fieldNodes[0].[1].selections;
const requestedFields = selections.map(sel => sel.[2].value);
const hasField = requestedFields.includes([3]);
Drag options to blanks, or click blank then click option'
AselectionSet
Bname
C'email'
D'id'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' instead of 'name.value' causes errors.
Checking for a field name without quotes or wrong quotes.