Resolver function in a GraphQL schema accepts four positional arguments:
fieldName:(root, args, context, info) => { result }
| Arguments | Description |
|---|---|
| root | The object that contains the result returned from the resolver on the parent field. |
| args | An object with the arguments passed into the field in the query. |
| context | This is an object shared by all resolvers in a particular query. |
| info | It contains information about the execution state of the query, including the field name, the path to the field from the root. |
Resolvers in GraphQL can return different types of values:
| Arguments | Description |
|---|---|
| null or undefined | Indicates the object could not be found |
| array | Only valid if the schema indicates that the result of a field should be a list |
| promise | Resolvers often do asynchronous actions like fetching from a database or backend API, so they can return promises |
| scalar or object | A resolver can also return other values |