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

FeatureRequest: get_pages/select_pages #86

Open
mattalbr opened this issue Jul 10, 2023 · 1 comment
Open

FeatureRequest: get_pages/select_pages #86

mattalbr opened this issue Jul 10, 2023 · 1 comment

Comments

@mattalbr
Copy link

I use sqlakeyset to do keyset-based pagination in my GraphQL server. It works great for top-level resolvers, but if I have nested pages, I end up encountering the N + 1 GraphQL problem. The solution to the N + 1 problem is basically a "DataLoader" that just implements a batch API. Functionally, as it relates to sqlakeyset, that means implementing a "get_pages".

I went ahead and implemented this for my company, and was hoping that sqlakeyset would be receptive to homing this functionality. I'd be happy to send a PR.

More specifically, I implemented a get_homogeneous_pages that assumes the queries all select the same columns (but can have different filters or order_bys), which allows us to do a UNION ALL and make a single round trip to the database. That would be an easy addition to sqlakeyset because there's no need to understand the caller's nor session's threading model. A get_heterogeneous_pages may be useful to someone else, but requires making assumptions about how to execute asynchronously that I think sqlakeyset probably shouldn't touch.

Thoughts? Would you be open to adding this if I sent a PR?

@acarapetis
Copy link
Collaborator

Feel free to open the PR, I'll have a look when I can :)

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

2 participants