graphql / graphql/graphql-spec

Explore possibility of generic types

Open
#190 74 comments 357 reactions 0 assignees View on GitHub
💭 Strawman (RFC 0)
Dominant language
JavaScript
Stars
14.6k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

As projects like Relay have shown, it's relatively common to repeat the same generic structures of types multiple times within a project. In the case of Relay, I'm talking about Connections.

The GraphQL definition language already has explicit support for one particular form of generic type, arrays:

```graphql
type Foo {
id: ID!
bars: [Bar]
}
```

I'd like to start discussion about being able to do something similar for user-defined structures:

```graphql
generic ConnectionEdge {
node: T
cursor: String
}

generic Connection {
edges: ConnectionEdge
pageInfo: PageInfo
}

type Foo {
id: ID!
bars: Connection
}
```

The overall goal is to reduce the amount of boilerplate in creating schemas with repetitive structures.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.