Skip to content

Commit bd40bac

Browse files
committed
expose all of the execution environment to resolvers
presumably we should do this
1 parent 4b044a1 commit bd40bac

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+
'fieldSet',
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+
fieldSet: [{ 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
@@ -786,6 +786,7 @@ function executeField(
786786
fieldSet,
787787
parentType,
788788
path,
789+
asyncPayloadRecord,
789790
);
790791

791792
// Get the resolve function, regardless of if its result is normal or abrupt (error).
@@ -865,12 +866,14 @@ export function buildResolveInfo(
865866
fieldSet: FieldSet,
866867
parentType: GraphQLObjectType,
867868
path: Path,
869+
asyncPayloadRecord?: AsyncPayloadRecord | undefined,
868870
): GraphQLResolveInfo {
869871
// The resolve function's optional fourth argument is a collection of
870872
// information about the current execution state.
871873
return {
872874
fieldName: fieldDef.name,
873-
fieldNodes: fieldSet.map(({ fieldNode }) => fieldNode),
875+
fieldSet,
876+
deferDepth: asyncPayloadRecord?.deferDepth,
874877
returnType: fieldDef.type,
875878
parentType,
876879
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 fieldSet: 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)