smallrye-graphql icon indicating copy to clipboard operation
smallrye-graphql copied to clipboard

Add support for Relay connections

Open marceloverdijk opened this issue 4 years ago • 7 comments

I understand time is limited, but it might be interesting to have support for Relay connections out of the box.

Similar as https://nexus.js.org/docs/plugin-connection

marceloverdijk avatar Jun 11 '20 11:06 marceloverdijk

PS: I don't need this myself, but I came across it and it might be useful to have something similar in the future.

marceloverdijk avatar Jun 11 '20 14:06 marceloverdijk

Any update regarding this? i think it's a valid use case

mutasemhidmi avatar Jan 24 '21 14:01 mutasemhidmi

No update on this. You are welcome to provide a PR !!! :)

phillip-kruger avatar Jan 25 '21 03:01 phillip-kruger

I guess chances would increase, if you would provide a tangible suggestion how the syntax would work exactly.

t1 avatar Jan 25 '21 04:01 t1

@t1 this is the official link for relay server side specification (https://relay.dev/docs/en/graphql-server-specification.html). The level of schema starts by connection -> edges -> node -> your (table row, collection document). The changes that need to be done is that you have a general type Node that has an id of type ID!, this type is usually base64 encoded and it should be used in all the ((table row, collection document) types (all of them should implement it). You can also notice that the implementation starts by a Connection type that define edges and pageInfo (i will explain pageInfo later), the edges then have cursor(i will explain later) and node and then you have your node which is your attributes or columns. Regarding the pageinfo it has information about the your queryif it has nextpage, previouspage, start cursor and end cursor which is related to the cursor that you have in the edge type. the cursor is unique value for each edge and it's used to query the next cursor for example or previous cursor that you get from query.

PS I would be happy to help if you would like to do the implementation together.

mutasemhidmi avatar Jan 26 '21 14:01 mutasemhidmi

Connection and Edge part is available in my generics example. Node is not here but can be added easily

velias avatar Jan 31 '21 09:01 velias

DGS Framework supports it natively: https://netflix.github.io/dgs/advanced/relay-pagination/ sourcecode: https://github.com/Netflix/dgs-framework/blob/master/graphql-dgs-pagination/src/main/kotlin/com/netflix/graphql/dgs/pagination/DgsPaginationTypeDefinitionRegistry.kt

lkrzyzanek avatar May 02 '23 09:05 lkrzyzanek