Array of strings as input

Hi. We have a possibility to provide few values as input. A simplified schema would be this:
input Filter {
include: [String]
exclude: [String]
type Query {
items (filter:Filter): [Item]

I was surprised that requesting { items (filter:{ include: “1” }) { … } } doesn’t generate GraphQL validation error. Is that how it is supposed to be? Looks more like a bug for me. This also applies to Federation.

So, shall we expect this changed?

This is a convenience feature in GraphQL, possibly specific to Apollo.

If you have a list defined as an input, and you only provide 1 item, it just wraps the item in an array for you. I suggest checking the behavior between [String], [String!], [String]!, and [String!]!, because I don’t recall if there’s any difference between them as it pertains to that convenience feature.

Thanks Kevin. I think Apollo didn’t expect someone would use Apollo Gateway + GraphQL Java services. I will see if I can tune GraphQL Java. However, I would like to submit a change request. Do you know how to do it?

Link to creating a ticket.

This is not specific to Apollo, this is in the specification under List Coercion.

We use Apollo Gateway with federation-jvm in our own infrastructure, so we definitely did anticipate this. Also, just so it’s known, the Gateway works with many subgraph implementations in several languages, including Python, Ruby, Java and more. The full list of tested subgraph implementations can be found here. There’s also a recent post related to this here on the forums.

Appreciate the intent on opening a change request to fix any bug you may have encountered in a GraphQL server or federated subgraph implementation though — I’m not sure where your bugfix goes, in this case, but it sounds like federation-jvm or graphql-java itself?

1 Like