Skip to content

Commit db9dc35

Browse files
committed
expose all of the execution environment to resolvers
presumably we should do this
1 parent 1c8132d commit db9dc35

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/execution/__tests__/executor-test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ describe('Execute: Handles basic execution tasks', () => {
215215

216216
expect(resolvedInfo).to.have.all.keys(
217217
'fieldName',
218-
'fieldNodes',
218+
'fieldGroup',
219+
'deferDepth',
219220
'returnType',
220221
'parentType',
221222
'path',
@@ -238,9 +239,10 @@ describe('Execute: Handles basic execution tasks', () => {
238239
operation,
239240
});
240241

241-
const field = operation.selectionSet.selections[0];
242+
const fieldNode = operation.selectionSet.selections[0];
242243
expect(resolvedInfo).to.deep.include({
243-
fieldNodes: [field],
244+
fieldGroup: [{ fieldNode, depth: 0, deferDepth: undefined }],
245+
deferDepth: undefined,
244246
variableValues: { var: 'abc' },
245247
});
246248

src/execution/execute.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ function executeField(
790790
fieldGroup,
791791
parentType,
792792
path,
793+
asyncPayloadRecord,
793794
);
794795

795796
// Get the resolve function, regardless of if its result is normal or abrupt (error).
@@ -869,12 +870,14 @@ export function buildResolveInfo(
869870
fieldGroup: FieldGroup,
870871
parentType: GraphQLObjectType,
871872
path: Path,
873+
asyncPayloadRecord?: AsyncPayloadRecord | undefined,
872874
): GraphQLResolveInfo {
873875
// The resolve function's optional fourth argument is a collection of
874876
// information about the current execution state.
875877
return {
876878
fieldName: fieldDef.name,
877-
fieldNodes: toNodes(fieldGroup),
879+
fieldGroup,
880+
deferDepth: asyncPayloadRecord?.deferDepth,
878881
returnType: fieldDef.type,
879882
parentType,
880883
path,

src/type/definition.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,12 @@ export type GraphQLFieldResolver<
890890

891891
export interface GraphQLResolveInfo {
892892
readonly fieldName: string;
893-
readonly fieldNodes: ReadonlyArray<FieldNode>;
893+
readonly fieldGroup: ReadonlyArray<{
894+
fieldNode: FieldNode;
895+
depth: number;
896+
deferDepth: number | undefined;
897+
}>;
898+
readonly deferDepth: number | undefined;
894899
readonly returnType: GraphQLOutputType;
895900
readonly parentType: GraphQLObjectType;
896901
readonly path: Path;

0 commit comments

Comments
 (0)