GraphQL DjangoModelType only has pk attribute #10337

Closed
opened 2025-12-29 21:30:12 +01:00 by adam · 2 comments
Owner

Originally created by @SRF-oberlicy on GitHub (Oct 9, 2024).

Originally assigned to: @arthanson on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.1.1

Python Version

3.11

Steps to Reproduce

When querying cables and their terminations, i cannot get the device name of the terminating interface anymore (since NB v4 / strawberry GraphQL)

Example query:

query {
  virtual_chassis_list {
    name
    members {
      name
      uplink_interfaces: interfaces {
        name
        cable {
          terminations {
            display
            _device {
              pk
            }
          }
        }
      }
    }
  }
}

Expected Behavior

In Netbox 3.7 we were able to query for the parent device of the termination, therefore I would expect have the same or a similar behaviour. Since the pk is available, the name shouldn't be too far away.

Observed Behavior

The DjangoModelType (in this case the _device) only has a pk attribute which provides the ID of the device.

Originally created by @SRF-oberlicy on GitHub (Oct 9, 2024). Originally assigned to: @arthanson on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.1.1 ### Python Version 3.11 ### Steps to Reproduce When querying cables and their terminations, i cannot get the device name of the terminating interface anymore (since NB v4 / strawberry GraphQL) ### Example query: ```graphql query { virtual_chassis_list { name members { name uplink_interfaces: interfaces { name cable { terminations { display _device { pk } } } } } } } ``` ### Expected Behavior In Netbox 3.7 we were able to query for the parent device of the termination, therefore I would expect have the same or a similar behaviour. Since the pk is available, the name shouldn't be too far away. ### Observed Behavior The DjangoModelType (in this case the _device) only has a pk attribute which provides the ID of the device.
adam added the type: bugstatus: acceptedtopic: GraphQLseverity: low labels 2025-12-29 21:30:12 +01:00
adam closed this issue 2025-12-29 21:30:12 +01:00
Author
Owner

@arthanson commented on GitHub (Oct 16, 2024):

@SRF-oberlicy Actually the _device, _site, _rack, _locaton fields are internal cached fields and shouldn't actually be exposed, so I will remove those. The correct way would be to query using fragments, something like:

query {
  virtual_chassis_list {
    name
    members {
      name
      uplink_interfaces: interfaces {
        name
        cable {
          terminations {
            display
            termination {
              ... on CircuitTerminationType {
                id
              }              
              ... on ConsolePortType {
                id
                name
              }
              ... on ConsoleServerPortType {
                id
                name
              }

            }
          }
        }
      }
    }
  }
}

@arthanson commented on GitHub (Oct 16, 2024): @SRF-oberlicy Actually the _device, _site, _rack, _locaton fields are internal cached fields and shouldn't actually be exposed, so I will remove those. The correct way would be to query using fragments, something like: ``` query { virtual_chassis_list { name members { name uplink_interfaces: interfaces { name cable { terminations { display termination { ... on CircuitTerminationType { id } ... on ConsolePortType { id name } ... on ConsoleServerPortType { id name } } } } } } } } ```
Author
Owner

@SRF-oberlicy commented on GitHub (Oct 16, 2024):

@arthanson thanks, we were able to achieve it with the following query:

query {
  virtual_chassis_list {
    name
    members {
      name
      uplink_interfaces: interfaces {
        name
        cable {
          terminations {
            display
            termination {
              ... on InterfaceType {
                name
                device {
                  name
                }
              }
            }
          }
        }
      }
    }
  }
}
@SRF-oberlicy commented on GitHub (Oct 16, 2024): @arthanson thanks, we were able to achieve it with the following query: ```graphql query { virtual_chassis_list { name members { name uplink_interfaces: interfaces { name cable { terminations { display termination { ... on InterfaceType { name device { name } } } } } } } } } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10337