Skip to content

Scalars within input objects cannot be parsed in MethodFieldResolver #466

Closed

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

Activity

  1. oryan-block commented on Jan 25, 2021

    @oryan-block
    CollaboratorAuthor

    I've proposed two possible workarounds for this issue:
    https://gist.github.com/oryan-block/7630eb6d352778164c7fbdbb45e24265
    One of which is the aforementioned deserializer idea.

  2. PhilippS93 commented on Mar 26, 2021

    @PhilippS93

    @oryan-block, do you know, when the proposed workaround will be merged into to library?

  3. oryan-block commented on Mar 29, 2021

    @oryan-block
    CollaboratorAuthor

    @PhilippS93 the workaround doesn't require changes to the library. It's all on the client side.

  4. oryan-block commented on Jun 18, 2021

    @oryan-block
    CollaboratorAuthor

    Added this to the known issues page.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions