Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nodes to be Unions #404

Open
IgnisDa opened this issue Jul 10, 2022 · 2 comments
Open

Allow nodes to be Unions #404

IgnisDa opened this issue Jul 10, 2022 · 2 comments

Comments

@IgnisDa
Copy link

IgnisDa commented Jul 10, 2022

Awesome library!

Is there a way for nodes to be a Union or ObjectType (it only allows this right now)? The relay spec itself allows this: https://relay.dev/graphql/connections.htm#sec-Node

@bobsingor
Copy link

I would also love to see an example with GraphQL Union Types

@sgarner
Copy link
Contributor

sgarner commented Oct 13, 2022

Unions should work but you have to define your own Edge class from scratch, it's not supported by extending createEdgeType() because that expects to be passed a class constructor.

Your Edge class should implements EdgeInterface<YourUnionType> and contain node and cursor properties, with node being typed and decorated to match your union. You can look at what createEdgeType does here as a basis: https://github.com/equalogic/nestjs-graphql-connection/blob/master/src/type/Edge.ts#L16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants