What is a GraphQL resolver?
Answer
A resolver is a function on the server that fetches the data for a specific field in the schema. Every field in a GraphQL schema has a corresponding resolver. Resolvers have the signature: fieldName(parent, args, context, info). parent (or root): the resolved value of the parent object. args: the arguments passed to the field in the query. context: shared across all resolvers in a request — typically contains the authenticated user, database connection, and data loaders. info: field-specific metadata about the query (AST, schema, path). If a resolver is not defined, GraphQL uses a default resolver that reads the property of the same name from the parent object. Resolvers can be async and return Promises.
Previous
What is the difference between ! (non-null) and nullable fields in GraphQL?
Next
What is the GraphQL Schema Definition Language (SDL)?