-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
NetBoxModelFilterSet causes GraphQL queries on custom-fields even if not referenced #11949
Comments
Adding blocked till: #9856 |
This is fixed in my branch here: If you'll assign this to me I'll tag this issue in my PR request. |
…etbox-community#7598, Closes netbox-community#18126, Closes netbox-community#17681, Closes netbox-community#16511, Closes netbox-community#16305: GraphQL Filter Redesign
…etbox-community#7598, Closes netbox-community#18126, Closes netbox-community#17681, Closes netbox-community#16511, Closes netbox-community#16305: GraphQL Filter Redesign
I'm not able to reproduce this on NetBox v4.2.3. When issuing a query for any model with a custom field to retrieve the list of IDs, only one SQL query is produced. This issue was probably addressed by a more recent Strawberry release or some other change made since it was opened. |
NetBox version
v3.4.5
Python version
3.8
Steps to Reproduce
This only appears in GraphQL as you can specify which fields to return, where REST API returns all the fields and has prefetch_related for the custom-fields. Make a graphql call to any model that uses NetBoxModelFilterSet, in the debug toolbar look at the queries and see that queries are made to custom-field even though they aren't referenced in the query. Example query below:
Traced down the issue: https://github.com/netbox-community/netbox/blob/develop/netbox/netbox/filtersets.py#L249 This code is causing custom-fields to be queried even if they aren't in GraphQL request.
Found while working on issue #11291 so opening a separate bug to track.
Expected Behavior
If custom-fields are not referenced in the filter then then queries shouldn't be done for them.
Observed Behavior
Queries are always added for the custom fields.
The text was updated successfully, but these errors were encountered: