Closes #21477: Add GraphQL Cable Termination filters for Device, Rack, Location, and Site #293

Closed
opened 2026-04-05 16:24:57 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @pheus on 2/20/2026

Fixes: #21477

This PR adds GraphQL filters for cables based on their terminations’ cached relations (Device, Rack, Location, and Site), bringing GraphQL filtering functionality to parity with the REST API and enabling more effective cable queries by termination attributes.

Example (NetBox demo data)

Filter cables by termination device ID 27 (with deduplication enabled):

query MyQuery {
  cable_list(
    filters: {terminations: {device: {id: {exact: "27"}}, DISTINCT: true}}
  ) {
    id
    display
  }
}

Changes

  • Expose cached termination relations (device, rack, location, site) for GraphQL filtering via terminations.
  • Support efficient lookups by leveraging cached relations on CableTermination.

Testing

  • Added a test in dcim/tests/test_api.py covering filtering by termination device/rack/location/site (including the case where both ends match and DISTINCT prevents duplicates).
*Originally created by @pheus on 2/20/2026* ### Fixes: #21477 This PR adds GraphQL filters for cables based on their terminations’ cached relations (Device, Rack, Location, and Site), bringing GraphQL filtering functionality to parity with the REST API and enabling more effective cable queries by termination attributes. #### Example (NetBox demo data) Filter cables by termination device ID `27` (with deduplication enabled): ```graphql query MyQuery { cable_list( filters: {terminations: {device: {id: {exact: "27"}}, DISTINCT: true}} ) { id display } } ``` #### Changes - Expose cached termination relations (`device`, `rack`, `location`, `site`) for GraphQL filtering via `terminations`. - Support efficient lookups by leveraging cached relations on `CableTermination`. #### Testing - Added a test in `dcim/tests/test_api.py` covering filtering by termination device/rack/location/site (including the case where both ends match and `DISTINCT` prevents duplicates).
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#293