Ability to query for cabled interfaces via GraphQL #11527

Open
opened 2025-12-29 21:46:24 +01:00 by adam · 6 comments
Owner

Originally created by @mraerino on GitHub (Aug 25, 2025).

NetBox version

v4.3.6

Feature type

Change to existing functionality

Proposed functionality

Prior versions of Netbox used to have a cabled filter property for interfaces in GraphQL that allowed to get only interfaces that have a cable.

I'd like to have this filter property in the current GraphQL datamodel. It would be of type Boolean.

There are no current fields in the GraphQL interface filter that allow this, since the cable filter field can't be queried on its "existence"

Use case

This is useful in situations where GraphQL queries want information about cable peers of an interface. This filter would allow reducing the returned data by only showing interfaces that actually have cables.

This would most likely also improve performance.

Database changes

None

External dependencies

None

Originally created by @mraerino on GitHub (Aug 25, 2025). ### NetBox version v4.3.6 ### Feature type Change to existing functionality ### Proposed functionality Prior versions of Netbox used to have a `cabled` filter property for interfaces in GraphQL that allowed to get only interfaces that have a cable. I'd like to have this filter property in the current GraphQL datamodel. It would be of type `Boolean`. There are no current fields in the GraphQL interface filter that allow this, since the `cable` filter field can't be queried on its "existence" ### Use case This is useful in situations where GraphQL queries want information about cable peers of an interface. This filter would allow reducing the returned data by only showing interfaces that actually have cables. This would most likely also improve performance. ### Database changes None ### External dependencies None
Author
Owner

@mraerino commented on GitHub (Aug 25, 2025):

I'm willing to implement this in a PR

@mraerino commented on GitHub (Aug 25, 2025): I'm willing to implement this in a PR
Author
Owner

@sleepinggenius2 commented on GitHub (Aug 25, 2025):

I ran across this same issue recently and found that I could use cable: {status: STATUS_CONNECTED} in my filter and it worked as expected. That assumes you are looking for just connected cables, which was what I actually wanted in my case. You should also be able to get what you're looking for using cable: {id: {is_null: false}}, but I agree a shorthand would be simpler.

@sleepinggenius2 commented on GitHub (Aug 25, 2025): I ran across this same issue recently and found that I could use `cable: {status: STATUS_CONNECTED}` in my filter and it worked as expected. That assumes you are looking for just connected cables, which was what I actually wanted in my case. You should also be able to get what you're looking for using `cable: {id: {is_null: false}}`, but I agree a shorthand would be simpler.
Author
Owner

@mraerino commented on GitHub (Aug 26, 2025):

what you're looking for using cable: {id: {is_null: false}},

sadly this doesn't work, same reason why https://github.com/netbox-community/netbox/issues/19811 is unsolved. you can only pass a specific ID, but not query for null.

The workaround that works is cable: { created: { is_null: false } } but that's hard to figure out

@mraerino commented on GitHub (Aug 26, 2025): > what you're looking for using `cable: {id: {is_null: false}}`, sadly this doesn't work, same reason why https://github.com/netbox-community/netbox/issues/19811 is unsolved. you can only pass a specific ID, but not query for null. The workaround that works is `cable: { created: { is_null: false } }` but that's hard to figure out
Author
Owner

@sleepinggenius2 commented on GitHub (Aug 26, 2025):

what you're looking for using cable: {id: {is_null: false}},

sadly this doesn't work, same reason why #19811 is unsolved. you can only pass a specific ID, but not query for null.

The workaround that works is cable: { created: { is_null: false } } but that's hard to figure out

My bad, I did test it in our environment before commenting, but I forgot I had already applied the fix for that bug there and it's not something that works out of the box at the moment.

@sleepinggenius2 commented on GitHub (Aug 26, 2025): > > what you're looking for using `cable: {id: {is_null: false}}`, > > sadly this doesn't work, same reason why [#19811](https://github.com/netbox-community/netbox/issues/19811) is unsolved. you can only pass a specific ID, but not query for null. > > The workaround that works is `cable: { created: { is_null: false } }` but that's hard to figure out My bad, I did test it in our environment before commenting, but I forgot I had already applied the fix for that bug there and it's not something that works out of the box at the moment.
Author
Owner

@jeremystretch commented on GitHub (Aug 28, 2025):

Thanks @mraerino, all yours!

@jeremystretch commented on GitHub (Aug 28, 2025): Thanks @mraerino, all yours!
Author
Owner

@jeremystretch commented on GitHub (Nov 6, 2025):

@mraerino are you still working on this?

@jeremystretch commented on GitHub (Nov 6, 2025): @mraerino are you still working on this?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11527