Skip to content

Input Objects GraphQLObjectType cannot be cast to GraphQLInputType #56

Closed

Description

@icer9955

I'm following the example listed here:
https://github.com/graphql-java/graphql-java-tools#input-objects

However, when I try to launch the app, I get the following error:

graphql.schema.GraphQLObjectType cannot be cast to graphql.schema.GraphQLInputType

This is basically what I've done:

class Query implements GraphQLQueryResolver {
    public int add(AdditionInput input) {
        return input.getFirst() + input.getSecond();
    }
}

class AdditionInput {
    private int first;
    private int second;
    
    // getFirst()
    // setFirst()
    // getSecond()
    // setSecond()
}

Am I missing something? Do I need to implement some interface on AdditionInput? Or is this a bug?

Activity

  1. apottere commented on Aug 30, 2017

    @apottere
    Collaborator

    This seems like a bug, I'll have to dig in and figure out what's going on. Do you have a more complete stacktrace?

  2. apottere commented on Aug 30, 2017

    @apottere
    Collaborator

    And what does your schema look like?

  3. icer9955 commented on Aug 30, 2017

    @icer9955
    Author

    Derp, after digging into the schema I found it:

    type AdditionInput {
      first: Int,
      second: Int,
    }
    

    Should actually be:

    input AdditionInput {
      first: Int,
      second: Int,
    }
    
  4. apottere commented on Aug 30, 2017

    @apottere
    Collaborator

    I was thinking that might be the case, but I wasn't sure. It's a bug regardless, it should have a more descriptive error instead of a class cast exception.

  5. added a commit that references this issue on Sep 7, 2017
  6. added a commit that references this issue on Sep 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions