-
Notifications
You must be signed in to change notification settings - Fork 133
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
Add DSL compiler for Kaminari #2100
base: main
Are you sure you want to change the base?
Conversation
I think we want to reduce the number of external gem compilers in tapioca. So ideally this would live inside Kaminari repo and be maintained by the gem maintainers. I also remember https://github.com/angellist/boba which aimed to host tapioca compilers. cc @stathis-alexander |
The idea of gem maintainers hosting their own compilers is a nice future to look forward to!
We'd be happy to accept this as part of Boba. We don't use Kaminari (we use graphql), but it fits the concept of the Boba |
Thanks all, I totally missed this note at the bottom of the README: https://github.com/Shopify/tapioca?tab=readme-ov-file#dsl-compilers. I'll send a PR over to Boba soon. |
Submitted an issue here: kaminari/kaminari#1139 |
@andyw8 The new policy makes more sense (since you already host non-rails compilers like GQL). Appreciate you including Boba! How do submitters know whether Shopify uses a particular gem or not? Is the process just:
Additionally, have y'all attempted (recently) to get Rails or GraphQL to accept Tapioca compilers? |
Hi @stathis-alexander, yes that process makes sense. And we'll consider if we can submit compilers to any gems. 👍 |
Looks like this got merged in Boba 👍 angellist/boba#2 |
Yes, that happened prior to @andyw8's suggestion to merge it into Tapioca. I'm sure we can move it here if folks are still interested in doing that. |
@andyw8, just checking in. I haven't heard a response back from the maintainer of Kaminari. Do we want to continue waiting until we receive a response? |
Is Yuki24 not a maintainer? |
Motivation
Closes #1859
Kaminari is one of the most popular gems in the Rails ecosystem.
Kaminari's
.page
scope is defined dynamically and not detected by Tapioca's scopes compiler. Also,.page
uses.extending
to extend the relation with more methods (e.g..per
,.total_count
,.total_pages
,.current_page
).See issue #1859 for more details.
Implementation
This PR adds a compiler for Kaminari that adds the
.page
method toGeneratedRelationMethods
. The return type is a union:If the
ActiveRecordRelations
compiler is not enabled, this compiler will take that into account.Tests
Tests are included.