Search code examples
spring-bootgraphqlgraphql-java

Exception using nested Input Types in GraphQL and Spring Boot


I'm trying to create a Mutation that receives an input type like this:

input Cart {
    items: [CartItem!]!
    client: String!
}

input CartItem {
    productId: Int!
    qty: Int!
}

And my Mutation goes like this:

type Mutation {
    createOrder(cart: Cart!): Order!
}

But when I try to run my Application I get the following exception:

Caused by: com.coxautodev.graphql.tools.SchemaError: Expected type 'CartItem' to be a GraphQLOutputType, but it wasn't!  Was a type only permitted for object types incorrectly used as an input type, or vice-versa?

What's going on?


Solution

  • It is a known bug of Graphql-java-tools: https://github.com/graphql-java-kickstart/graphql-java-tools/issues/216

    The input java types should have public getters.