Skip to content

Customizing the type of a Relay edge #497

Answered by hayes
madebyherzblut asked this question in Q&A
Discussion options

You must be logged in to vote

Unfortunately I think this is something that doesn't work well with builder.connectionObject today. Connections were designed to infer the shape from the connection resolver (which you don't have when you define the connection object in isolation).

There are 2 ways you can do this:

You can define the connection inline with the connection field: https://stackblitz.com/edit/typescript-tifnwy?file=index.ts

or you can pass in some generics when creating the connectionObject: https://stackblitz.com/edit/typescript-x6ph9p?file=index.ts

I did need to change the return shape of toConnectionFromEdges slightly to match the expected shape of connections, but that should get you close to what you need

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@madebyherzblut
Comment options

Answer selected by madebyherzblut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants