GraphQL support for reverse generic relationships #5111

Closed
opened 2025-12-29 19:24:23 +01:00 by adam · 3 comments
Owner

Originally created by @ryanmerolle on GitHub (Jul 28, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.0-beta1

Feature type

Change to existing functionality

Proposed functionality

It looks like ForeignKey relationship are automatically handled in the NetBox implementation of graphql, but any relationship via a GenericForeignKey is not created.

From browsing the code I think the following use GenericForeignKey relationships:

  • Cable - termination_a & termination_b - Available via the cable ForeignKey on termination models
  • CablePath - origin & destination - We don't currently support cable paths in the GraphQL API, nor do we link to paths directly in the REST API. Probably needs more discussion.
  • CableTermination - _cable_peer - This is accessible as a forward relation from opposite ends of the cable
  • ObjectChange - changed_object & related_object
  • IPAddress - assigned_object
  • ImageAttachment - parent
  • JournalEntry - assigned_object
  • VLANGroup - scope

Use case

This would be needed if we truly want to leverage graphql queries to tie separated but related models together. For example, we cannot currently tie circuit information or ipam data to a device's interfaces.

Database changes

None

External dependencies

None

Originally created by @ryanmerolle on GitHub (Jul 28, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.0-beta1 ### Feature type Change to existing functionality ### Proposed functionality It looks like `ForeignKey` relationship are automatically handled in the NetBox implementation of graphql, but any relationship via a `GenericForeignKey` is not created. From browsing the code I think the following use `GenericForeignKey` relationships: - [x] ~Cable - termination_a & termination_b~ - Available via the `cable` ForeignKey on termination models - [ ] ~CablePath - origin & destination~ - We don't currently support cable paths in the GraphQL API, nor do we link to paths directly in the REST API. Probably needs more discussion. - [x] ~CableTermination - _cable_peer~ - This is accessible as a forward relation from opposite ends of the cable - [x] ObjectChange - changed_object & related_object - [x] IPAddress - assigned_object - [x] ImageAttachment - parent - [x] JournalEntry - assigned_object - [x] VLANGroup - scope ### Use case This would be needed if we truly want to leverage graphql queries to tie separated but related models together. For example, we cannot currently tie circuit information or ipam data to a device's interfaces. ### Database changes None ### External dependencies None
adam added the status: acceptedtype: featurebeta labels 2025-12-29 19:24:23 +01:00
adam closed this issue 2025-12-29 19:24:23 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jul 29, 2021):

This is a great opportunity for some GraphQL power users to get involved with its development in NetBox.

@jeremystretch commented on GitHub (Jul 29, 2021): This is a great opportunity for some GraphQL power users to get involved with its development in NetBox.
Author
Owner

@jeremystretch commented on GitHub (Aug 3, 2021):

I've addressed everything but the cable path item in #6873. (That one probably deserves a deeper discussion as it relates to parity with the REST API.)

@jeremystretch commented on GitHub (Aug 3, 2021): I've addressed everything but the cable path item in #6873. (That one probably deserves a deeper discussion as it relates to parity with the REST API.)
Author
Owner

@ryanmerolle commented on GitHub (Aug 4, 2021):

Thanks. I will test and revert if anything.

@ryanmerolle commented on GitHub (Aug 4, 2021): Thanks. I will test and revert if anything.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5111