Skip to content

Commit 87f1703

Browse files
committed
refactor: move execution instance to new class
1 parent 0ae2604 commit 87f1703

File tree

4 files changed

+1083
-1038
lines changed

4 files changed

+1083
-1038
lines changed

src/execution/compiledDocument.ts

+1-46
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { Kind } from '../language/kinds';
1111
import { assertValidSchema } from '../type/validate';
1212

1313
import type { ExecutionArgs } from './execute';
14-
import { getVariableValues } from './values';
1514

1615
/**
1716
* Data that must be available at all points during query execution.
@@ -21,11 +20,7 @@ import { getVariableValues } from './values';
2120
*/
2221
export interface ExecutionContext {
2322
fragments: ObjMap<FragmentDefinitionNode>;
24-
rootValue: unknown;
25-
contextValue: unknown;
2623
operation: OperationDefinitionNode;
27-
variableValues: { [variable: string]: unknown };
28-
errors: Array<GraphQLError>;
2924
}
3025

3126
/**
@@ -40,14 +35,7 @@ export interface ExecutionContext {
4035
export function buildExecutionContext(
4136
args: ExecutionArgs,
4237
): ReadonlyArray<GraphQLError> | ExecutionContext {
43-
const {
44-
schema,
45-
document,
46-
rootValue,
47-
contextValue,
48-
variableValues: rawVariableValues,
49-
operationName,
50-
} = args;
38+
const { schema, document, operationName } = args;
5139

5240
// If the schema used for execution is invalid, throw an error.
5341
assertValidSchema(schema);
@@ -85,41 +73,8 @@ export function buildExecutionContext(
8573
return [new GraphQLError('Must provide an operation.')];
8674
}
8775

88-
// FIXME: https://github.com/graphql/graphql-js/issues/2203
89-
/* c8 ignore next */
90-
const variableDefinitions = operation.variableDefinitions ?? [];
91-
92-
const coercedVariableValues = getVariableValues(
93-
schema,
94-
variableDefinitions,
95-
rawVariableValues ?? {},
96-
{ maxErrors: 50 },
97-
);
98-
99-
if (coercedVariableValues.errors) {
100-
return coercedVariableValues.errors;
101-
}
102-
10376
return {
10477
fragments,
105-
rootValue,
106-
contextValue,
10778
operation,
108-
variableValues: coercedVariableValues.coerced,
109-
errors: [],
110-
};
111-
}
112-
113-
/**
114-
* @internal
115-
*/
116-
export function buildPerEventExecutionContext(
117-
exeContext: ExecutionContext,
118-
payload: unknown,
119-
): ExecutionContext {
120-
return {
121-
...exeContext,
122-
rootValue: payload,
123-
errors: [],
12479
};
12580
}

0 commit comments

Comments
 (0)