From 09b46864403f711b25facaf0ae4b80f3fd36ac28 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 9 Oct 2024 14:24:24 -0400 Subject: [PATCH] Update GraphQL type for Prefix model --- netbox/ipam/graphql/types.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/netbox/ipam/graphql/types.py b/netbox/ipam/graphql/types.py index 46d45816e..9fe1fe466 100644 --- a/netbox/ipam/graphql/types.py +++ b/netbox/ipam/graphql/types.py @@ -152,17 +152,25 @@ class IPRangeType(NetBoxObjectType): @strawberry_django.type( models.Prefix, - fields='__all__', + exclude=('scope_type', 'scope_id', '_location', '_region', '_site', '_sitegroup'), filters=PrefixFilter ) class PrefixType(NetBoxObjectType, BaseIPAddressFamilyType): prefix: str - site: Annotated["SiteType", strawberry.lazy('dcim.graphql.types')] | None vrf: Annotated["VRFType", strawberry.lazy('ipam.graphql.types')] | None tenant: Annotated["TenantType", strawberry.lazy('tenancy.graphql.types')] | None vlan: Annotated["VLANType", strawberry.lazy('ipam.graphql.types')] | None role: Annotated["RoleType", strawberry.lazy('ipam.graphql.types')] | None + @strawberry_django.field + def scope(self) -> Annotated[Union[ + Annotated["LocationType", strawberry.lazy('dcim.graphql.types')], + Annotated["RegionType", strawberry.lazy('dcim.graphql.types')], + Annotated["SiteGroupType", strawberry.lazy('dcim.graphql.types')], + Annotated["SiteType", strawberry.lazy('dcim.graphql.types')], + ], strawberry.union("PrefixScopeType")] | None: + return self.scope + @strawberry_django.type( models.RIR,