Skip to content

Commit 1d19845

Browse files
committed
adjust GraphQLResolveInfo to remove breaking change from v16
#3811 internally preserved the sources of variable values so that we could properly replace variables within complex scalars, but it also exposed this within the GraphQLResolveInfo interface available to resolvers in a breaking manner, by changing the type of the `variableValues` property. This PR reverts the change to the `variableValues` property, but exposed the extended variable information under a new `variableValuesWithSources` property.
1 parent 079167d commit 1d19845

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/execution/__tests__/executor-test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ describe('Execute: Handles basic execution tasks', () => {
222222
'rootValue',
223223
'operation',
224224
'variableValues',
225+
'variableValuesWithSources',
225226
);
226227

227228
const operation = document.definitions[0];
@@ -240,7 +241,8 @@ describe('Execute: Handles basic execution tasks', () => {
240241
expect(resolvedInfo).to.deep.include({
241242
fieldNodes: [field],
242243
path: { prev: undefined, key: 'result', typename: 'Test' },
243-
variableValues: {
244+
variableValues: { var: 'abc' },
245+
variableValuesWithSources: {
244246
sources: {
245247
var: {
246248
signature: {

src/execution/execute.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,8 @@ export function buildResolveInfo(
955955
fragments: fragmentDefinitions,
956956
rootValue,
957957
operation,
958-
variableValues,
958+
variableValues: variableValues.coerced,
959+
variableValuesWithSources: variableValues,
959960
};
960961
}
961962

src/type/definition.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,8 @@ export interface GraphQLResolveInfo {
10031003
readonly fragments: ObjMap<FragmentDefinitionNode>;
10041004
readonly rootValue: unknown;
10051005
readonly operation: OperationDefinitionNode;
1006-
readonly variableValues: VariableValues;
1006+
readonly variableValues: { [variable: string]: unknown };
1007+
readonly variableValuesWithSources: VariableValues;
10071008
}
10081009

10091010
/**

0 commit comments

Comments
 (0)