-
Notifications
You must be signed in to change notification settings - Fork 50
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
Pagination that involves ordering #99
Comments
I will look into this. Thanks for the report. |
@vangavroche Are you sure it's not working? I just wrote a passing test. |
According to the src https://github.com/RisingStack/graffiti-mongoose/blob/master/src/query/query.js#L286 The "after" is always determined by the ID, ( > ID). So if there's some ordering, it will break. Regarding your test, it works because the ordering ( NAME_DESC) happens to be the same as the ID order. See
Named descending order: Mother > Foo > Bar It is exactly the same order the records are inserted (which is also the order of the ID generated.) |
@vangavroche You are right. I don't see an easy solution without MongoDB aggregations, but using those will be really painful. Do you see other solutions? |
Other solution is extending logic of GQ First solutionUse mongodb cursor via query_stream in mongoose and store in
Cons:
Second solutionIf used custom sorting, you should store OFFSET instead of objectID in
Cons:
Third solutionIf used custom sorting, apply sorting with 0 offset, and request objects until you not get expected id in cursor. After that get needed amount of docs.
Cons:
Fourth solution (combination of 2 and 3rd solution)Store in Fifth solutionAggregation framework Sixth solutionUsing So... To be or not to beOnly developer knows, can he skip some data, or can show twice the same, can do fullscan for every request. Or use 3rd party solution. So I think that need create ability for pluggable adapters for connections. No Silver Bullet for connections |
The silver bullet was found but it has complex realization. Connection sorting problem (not only by ID) solved in https://github.com/nodkz/graphql-compose-mongoose The main secret in
|
Pagination that involves ordering doesn't work.
Do you have any idea how to fix it elegantly?
Thanks.
The text was updated successfully, but these errors were encountered: