-
Notifications
You must be signed in to change notification settings - Fork 227
Added sort support #101
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
Added sort support #101
Conversation
I've changed the implementation to use a subclass of string instead of the list, so that the ast graph can be created successfully and there is no need to query the model every time. |
The sort enum value is now a subclass of str that cat store the sort operator and be treated as string when creating the ast graph
d0337ba
to
2fd5203
Compare
Nice, thank you. Maybe, as I've already commented in #40, the |
Good idea. I'll add it. |
For an |
acc1a8a
to
bead50a
Compare
|
This going to get merged? |
I hope so. |
Hi, |
On my part I wanted a feedback from @syrusakbary about the implementation before writing the tests. |
@syrusakbary We are waiting on you to review the PR |
Sorry for the time taken on reviewing this PR, and thanks for the ping. |
Thanks for the review @syrusakbary |
@syrusakbary I think it's ready for a review Let me know what you think |
It looks great! You did a great job 👏 Merging |
Thank you for merging it! |
Add support for sorting the return values of a
SQLAlchemyConnectionField
The
sort
argument ofSQLAlchemyConnectionField
supports sorting over a single over multiple field.In the utils file I've added
sort_enum_for_model
to create a graphene Enum with all be possible field and order combination for a particular sqlalchemy model as suggested by @Citosort_argument_for_model
to automacally create the enum and return the attribute to use in the connection fieldThe test and documentation are still missing, because first I wanted to get some feedback about the implementation.
Regarding the value of the sort enumerator at first I tried to set the values of the enum to the ascenting or descenting operators of sqlalchemy simplify the logic of the get_query but that results in an error when graphql builds the ast graph, so I reverted to use a list column_name, operator that is less than optimal since every time it needs to query the model to create the operators.
Thanks to @Cito to the input in #40
Closes #40