|
| 1 | +import type { ObjMap } from '../jsutils/ObjMap'; |
| 2 | +import type { Path } from '../jsutils/Path'; |
| 3 | + |
| 4 | +import type { |
| 5 | + FieldNode, |
| 6 | + FragmentDefinitionNode, |
| 7 | + OperationDefinitionNode, |
| 8 | +} from '../language/ast'; |
| 9 | + |
| 10 | +import type { |
| 11 | + GraphQLField, |
| 12 | + GraphQLObjectType, |
| 13 | + GraphQLOutputType, |
| 14 | + GraphQLResolveInfo, |
| 15 | +} from '../type/definition'; |
| 16 | +import type { GraphQLSchema } from '../type/schema'; |
| 17 | + |
| 18 | +interface ExecutionDetails { |
| 19 | + schema: GraphQLSchema; |
| 20 | + fragments: ObjMap<FragmentDefinitionNode>; |
| 21 | + rootValue: unknown; |
| 22 | + operation: OperationDefinitionNode; |
| 23 | + variableValues: { [key: string]: unknown }; |
| 24 | +} |
| 25 | + |
| 26 | +/** @internal */ |
| 27 | +export class ResolveInfo implements GraphQLResolveInfo { |
| 28 | + readonly fieldName: string; |
| 29 | + readonly fieldNodes: ReadonlyArray<FieldNode>; |
| 30 | + readonly returnType: GraphQLOutputType; |
| 31 | + readonly parentType: GraphQLObjectType; |
| 32 | + readonly path: Path; |
| 33 | + readonly schema: GraphQLSchema; |
| 34 | + readonly fragments: ObjMap<FragmentDefinitionNode>; |
| 35 | + readonly rootValue: unknown; |
| 36 | + readonly operation: OperationDefinitionNode; |
| 37 | + readonly variableValues: { [variable: string]: unknown }; |
| 38 | + |
| 39 | + constructor( |
| 40 | + executionDetails: ExecutionDetails, |
| 41 | + fieldDef: GraphQLField<unknown, unknown>, |
| 42 | + fieldNodes: ReadonlyArray<FieldNode>, |
| 43 | + parentType: GraphQLObjectType, |
| 44 | + path: Path, |
| 45 | + ) { |
| 46 | + this.fieldName = fieldNodes[0].name.value; |
| 47 | + this.fieldNodes = fieldNodes; |
| 48 | + this.returnType = fieldDef.type; |
| 49 | + this.parentType = parentType; |
| 50 | + this.path = path; |
| 51 | + const { schema, fragments, rootValue, operation, variableValues } = |
| 52 | + executionDetails; |
| 53 | + this.schema = schema; |
| 54 | + this.fragments = fragments; |
| 55 | + this.rootValue = rootValue; |
| 56 | + this.operation = operation; |
| 57 | + this.variableValues = variableValues; |
| 58 | + } |
| 59 | +} |
0 commit comments