Skip to content

Commit

Permalink
adjust GraphQLResolveInfo to remove breaking change from v16
Browse files Browse the repository at this point in the history
graphql#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.
  • Loading branch information
yaacovCR committed Nov 26, 2024
1 parent 079167d commit 1d19845
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/execution/__tests__/executor-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ describe('Execute: Handles basic execution tasks', () => {
'rootValue',
'operation',
'variableValues',
'variableValuesWithSources',
);

const operation = document.definitions[0];
Expand All @@ -240,7 +241,8 @@ describe('Execute: Handles basic execution tasks', () => {
expect(resolvedInfo).to.deep.include({
fieldNodes: [field],
path: { prev: undefined, key: 'result', typename: 'Test' },
variableValues: {
variableValues: { var: 'abc' },
variableValuesWithSources: {
sources: {
var: {
signature: {
Expand Down
3 changes: 2 additions & 1 deletion src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,8 @@ export function buildResolveInfo(
fragments: fragmentDefinitions,
rootValue,
operation,
variableValues,
variableValues: variableValues.coerced,
variableValuesWithSources: variableValues,
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/type/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,8 @@ export interface GraphQLResolveInfo {
readonly fragments: ObjMap<FragmentDefinitionNode>;
readonly rootValue: unknown;
readonly operation: OperationDefinitionNode;
readonly variableValues: VariableValues;
readonly variableValues: { [variable: string]: unknown };
readonly variableValuesWithSources: VariableValues;
}

/**
Expand Down

0 comments on commit 1d19845

Please sign in to comment.