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

Support relay for associations #25

Closed
zachdaniel opened this issue Aug 3, 2021 · 6 comments
Closed

Support relay for associations #25

zachdaniel opened this issue Aug 3, 2021 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@zachdaniel
Copy link
Contributor

zachdaniel commented Aug 3, 2021

I've laid the groundwork for relay support, pushed to master now. There are three remaining steps:

  • when fetching :has_many or :many_to_many relationships, we need to wrap them in a connection if the destination action supports pagination
@zachdaniel zachdaniel added enhancement New feature or request good first issue Good for newcomers labels Aug 3, 2021
@zachdaniel zachdaniel changed the title Finish Graphql Relay support Support relay for associations Sep 30, 2022
@zachdaniel
Copy link
Contributor Author

Thanks to the amazing work from @dolfinus, we have the core support for relay in place, so all that is left is to make it work for relationships!

@zachdaniel
Copy link
Contributor Author

I've decided that this is out of scope for the moment. The performance of running that many cursors is highly doubtful. For now, instead, you can simply hide those relationships and/or create a calculation that produces a matching type.

@dolfinus
Copy link
Contributor

The performance of running that many cursors is highly doubtful.

What do you mean?

@zachdaniel
Copy link
Contributor Author

Well, its not so much that there would be issues with performance above and beyond the obvious, but if you make one request that has a bunch of related cursors, to seek one cursor you'd need to make the entire request again, refetching all cursors. So its a more scalable approach to do that by using a non-nested field for each relationship you want to page through. (i.e use a filter on the read<associatedResource> query)

@dolfinus
Copy link
Contributor

But the same issue is possible with offset pagination, isn't it?

@zachdaniel
Copy link
Contributor Author

Yeah, but I think people are less likely to use offset pagination on large datasets. I didn't mean to imply that we should never add relay for associations, just that I wasn't going to invest more in doing it now because it would be "better" to prefer top-level pagination. If you're interested in working on relay for associations (will have some difficult design considerations, but should be doable) I'm happy to reopen this and we could have that conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants