-
Couldn't load subscription status.
- Fork 2.9k
Fixes #20422: Allow Aggregate and Prefix to filter by family in GraphQL #20626
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
Fixes #20422: Allow Aggregate and Prefix to filter by family in GraphQL #20626
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.
Thanks for the work, @rinna11. The approach looks good and correctly follows the existing pattern.
Please add tests covering the family filter for both AggregateFilter and PrefixFilter, with both FAMILY_4 and FAMILY_6 values to verify the filter returns the correct address family results.
You can add custom test methods to the AggregateTest and PrefixTest classes in ipam/tests/test_api.py. These inherit from APIViewTestCase which provides self.client, self.user, and other helpers. Please mark these tests with @tag('regression'), which you can see elsewhere in the same file. For examples, see the templated tests that are defined in netbox/tests/test_graphql.py.
|
Hi @jnovinger , thank you for the suggestion! Given that, I would like to kindly ask if we could proceed with merging this PR without adding new tests. Please let me know if you're still up for it after all that—happy to adjust! |
|
@rinna11 , yeah, let's accept this without new tests. I have some work in mind to improve GraphQL filter testing that will eventually cover all of this. If you are interested in seeing some GraphQL tests that were just added, check out #20579. Apologies for pointing you in the wrong direction with the earlier comment. It looks like you do now have conflicts, though. Please address those and I'll be happy to merge. Thanks for hanging with me! |
…to filter by family in GraphQL
6f2c7e5 to
71581e8
Compare
|
@jnovinger , I have rebased the main branch and believe the conflicts have been resolved. Thank you for your patience! |
| q |= Q(**{f"{prefix}prefix__net_contains": query}) | ||
| return q | ||
|
|
||
| def family( |
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.
I think you lost the @strawberry_django.filter_field() decorator application during rebase.
Fixes: #20422
This allows
AggregateFilterandPrefixFilterto filter by their family similar withIPAddressFilter.I've tested the following queries manually: