Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL DjangoModelType only has pk attribute #17710

Closed
SRF-oberlicy opened this issue Oct 9, 2024 · 2 comments · Fixed by #17767
Closed

GraphQL DjangoModelType only has pk attribute #17710

SRF-oberlicy opened this issue Oct 9, 2024 · 2 comments · Fixed by #17767
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation topic: GraphQL type: bug A confirmed report of unexpected behavior in the application

Comments

@SRF-oberlicy
Copy link

SRF-oberlicy commented Oct 9, 2024

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.

@SRF-oberlicy SRF-oberlicy added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Oct 9, 2024
@arthanson arthanson added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation topic: GraphQL severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation and removed status: needs triage This issue is awaiting triage by a maintainer status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Oct 9, 2024
@arthanson arthanson self-assigned this Oct 15, 2024
@arthanson
Copy link
Collaborator

@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
              }

            }
          }
        }
      }
    }
  }
}

@SRF-oberlicy
Copy link
Author

@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
                }
              }
            }
          }
        }
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation topic: GraphQL type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants