GraphQL Resolve Info
-
You can access its type like this:
import { GraphQLResolveInfo } from 'graphql'; -
A key on the
infoobject is either:- Field-specific:
- The value for that key depends on the field.
fieldName,fieldNodes,path,rootType, andparentType.
- Global:
- The values for these keys won’t change, no matter which resolver we’re talking about.
schema,fragments,rootValue,operationandvariableValues.
- Field-specific:

-
fieldNodes:- Contains an excerpt of the query AST.
- This excerpt starts at the current field (i.e. author) rather than at the root of the query (The entire query AST which starts at the root is stored in
operation).
It's value should be something similar to this:
{ "fieldNodes": [ { "kind": "Field", "name": { "kind": "Name", "value": "author", "loc": { "start": 27, "end": 33 } }, "arguments": [ { "kind": "Argument", "name": { "kind": "Name", "value": "id", "loc": { "start": 34, "end": 36 } }, "value": { "kind": "StringValue", "value": "user-1", "block": false, "loc": { "start": 38, "end": 46 } }, "loc": { "start": 34, "end": 46 } } ], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [ { "kind": "Field", "name": { "kind": "Name", "value": "username", "loc": { "start": 54, "end": 62 } }, "arguments": [], "directives": [], "loc": { "start": 54, "end": 62 } }, { "kind": "Field", "name": { "kind": "Name", "value": "posts", "loc": { "start": 67, "end": 72 } }, "arguments": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [ { "kind": "Field", "name": { "kind": "Name", "value": "id", "loc": { "start": 81, "end": 83 } }, "arguments": [], "directives": [], "loc": { "start": 81, "end": 83 } }, { "kind": "Field", "name": { "kind": "Name", "value": "title", "loc": { "start": 90, "end": 95 } }, "arguments": [], "directives": [], "loc": { "start": 90, "end": 95 } } ], "loc": { "start": 73, "end": 101 } }, "loc": { "start": 67, "end": 101 } } ], "loc": { "start": 48, "end": 105 } }, "loc": { "start": 27, "end": 105 } } ] } -
path:GraphQL Query pathwhen resolvingPost.titlequery AuthorWithPosts { author { posts { title } } }{ "path": { "prev": { "prev": { "prev": { "key": "author" }, "key": "posts" }, "key": 0 }, "key": "title" } } -
operation:It's value should be something similar to this:
{ "operation": { "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "AuthorWithPosts" }, "selectionSet": { "kind": "SelectionSet", "selections": [ { "kind": "Field", "name": { "kind": "Name", "value": "author" }, "arguments": [ { "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "StringValue", "value": "user-1" } } ], "selectionSet": { "kind": "SelectionSet", "selections": [ { "kind": "Field", "name": { "kind": "Name", "value": "username" } }, { "kind": "Field", "name": { "kind": "Name", "value": "posts" }, "selectionSet": { "kind": "SelectionSet", "selections": [ { "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "title" } } ] } } ] } } ] } } } -
variableValues:{ "variableValues": { "userId": "user-1" } }