Skip to content

Add "in_list" operator to GraphQL API filters for IDs and Enums #19338

@tyler-8

Description

@tyler-8

NetBox version

v4.3.0

Feature type

Change to existing functionality

Proposed functionality

Introduce support for the in_list operator across all GraphQL filters for ID and Enum fields (like status or interface types) in NetBox's v4.3.0, aligning with most other filter options for other fields in the NetBox GraphQL API.

This operator allows filtering objects by specifying multiple values simultaneously using a concise syntax:

query {
  circuit_list {
    terminations(filter: { site: { id: { in_list: [1, 2] } } }) {
      id
      site { name }
    }
  }
}

Use case

This feature significantly simplifies and optimizes common automation tasks and data integrations. Examples include:

Batch Object Retrieval

Quickly query multiple objects by IDs or statuses within one GraphQL request. While GraphQL does offer other logical operators like OR, they don't cleanly fit every use case where filtering by multiple values is needed.

query {
  device_list(filter: { status: { in_list: [ACTIVE, PLANNED, STAGED] } }) {
    id
    name
    status
  }
}

Dashboard Filtering

Simplify dashboards displaying entities filtered by various criteria, making queries cleaner and easier to maintain.

The REST API currently supports similar functionality, and the v4.3.0 GraphQL API also provides similar capability on most endpoints/field filters. Adding in_list to the current GraphQL filtering mechanism for IDs and Enums continues this existing theme, eliminating the need for chaining multiple "OR" filters - which are difficult to produce dynamically without awkward/cumbersome string manipulation.

The ability to combine in_list, OR filters, and pagination would provide maximum API flexibility; serving diverse use cases.

Database changes

N/A

External dependencies

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: under reviewFurther discussion is needed to determine this issue's scope and/or implementationtopic: GraphQLtype: featureIntroduction of new functionality to the application

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions