Search code examples
springspring-bootgraphqlgraphql-java

Spring Boot GraphQL: Expected type to be a GraphQLInputType, but it wasn't


I am trying to set up a GraphQL endpoint in Spring Boot, and when I try to run my App, I get the following error:

Expected type 'Order' to be a GraphQLInputType, but it wasn't! Was a type only permitted for object types incorrectly used as an input type, or vice-versa?

Here is my models.graphqls:

type Order {
    id: String!
    storeOrderId: String
    connectionId: String
}

type Mutation {
    createOrder(order: Order): Order
}


Solution

  • This is happening because you're trying to use a type for an input, which isn't allowed.

    type Order {

    Should be...

    input Order {

    So that the whole thing looks like:

    I am trying to set up a GraphQL endpoint in Spring Boot, and when I try to run my App, I get the following error:

    Expected type 'Order' to be a GraphQLInputType, but it wasn't! Was a type only permitted for object types incorrectly used as an input type, or vice-versa?

    Here is my models.graphqls:

    input Order {
        id: String!
        storeOrderId: String
        connectionId: String
    }
    
    type Mutation {
        createOrder(order: Order): Order
    }