Adam Rackis
Adam Rackis

Reputation: 83376

GraphQL specify array of multiple types

Is there any way to tell GraphQL that a type is an array filled with Strings OR Integers? Basically this, if it were valid

inputHelper: [[String | Int]]

So in a query I could validly send over

inputHelper: [["foo", 1], ["bar", -1]]

Upvotes: 1

Views: 1713

Answers (1)

Daniel Rearden
Daniel Rearden

Reputation: 84867

You could potentially create a custom scalar that could accept either integers or strings.

The easier solution would be to utilize an existing JSON scalar, like the one here. Then you could just do:

inputHelper: [JSON]

or just

inputHelper: JSON

Upvotes: 1

Related Questions