GraphQL input enums

So I have recently been using the GraphQL feature to build and run my queries. Some of my queries use ENUMs as an input. When you build these queries via the query builder and enter your input into the box is comes out as a string between quotes. This is not an enum (which requires the quotes to be removed) and so you get this confusing error message
Enum "CustomerOrder_OrderType" cannot represent non-enum value: "ORDER". Did you mean the enum value "ORDER"?

This message should probably use backticks rather than quotes on the example just to differentiate them.

Also is there a way I am missing to escape the quotes when using the input box? It also feels like the input for a type that is a enum should be a drop down of the enums values.

Hey @tompea :wave: ,
Thanks for sharing this. I tried using a GraphQL API that takes the input as an enum but didn’t face similar issues. It would be super helpful if you could either provide a screen recording or any screenshots of the error you are facing that would help me reproduce it.

I used the https://api.cartql.com API, SKU is a CartItemType :point_down: Also, I’m using the GraphQL v2 client.

graphql-error

P.S. The error message does seem confusing though :thinking:

1 Like

Hey @meenakshi.dhanani,

Thanks for getting back to me. What you’ve sent is exactly what I expected to happen. Maybe there is some step I missed in my setup?

This is schema type

"""Enum for order type."""
enum CustomerOrder_OrderType {
  """Order type is order."""
  ORDER
  """Order type is wishlist."""
  WISHLIST
}

I have no dropdown option. I also can’t seem to add an attachment of my screen recording as I am a “new user”

Best I can do is this dropbox link

Else I am not sure how to become not a “new use”

Dropbox - Screen Recording 2024-04-04 at 12.01.55.mov - Simplify your life


Can now upload the recording :slight_smile:

Perfect! Thanks for the screen recording :slight_smile:

That’s funny. I would’ve expected a dropdown for the enums. Could you confirm the schema has parsed the OrderType as an enum?

For instance, I tried validating mine via the Documentation pane on the right.

graphql-docs

My documentation tab does not seem to generate like yours. It does not give me the inputs of my query. I am wondering if this could be related to the fact that my query with inputs is not at the top level? I can confirm the schema is an enum.

The documentation tab reflects what is selected by the query builder.
Also, I would expect the CustomerOrder type to be an input type, like here. The screen recording shows the output type I think, probably that’s why I can’t see the input keyword.

Meanwhile, I can try checking locally with another API if it behaves the same if the mutation isn’t top level.

I tested it for a mutation within a level as well, the dropdown still appears.

level-mutation-graphql

Strange, jsut trying to figure out any differences in our approaches. Is your schema from a schema file or via introspection, mine is via introspection. It is also a Federated GraphQL Service although not sure that should make a differences.

Hey @tompea,
I’m using introspection; I don’t think it should matter how the schema is generated if the structure is similar. Let me check if anyone on the product team knows anything more.