graphql / graphql/graphql-spec
Extend Wrapping Types with additional primitive Tuple
- Dominant language
- JavaScript
- Stars
- 14.6k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
# GraphQL Tuples
At this stage, GraphQL does not provide tuples. This issue proposes to extend the GraphQL specification with an additional primitive type `Tuple` (of kind `WRAPPER`).
a GraphQL tuple `(a₁,...,aₙ₋₁, type)` is a list of fixed size `n`, where the first `n-1` arguments can be either `enum`, `scalar`, or `wrapper` types, but the last argument can take any possible type.
accordingly, the selection will be applied only to the last argument.
For example a API with the following schema for query `{ users { name } }`
```graphql
type User {
name: String
age: Int
}
type Query {
users : [(ID!,User)]
}
```
will produce the response:
```json
{
"data": {
"users": [
["jkgad", { "name": "Alex" }],
["t9t98", { "name": "John" }],
]
}
}
```
this way we can support a `Map` in GraphQL.
Additional considerations of syntax, semantics, and introspection are presented in the [morpheus-graphql-proposals](https://github.com/morpheusgraphql/graphql-proposals/blob/master/proposals/tuples.md)
Contributor guide
Assessment
This issue has not been assessed yet.