What is a Resolver
A resolver is a function that fetches the data for a single field in a GraphQL schema. When a query arrives, the GraphQL engine walks the query tree and calls the resolver for each requested field.
How it works
Each resolver receives four arguments: the parent object (result of the parent field's resolver), the field arguments, a context object (shared across all resolvers — database connections, auth info), and field metadata. The resolver returns the value for its field, which can be a scalar, an object, or a list.
Resolvers compose naturally. The Query.user resolver returns a user object. The User.posts resolver receives that user and returns its posts. Each resolver is responsible for one field only.
Why it matters
Resolvers are where GraphQL meets your data sources. A single query can hit a database, a REST API, a cache, and a microservice — each field resolved independently. This flexibility is powerful but creates the N+1 problem when resolvers make one database query per item. DataLoader batches these into a single query.
See How GraphQL Works for resolvers, DataLoader, and the N+1 problem.