-
-
Notifications
You must be signed in to change notification settings - Fork 438
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
No documentation on how to add pagination type #2274
Comments
It is unclear to me what exactly you would like to see changed and how to achieve it. Perhaps you can just propose a pull request? |
I'm sorry, I hope this helps. Problem:There is no way currently (that I can see at least in the code or documentation) to add a new pagination type. There is documentation on how to point to a custom class that will return a Query Builder but it must return a Builder and so the builder cannot implement any custom pagination. Why:In my case I wanted to implement a different form of How:Since my pagination method exposed itself as a method of the builder, it fit in nicely with how other pagination types are already included. I simply needed to update the default schema and add some additional logic to know when and what method to call based on a new type value I would be more than happy to help work on this. However, I wanted to bring this up first to see if there was a valid reason not to do so or if this was already in the works. I think with some updates to the Paginator implementation and the introduction of a PaginatorType this could be done. |
Pagination is already a quite complex part of Lighthouse, so I am somewhat apprehensive about adding even more to it. However, I also see the value in making it easier for end users and have Lighthouse do the heavy lifting. I personally do not need anything like this so I do not plan to work on this, but am open to doing it as paid work or to reviewing a pull request that adds it. |
I will start working on something but here is my high level idea.
|
I could see there being a config option that maps the names of pagination types to classes that implement their behaviour. The classes would have to implement a common interface and define runtime behaviour, schema manipulation steps, etc. [
'paginator' => PaginatorPagination::class,
'simple' => SimplePagination::class,
'custom' => YourOwnPagination::class,
] Then, this configuration will need to be tied in with existing directives that use pagination - so |
Describe the bug
There is no way to integration a custom pagination type. You can add a custom resolver to add custom builder instance but cannot add a new pagination type. This is useful features as there are 1) multiple ways to do pagination 2) external factors that my required a custom or modified pagination type such as DB design, system architecture, etc.
Expected behavior/Solution
A way to integration a custom pagination type. I have added one by altering the source pagination files but that is not ideal. I believe requiring it to be an extension of a LengthAwarePagination type to be fair since it would only require adding the new type as an available type type and being able to call it as a method available on the builder.
Steps to reproduce
Output/Logs
N/A
Lighthouse Version
v5.70.0
I have done this manually by modifying the following
src/Pagniation
files:The text was updated successfully, but these errors were encountered: