Skip to content

Custom Scalar with CustomIntScalar Fails for Numeric Variables #2286

@mpuczynski55

Description

@mpuczynski55

Hello, when using a custom scalar that implements CustomIntScalar I get a validation error when a numeric variable is passed in the query. I have prepared a reproducer here:
https://github.com/mpuczynski55/smallrye-graphql-reproducer.git

The test class that demonstrates the problem is MovieResourceTest

The root cause seems to be VariablesParser that casts all numeric variables to BigDecimal by default. This behavior conflicts with the IntCoercing implementation used for CustomIntScalar that does not handle BigDecimal values. There does not appear to be a way to set NumberCoercing (which I believe should work in this case) for custom scalars, or at least I have not found how to do so.

Expected Behavior
The numeric value should be correctly parsed

Actual Behavior
The following error is returned:

{
	"errors": [
		{
			"message": "Variable 'paginationParams' has an invalid value: SRGQL000013: Expected type [BigInteger or class extending class com.example.scalar.LongBigInteger] but was [BigDecimal].",
			"locations": [
				{
					"line": 1,
					"column": 8
				}
			],
			"extensions": {
				"classification": "ValidationError"
			}
		}
	]
}

Environment:

  • SmallRye GraphQL Version: 2.13.0
  • Quarkus Version: 3.19.1
  • Java 21

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions