Skip to content

Support generic types #75

Closed
Closed
@oliemansm

Description

@oliemansm

What are your thoughts on adding support for generic types? Our current problem is pagination and the fact we need to copy paste a lot of the same code because it's not supported at the moment (unless we're overlooking something?). If we ever want to change our base Connection type, we would have to change a lot of code just because generics isn't supported.

This issue was raised here as well: graphql/graphql-spec#190. Basically the same use case, but it's still open. They did mention that the JS version of graphql-tools supports a way to have the connection and edges generated for a specific type:

type MyType {
  hello: String
  world: String
}

${ connectionAndEdgeFor('MyType') }

In my opinion this should be supported in some way, preferrably as pure generics, because that gives a lot more flexibility for other use cases as well. Then we could do something like:

type Connection<T> {
  pageInfo: PageInfo!
  edges: [Edge<T>]
  totalCount: Int
  nodes: [T]
}

type Edge<T> {
  node: T
  cursor: String!
}

Is this something that could be added to the library?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions