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
Filtering interface implementation #3952
Filtering interface implementation #3952
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whenever you have 5 minutes before switching from draft to ready for review, could you add look back at the changes and put some more comments so the code will be quicker to read when not familiar with the implementation?
@NyanKiyoshi No worries :) |
Codecov Report
@@ Coverage Diff @@
## master #3952 +/- ##
==========================================
- Coverage 91.3% 91.27% -0.03%
==========================================
Files 267 275 +8
Lines 14501 14953 +452
Branches 1393 1448 +55
==========================================
+ Hits 13240 13649 +409
- Misses 894 913 +19
- Partials 367 391 +24
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, good job! 🎉
@korycins Looks good! I have few notes to change later but I'd really like to merge it as it is and make some improvements later. Remember to update the changelog ;) |
Backend part - #2588
This feature introduces base filter logic that can be used in any graphQL queries.
How it works:
I've created
EnumFilter
which handle graphQL enums, it was needed to serve enum fields over api. Based ondjango-filters
andEnumFilter
we create newFilterSet
object with all fields that we want to use in filters. Our customFilterSet
should be assigned in a derived class fromFilterInputObjectType
.FilterInputObjectType
is responsible for converting all django-filter's fields to graphene fields (also enum fields). An object of a class that derives fromFilterInputObjectType
should be assigned as a new param inFilterInputConnectionField
(by default it should be filters=FilterInputObjectType(), but you can also pass custom filters name - All filters will be available under this name in API).You can also check the test:
test_filter_input which
. The test contains configuration step by step.What do you think? If you like it we can think about the implementation of the filters for the rest of the queries. For now, I've added some filters only for products view.
We can also think about some small documentation chapter about filtration.
Pull Request Checklist