Skip to content

Fix parseLiteral not called on per-schema scalar overrides for inline arguments#1880

Open
ruudk wants to merge 3 commits intomasterfrom
fix-parse-literal
Open

Fix parseLiteral not called on per-schema scalar overrides for inline arguments#1880
ruudk wants to merge 3 commits intomasterfrom
fix-parse-literal

Conversation

@ruudk
Copy link
Collaborator

@ruudk ruudk commented Mar 17, 2026

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

… 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.
@ruudk ruudk requested a review from spawnia March 17, 2026 09:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Schema plumbing to AST::valueFromAST() and Values::getArgumentValues() so coercion can resolve built-in scalars from the active schema before invoking parseLiteral().
  • 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.

@ruudk
Copy link
Collaborator Author

ruudk commented Mar 17, 2026

@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 spawnia added the bug label Mar 17, 2026
@ruudk
Copy link
Collaborator Author

ruudk commented Mar 17, 2026

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants