smallrye-graphql icon indicating copy to clipboard operation
smallrye-graphql copied to clipboard

OptionalInt (and Long/Double) should be supported

Open ybroeker opened this issue 4 years ago • 3 comments

It would be nice if OptionalInt (and OptionalLong/OptionalDoulble) were also supported.

ybroeker avatar Mar 21 '21 23:03 ybroeker

I was under the impression that they are ?!? At least there are this : https://github.com/smallrye/smallrye-graphql/blob/910d920003c6a564478ddfcaf00fa747a97421e9/server/implementation/src/main/java/io/smallrye/graphql/scalar/number/IntegerScalar.java#L39

You you have a test case where this fails ?

phillip-kruger avatar Mar 26 '21 05:03 phillip-kruger

Sorry, you are right! Maybe I had used an older version or something.

ybroeker avatar Mar 30 '21 22:03 ybroeker

Found an error: those Optionals doesn't work as input types. The schema is generated correctly, but an error is thrown at runtime

GrpahQL-API:

@Query
public OptionalInt optionalInt(OptionalInt optionalInt) {
    return optionalInt;
}

Query:

query {
  optionalInt(optionalInt: 5)
}
SRGQL012000: Data Fetching Error: graphql.schema.CoercingParseLiteralException: SRGQL000015: Expected AST type 'IntValue' or 'StringValue' but was 'Integer'.
        at io.smallrye.graphql.scalar.number.NumberCoercing.parseLiteral(NumberCoercing.java:100)
        at io.smallrye.graphql.execution.datafetcher.helper.ArgumentHelper.correctObjectClass(ArgumentHelper.java:239)
        at io.smallrye.graphql.execution.datafetcher.helper.ArgumentHelper.afterRecursiveTransform(ArgumentHelper.java:216)
        at io.smallrye.graphql.execution.datafetcher.helper.AbstractHelper.recursiveTransform(AbstractHelper.java:82)
        at io.smallrye.graphql.execution.datafetcher.helper.ArgumentHelper.getArgument(ArgumentHelper.java:113)
        at io.smallrye.graphql.execution.datafetcher.helper.ArgumentHelper.getArguments(ArgumentHelper.java:70)
        at io.smallrye.graphql.execution.datafetcher.helper.ArgumentHelper.getArguments(ArgumentHelper.java:63)
        ...

ybroeker avatar Mar 30 '21 22:03 ybroeker

The problem mentioned by @ybroeker is now fixed via https://github.com/smallrye/smallrye-graphql/pull/1731

jmartisk avatar Feb 08 '23 11:02 jmartisk