Skip to content
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

Closed
arthanson opened this issue Mar 10, 2023 · 3 comments
Labels
netbox severity: low Does not significantly disrupt application functionality, or a workaround is available topic: GraphQL type: bug A confirmed report of unexpected behavior in the application

Comments

@arthanson
Copy link
Collaborator

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:

query vlan {
	vlan_list {
                id
	}
}

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.

@arthanson arthanson added the type: bug A confirmed report of unexpected behavior in the application label Mar 10, 2023
@arthanson arthanson self-assigned this Mar 10, 2023
@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Mar 16, 2023
@arthanson arthanson changed the title NetBoxModelFilterSet causes queries on custom-fields even if not referenced NetBoxModelFilterSet causes GraphQL queries on custom-fields even if not referenced Mar 27, 2023
@arthanson arthanson added the status: blocked Another issue or external requirement is preventing implementation label Apr 21, 2023
@arthanson
Copy link
Collaborator Author

Adding blocked till: #9856

@arthanson arthanson removed their assignment Apr 24, 2023
@arthanson arthanson added the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label Apr 24, 2023
@jeremystretch jeremystretch removed status: accepted This issue has been accepted for implementation status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels May 4, 2023
@jeremystretch jeremystretch added the severity: low Does not significantly disrupt application functionality, or a workaround is available label Jun 23, 2023
@jeremystretch jeremystretch added the netbox label Nov 1, 2024 — with Linear
@jeremypng
Copy link

This is fixed in my branch here:
https://github.com/jeremypng/netbox/tree/refs/heads/graphql-filter-redesign

If you'll assign this to me I'll tag this issue in my PR request.

@jeremystretch
Copy link
Member

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.

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.

@jeremystretch jeremystretch closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2025
@jeremystretch jeremystretch removed the status: blocked Another issue or external requirement is preventing implementation label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
netbox severity: low Does not significantly disrupt application functionality, or a workaround is available topic: GraphQL type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

3 participants