Optimize GraphQL queries #7744

Closed
opened 2025-12-29 20:27:45 +01:00 by adam · 0 comments
Owner

Originally created by @arthanson on GitHub (Mar 10, 2023).

Originally assigned to: @arthanson on GitHub.

NetBox version

v3.4.6

Python version

3.8

Steps to Reproduce

There is code in the GraphQL queryset optimizer (not currently merged, but adding this as a future issue)
netbox/netbox/graphql/fields.py

This disables the queryset optimizer if there are no filter params, the issue is that if you use graphql, filtersets and the queryset optimizer it results in extra queries. Using the optimizer with graphql and no filterset works fine, using the optimizer outside of graphql with a filterset works fine, but the combination of graphql / optimizer and filterset doesn't work. The code should be updated to allow the optimization to work in the filtered case as well.

Expected Behavior

Graphql queries with filters applied should be optimized.

Observed Behavior

If you apply a filter to GraphQL queries they are no longer optimized.

Originally created by @arthanson on GitHub (Mar 10, 2023). Originally assigned to: @arthanson on GitHub. ### NetBox version v3.4.6 ### Python version 3.8 ### Steps to Reproduce There is code in the GraphQL queryset optimizer (not currently merged, but adding this as a future issue) [netbox/netbox/graphql/fields.py](https://github.com/netbox-community/netbox/pull/11943/files#diff-453a32882215ad6bdb3c106adeeff83bcf4d2667375fe4130a8643f10be5e872) This disables the queryset optimizer if there are no filter params, the issue is that if you use graphql, filtersets and the queryset optimizer it results in extra queries. Using the optimizer with graphql and no filterset works fine, using the optimizer outside of graphql with a filterset works fine, but the combination of graphql / optimizer and filterset doesn't work. The code should be updated to allow the optimization to work in the filtered case as well. ### Expected Behavior Graphql queries with filters applied should be optimized. ### Observed Behavior If you apply a filter to GraphQL queries they are no longer optimized.
adam added the status: acceptedtype: feature labels 2025-12-29 20:27:45 +01:00
adam closed this issue 2025-12-29 20:27:45 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7744