Fix parseLiteral not called on per-schema scalar overrides for inline arguments#1880
Open
Fix parseLiteral not called on per-schema scalar overrides for inline arguments#1880
Conversation
… arguments AST::valueFromAST() called parseLiteral() on the built-in scalar singleton from field definitions, not the custom override registered via the type loader. This meant inline literal arguments like `node(id: 123)` silently skipped custom parsing logic. Pass the Schema into valueFromAST() and resolve built-in scalars from it before calling parseLiteral(), mirroring the parseValue() fix in Value::coerceInputValue(). Also extract Type::isBuiltInScalarName() to centralize the name check without requiring an instanceof guard.
There was a problem hiding this comment.
Pull request overview
This PR fixes an execution-time coercion bug where inline literal arguments (e.g. node(id: 123)) could bypass per-schema overrides of built-in scalars by calling parseLiteral() on the built-in singleton instead of the schema-resolved scalar instance.
Changes:
- Add optional
Schemaplumbing toAST::valueFromAST()andValues::getArgumentValues()so coercion can resolve built-in scalars from the active schema before invokingparseLiteral(). - Centralize the built-in scalar name check via
Type::isBuiltInScalarName(). - Add regression tests for inline-argument
parseLiteral()invocation and unit tests for the new helper; update generated class-reference docs.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/Utils/AST.php |
Adds schema-aware scalar resolution before parseLiteral() for built-in scalar names. |
src/Executor/Values.php |
Threads optional schema into argument coercion so inline literals can use schema overrides. |
src/Executor/ReferenceExecutor.php |
Passes execution schema into argument coercion during field resolution. |
src/Type/Definition/Type.php |
Extracts isBuiltInScalarName() helper and uses it for built-in scalar checks. |
tests/Type/ScalarOverridesTest.php |
Regression test ensuring overridden ID scalar’s parseLiteral() is called for inline args. |
tests/Type/Definition/TypeTest.php |
Unit tests for Type::isBuiltInScalarName(). |
docs/class-reference.md |
Updates AST::valueFromAST() signature documentation to include the schema parameter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Collaborator
Author
|
@spawnia Don't have time today anymore to apply the feedback. If you could have a look that would be great. Otherwise I'll continue tomorrow. |
Directive arguments (e.g. @include(if: true)) were not using schema-resolved scalar overrides because getDirectiveValues() did not pass the schema to getArgumentValues(). 🤖 Generated with Claude Code
spawnia
approved these changes
Mar 17, 2026
Collaborator
Author
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AST::valueFromAST() called parseLiteral() on the built-in scalar singleton from field definitions, not the custom override registered via the type loader. This meant inline literal arguments like
node(id: 123)silently skipped custom parsing logic.Pass the Schema into valueFromAST() and resolve built-in scalars from it before calling parseLiteral(), mirroring the parseValue() fix in Values::coerceInputValue().
Also thread the schema through getDirectiveValues() so directive arguments (e.g.
@include(if: true)) use schema-resolved scalars too.Extract Type::isBuiltInScalarName() to centralize the name check without requiring an instanceof guard.
Related to #1869