Skip to content

Scalars within input objects cannot be parsed in MethodFieldResolver #466

Closed
@oryan-block

Description

@oryan-block

Description

As described in graphql-java-kickstart/graphql-spring-boot#404 scalars work fine by themselves (or as an array) but not if they are defined as a field on an input object.
This is because for input objects shouldValueBeConverted is false and we try to use the object mapper to parse them.
If the mapper doesn't know how to parse that scalar, and there's no reason it should, it will fail (this can be worked around by providing a deserializer with the mapper through the objectMapperProvider option but probably not the solution we're looking for).

Expected behavior

Both queries should work:

type Query {
    test1(input: Upload): ID!
    test2(input: FileInput): ID!
}

scalar Upload

input FileInput {
    name: String!
    file: Upload
}

Actual behavior

Second query fails with:

java.lang.IllegalArgumentException: Cannot construct instance of `javax.servlet.http.Part` (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
 at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: graphql.kickstart.tools.FileInput["part"])

Steps to reproduce the bug

  1. run query test2

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions