0
0
GraphQLquery~10 mins

Info argument in GraphQL - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Info argument
GraphQL Query Received
Resolver Function Called
Info Argument Passed
Info Contains Query Details
Resolver Uses Info to Access Query AST
Resolver Returns Data Based on Info
Response Sent to Client
The info argument is passed to resolver functions and contains details about the GraphQL query, allowing resolvers to understand the query structure and fields requested.
Execution Sample
GraphQL
const resolver = (parent, args, context, info) => {
  console.log(info.fieldName);
  return 'Hello';
};
This resolver logs the field name requested in the query using the info argument and returns a simple string.
Execution Table
StepActioninfo.fieldNameResult
1GraphQL query calls resolver for 'greeting' fieldgreetingResolver starts execution
2Resolver logs info.fieldNamegreetingLogs 'greeting' to console
3Resolver returns 'Hello'greetingResponse 'Hello' sent to client
4Execution ends-Resolver finished
💡 Resolver returns response and execution ends
Variable Tracker
VariableStartAfter Step 1After Step 2Final
info.fieldNameundefinedgreetinggreetinggreeting
Key Moments - 2 Insights
Why does info.fieldName contain the name of the field being resolved?
Because the GraphQL engine passes the info argument to the resolver with details about the current field, as shown in execution_table step 1 and 2.
Can the info argument be used to access the full query structure?
Yes, info contains the query's abstract syntax tree (AST), allowing the resolver to inspect requested fields beyond just the current one.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the value of info.fieldName at step 2?
Aundefined
BHello
Cgreeting
Dnull
💡 Hint
Check the 'info.fieldName' column in execution_table row for step 2
At which step does the resolver return the response to the client?
AStep 2
BStep 3
CStep 1
DStep 4
💡 Hint
Look at the 'Result' column in execution_table for when the response is sent
If the query requested a field named 'user', what would info.fieldName be at step 2?
Auser
Bgreeting
Cargs
Dcontext
💡 Hint
info.fieldName matches the field being resolved, see variable_tracker and execution_table
Concept Snapshot
Info argument in GraphQL resolvers:
- Passed as 4th parameter: (parent, args, context, info)
- Contains query details and AST
- info.fieldName shows current field name
- Useful to inspect query structure
- Helps build dynamic responses
Full Transcript
The info argument is a special parameter passed to GraphQL resolver functions. It contains detailed information about the query being executed, including the name of the field currently being resolved, accessible via info.fieldName. This allows the resolver to know exactly which field it is handling. The info argument also includes the full query structure as an abstract syntax tree (AST), enabling advanced use cases like conditional data fetching based on requested fields. In the example, the resolver logs the field name and returns a simple string. The execution table shows each step: receiving the query, calling the resolver, logging info.fieldName, returning the response, and finishing execution. Understanding the info argument helps developers write flexible and efficient resolvers.