GraphQL: Querying of cable within a cabletermination_set of an device can only return the ID but no the corresponding cable #10526

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

Originally created by @dxks on GitHub (Nov 29, 2024).

Originally assigned to: @dxks on GitHub.

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

v4.1.7

Python Version

3.11

Steps to Reproduce

Create a simple GraphQL query to get all cable-terminations of an device and retrieve the cable information:

{
  device(id: 249) {
    cabletermination_set {
      cable {
        display
      }
    }
  }
}

You will retrieve the following error:

{
  "data": null,
  "errors": [
    {
      "message": "Cannot query field 'display' on type 'DjangoModelType'.",
      "locations": [
        {
          "line": 2,
          "column": 61
        }
      ]
    }
  ]
}

Expected Behavior

Retrieve the cable details on the cable-termination:

{
  "data": {
    "device": {
      "cabletermination_set": [
        {
          "cable": {
            "display": "#2452"
          }
        }
      ]
    }
  }
}

Observed Behavior

The cable of cabletermination_set is referencing ModelDjangoType instead of CableType. Querying the cable will only possible when querying the terminations and cable there.

Originally created by @dxks on GitHub (Nov 29, 2024). Originally assigned to: @dxks on GitHub. ### Deployment Type Self-hosted ### Triage priority N/A ### NetBox Version v4.1.7 ### Python Version 3.11 ### Steps to Reproduce Create a simple GraphQL query to get all cable-terminations of an device and retrieve the cable information: ``` { device(id: 249) { cabletermination_set { cable { display } } } } ``` You will retrieve the following error: ``` { "data": null, "errors": [ { "message": "Cannot query field 'display' on type 'DjangoModelType'.", "locations": [ { "line": 2, "column": 61 } ] } ] } ``` ### Expected Behavior Retrieve the cable details on the cable-termination: ``` { "data": { "device": { "cabletermination_set": [ { "cable": { "display": "#2452" } } ] } } } ``` ### Observed Behavior The cable of cabletermination_set is referencing ModelDjangoType instead of CableType. Querying the cable will only possible when querying the terminations and cable there.
adam added the type: bugstatus: acceptedtopic: GraphQLseverity: low labels 2025-12-29 21:32:38 +01:00
adam closed this issue 2025-12-29 21:32:38 +01:00
Author
Owner

@dxks commented on GitHub (Dec 4, 2024):

I had a look into this and see that other CabledModels uses a Mixin but this will not fit here. So in general the CableTerminationType just needs the Cable-Annotation to the CableType. I checked this and could provide a Pull-Request for this:

https://github.com/netbox-community/netbox/compare/develop...dxks:netbox:18124-graphql-query-cable-inside-cabletermination-set

@dxks commented on GitHub (Dec 4, 2024): I had a look into this and see that other CabledModels uses a Mixin but this will not fit here. So in general the CableTerminationType just needs the Cable-Annotation to the CableType. I checked this and could provide a Pull-Request for this: https://github.com/netbox-community/netbox/compare/develop...dxks:netbox:18124-graphql-query-cable-inside-cabletermination-set
Author
Owner

@arthanson commented on GitHub (Dec 5, 2024):

@dxks I've assigned this issue to you said you could create a PR for this.

@arthanson commented on GitHub (Dec 5, 2024): @dxks I've assigned this issue to you said you could create a PR for this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10526