-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closes #7598: Enable custom field filtering for GraphQL #18701
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
Conversation
Co-authored-by: Jeremy Stretch <[email protected]>
* Add as_num() method to ChoiceSet * Update circuits enums * Update DCIM enums * Update extras enums * Update IPAM enums * Add tenancy enums * Update virtualization enums * Update VPN enums * Update wireless enums * Update netbox enums * Permit TenantType.group to be null
|
We still need to update the documentation to cover:
|
|
I believe this PR also resolves the following bugs related to GraphQL functionality: |
|
We have continued using this graphql filtering system on 4.0.11 and have reduced nested queries that were taking 36s with pynetbox and the DRF API to 400ms with graphql. The additional changes you have made look good. |
| upstream_speed: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = ( | ||
| strawberry_django.filter_field() | ||
| ) | ||
| xconnect_id: FilterLookup[str] | None = strawberry_django.filter_field() |
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.
@jeremypng do you know whether it's necessary to define these filters explicitly? Setting them to auto seems to yield the same schema, but I wanted to check if you had run into any problems with this approach.
| xconnect_id: FilterLookup[str] | None = strawberry_django.filter_field() | |
| xconnect_id: strawberry.auto |
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.
If it can successfully infer the filter type from the field type it will work. From what I saw, this generally works for model fields that are physical database fields but not computed fields.
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.
That makes sense, thanks!
|
Adding a couple sample queries here for anyone testing to play with: |
arthanson
left a comment
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.
Couple small suggestions, but it could go in even without those.
Closes: #7598
This PR serves to capture @jeremypng's recent work on improving the GraphQL API. Although this work primarily targets FR #7598, it includes many foundational improvements:
USE_DEPRECATED_FILTERS = False)as_enum()method to ChoiceSet for use in GraphQL filters