2

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
}

2 Answers 2

1

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
}

Sign up to request clarification or add additional context in comments.

Comments

0

if it still does't work after use a input type, There may be other problems here.

  • the input java types should have public getters,
  • the input java types should also implement Serializable interface

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.