Skip to content

Commit e3727fc

Browse files
GraphQLScalarType: default 'parseLiteral' should handle variables (#2696)
Motivation #2657
1 parent 9da7d35 commit e3727fc

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/type/__tests__/definition-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ describe('Type System: Scalars', () => {
9191
expect(scalar.parseLiteral(parseValue('{ foo: "bar" }'))).to.equal(
9292
'parseValue: { foo: "bar" }',
9393
);
94+
expect(
95+
scalar.parseLiteral(parseValue('{ foo: { bar: $var } }'), { var: 'baz' }),
96+
).to.equal('parseValue: { foo: { bar: "baz" } }');
9497
});
9598

9699
it('rejects a Scalar type without name', () => {

src/type/definition.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,8 @@ export class GraphQLScalarType {
591591
this.serialize = config.serialize ?? identityFunc;
592592
this.parseValue = parseValue;
593593
this.parseLiteral =
594-
config.parseLiteral ?? ((node) => parseValue(valueFromASTUntyped(node)));
594+
config.parseLiteral ??
595+
((node, variables) => parseValue(valueFromASTUntyped(node, variables)));
595596
this.extensions = config.extensions && toObjMap(config.extensions);
596597
this.astNode = config.astNode;
597598
this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);

0 commit comments

Comments
 (0)