GraphQL Resolver Vocabulary
5 exercises — master resolver vocabulary: resolver chain and context, the N+1 problem and DataLoader batching, IDOR security vulnerabilities, and resolver performance tracing.
0 / 5 completed
GraphQL resolver vocabulary quick reference
- Resolver — a function that returns the value for a specific GraphQL field
- Resolver chain — the tree of resolvers called for a single query (parent → child fields)
- Context — per-request object passed to all resolvers; holds auth user, DB, DataLoader
- N+1 problem — 1 query to fetch N objects + N individual queries for related data
- DataLoader — batches and deduplicates data fetching within a single request tick
- IDOR — Insecure Direct Object Reference; missing object-level authorisation check
- Resolver trace — field-level execution timing for identifying performance bottlenecks
1 / 5
What is a resolver in GraphQL, and how does it map to the schema?
Resolvers are the engine of a GraphQL API — they bridge the schema contract and the data sources.
Resolver function signature:
①
② For each requested field on User (
③
④ For each Post, the Post field resolvers run in turn
Default resolver: if you don't define a resolver for a field, GraphQL uses a default resolver that reads the field name as a property from the parent object (
Key vocabulary:
• Resolver — a function that returns the value for a specific GraphQL field
• Resolver chain — the tree of resolvers called for a single GraphQL query
• Default resolver — automatically reads the field name as a property from the parent object
• Context — shared resolver state (auth, DB connections, DataLoader instances)
Resolver function signature:
fieldName(parent, args, context, info) {
// parent — the object returned by the parent resolver
// args — arguments passed in the query for this field
// context — shared state (auth user, DB connection, DataLoader instances)
// info — schema info (field name, return type, AST of the query)
return /* data for this field */;
}
Example resolver map:
const resolvers = {
Query: {
user: (_, { id }, { db }) => db.users.findById(id),
},
User: {
posts: (user, _, { db }) => db.posts.findByAuthor(user.id),
// 'user' is the parent — the User object returned by the Query.user resolver
},
}
Resolver chain execution:①
Query.user resolves — returns a User object② For each requested field on User (
name, email, posts), the User's field resolvers run③
User.posts resolver uses the parent User object to fetch that user's posts④ For each Post, the Post field resolvers run in turn
Default resolver: if you don't define a resolver for a field, GraphQL uses a default resolver that reads the field name as a property from the parent object (
parent["fieldName"]). This is why simple fields like name and email often don't need explicit resolvers.Key vocabulary:
• Resolver — a function that returns the value for a specific GraphQL field
• Resolver chain — the tree of resolvers called for a single GraphQL query
• Default resolver — automatically reads the field name as a property from the parent object
• Context — shared resolver state (auth, DB connections, DataLoader instances)