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:
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.