From 9381564cab54836d4ba6dc5cff5ef964b1915ede Mon Sep 17 00:00:00 2001 From: rinna11 Date: Mon, 27 Oct 2025 23:02:28 +0900 Subject: [PATCH] Fixes #20422: Allow Aggregate and Prefix to filter by family in GraphQL (#20626) Co-authored-by: Rinna Izumi Co-authored-by: Jason Novinger --- netbox/ipam/graphql/filters.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/netbox/ipam/graphql/filters.py b/netbox/ipam/graphql/filters.py index b8326cc43..c0a01d72b 100644 --- a/netbox/ipam/graphql/filters.py +++ b/netbox/ipam/graphql/filters.py @@ -101,6 +101,14 @@ class AggregateFilter(ContactFilterMixin, TenancyFilterMixin, PrimaryModelFilter q |= Q(**{f"{prefix}prefix__net_contains": query}) return q + @strawberry_django.filter_field() + def family( + self, + value: Annotated['IPAddressFamilyEnum', strawberry.lazy('ipam.graphql.enums')], + prefix, + ) -> Q: + return Q(**{f"{prefix}prefix__family": value.value}) + @strawberry_django.filter_type(models.FHRPGroup, lookups=True) class FHRPGroupFilter(PrimaryModelFilterMixin): @@ -292,6 +300,14 @@ class PrefixFilter(ContactFilterMixin, ScopedFilterMixin, TenancyFilterMixin, Pr q |= Q(**{f"{prefix}prefix__net_contains": query}) return q + @strawberry_django.filter_field() + def family( + self, + value: Annotated['IPAddressFamilyEnum', strawberry.lazy('ipam.graphql.enums')], + prefix, + ) -> Q: + return Q(**{f"{prefix}prefix__family": value.value}) + @strawberry_django.filter_type(models.RIR, lookups=True) class RIRFilter(OrganizationalModelFilterMixin):