Open mikkelmk opened 1 year ago
@jeremystretch I don't think there is a way to do this performantly with the current design, since it is a content_type the reference to the object is stored in the json field, so there isn't a DB reference to signal the deletion of the referenced object. When deserializing from GraphQL it just returns the value of the json, to do this would need to query the referenced object to make sure it exists which would work for a single query but not a list (n+1 queries).
We could make a GFK mapping table for custom field object references (GFK -> GFK) That could clean up when the referenced object is deleted, but I don't think we would want to do that just for this.
One idea I've had on the back burner is reimplementing the custom fields feature in NetBox to utilize discrete database fields (as opposed to monolithic JSON blobs) managed via dynamic schema migrations. I haven't gotten around to drafting an FR for that yet, but it occurs to me that such a change would resolve this bug as well.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.
@arthanson could you revisit this now that we've switched from Graphene to Strawberry in NetBox v4.0?
This isn't blocked on GraphQL, it is blocked on Custom Field data being JSON blobs which would make this non-performant.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.
NetBox version
v3.5.1
Python version
3.10
Steps to Reproduce
Expected Behavior
GraphQL output like this:
Observed Behavior
GraphQL output like this:
Note that the field will be null in both the Web interface and REST API - I believe that what happens is that the underlying custom_field_data on the interface is not cleared, but that the Web/API layer knows to nullify the invalid reference