Преглед изворни кода

feat(dcim): Add filter for cabled objects in GraphQL

Introduces a `cabled` filter to the GraphQL API for DCIM. Allows
filtering objects based on whether they are connected to a cable,
improving query customization.

Fixes #20172
Martin Hauser пре 3 недеља
родитељ
комит
1745d2ae93
1 измењених фајлова са 4 додато и 0 уклоњено
  1. 4 0
      netbox/dcim/graphql/filters.py

+ 4 - 0
netbox/dcim/graphql/filters.py

@@ -550,6 +550,10 @@ class InterfaceFilter(
         strawberry_django.filter_field()
     )
 
+    @strawberry_django.filter_field
+    def cabled(self, value: bool, prefix: str):
+        return Q(**{f'{prefix}cable__isnull': (not value)})
+
     @strawberry_django.filter_field
     def connected(self, queryset, value: bool, prefix: str):
         if value is True: