Update GraphQL to allow query of prefix by location, site, site-group and region #11943

Open
opened 2025-12-29 21:51:45 +01:00 by adam · 1 comment
Owner

Originally created by @matthew-242 on GitHub (Dec 19, 2025).

NetBox version

v4.4.2

Feature type

New functionality

Proposed functionality

Extend GraphQL query logic for prefixes to mirror the ability in "circuit terminations" to filter on Location, Site, Site-Group and Region.

My testing suggests it is as simple as updating the imports to include the relevant filters:

from dcim.graphql.filters import LocationFilter, RegionFilter, SiteFilter, SiteGroupFilter

And then adding the following:

    _location: Annotated['LocationFilter', strawberry.lazy('dcim.graphql.filters')] | None = (
        strawberry_django.filter_field(name='location')
    )
    _region: Annotated['RegionFilter', strawberry.lazy('dcim.graphql.filters')] | None = (
        strawberry_django.filter_field(name='region')
    )
    _site_group: Annotated['SiteGroupFilter', strawberry.lazy('dcim.graphql.filters')] | None = (
        strawberry_django.filter_field(name='site_group')
    )
    _site: Annotated['SiteFilter', strawberry.lazy('dcim.graphql.filters')] | None = (
        strawberry_django.filter_field(name='site')
    )

Use case

Allows the query of prefixes by location, site, site-group or region.

Database changes

No response

External dependencies

No response

Originally created by @matthew-242 on GitHub (Dec 19, 2025). ### NetBox version v4.4.2 ### Feature type New functionality ### Proposed functionality Extend GraphQL query logic for prefixes to mirror the ability in "circuit terminations" to filter on Location, Site, Site-Group and Region. My testing suggests it is as simple as updating the imports to include the relevant filters: ` from dcim.graphql.filters import LocationFilter, RegionFilter, SiteFilter, SiteGroupFilter ` And then adding the following: ``` _location: Annotated['LocationFilter', strawberry.lazy('dcim.graphql.filters')] | None = ( strawberry_django.filter_field(name='location') ) _region: Annotated['RegionFilter', strawberry.lazy('dcim.graphql.filters')] | None = ( strawberry_django.filter_field(name='region') ) _site_group: Annotated['SiteGroupFilter', strawberry.lazy('dcim.graphql.filters')] | None = ( strawberry_django.filter_field(name='site_group') ) _site: Annotated['SiteFilter', strawberry.lazy('dcim.graphql.filters')] | None = ( strawberry_django.filter_field(name='site') ) ``` ### Use case Allows the query of prefixes by location, site, site-group or region. ### Database changes _No response_ ### External dependencies _No response_
adam added the type: featurenetboxstatus: needs triage labels 2025-12-29 21:51:45 +01:00
Author
Owner

@matthew-242 commented on GitHub (Dec 19, 2025):

If this is accepted (and I haven't missed anything), I am happy to create the Pull Request for this.

@matthew-242 commented on GitHub (Dec 19, 2025): If this is accepted (and I haven't missed anything), I am happy to create the Pull Request for this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11943