netbox icon indicating copy to clipboard operation
netbox copied to clipboard

GraphQL filter for "ip_address_list" - Filter query tag works not as accepted

Open SchmidtJonathan1 opened this issue 1 year ago • 1 comments

Deployment Type

Self-hosted

NetBox Version

v4.0.3

Python Version

3.12

Steps to Reproduce

When a query is created in Graphql Explorer that accesses the class "ip_address_list". Cannot be filtered by "tags" as there is only one parameter called "tag".

#Graphql query:

query MyQuery {
  ip_address_list(filters: {tag: "Gateway"}) {
    tags{
      name
    }
  }
}

Expected Behavior

{
  "data": {
    "ip_address_list": [
      {
        "id": "15",
        "tags": [
          {
            "name": "Gateway"
          }
        ]
      }
}

Observed Behavior

{
  "data": {
    "ip_address_list": [
      {
        "id": "2",
        "tags": []
      },
      {
        "id": "3",
        "tags": []
      },
      {
        "id": "4",
        "tags": []
      },
      {
        "id": "15",
        "tags": [
          {
            "name": "Gateway"
          }
        ]
      }
}

SchmidtJonathan1 avatar May 27 '24 13:05 SchmidtJonathan1

Hi, I would like to tackle this issue (CC @jeffgdotorg)

fooker avatar Jul 01 '24 12:07 fooker

@fooker any updates on this? Are you still able to work on this?

arthanson avatar Aug 13 '24 06:08 arthanson

Fixed in my branch here: https://github.com/jeremypng/netbox/tree/refs/heads/graphql-filter-redesign

fixed query:

query IPTags {
  ip_address_list(filters: {tags: {name: {exact: "Bravo"}}}) {
    id
    address
  }
}

results:

{
  "data": {
    "ip_address_list": [
      {
        "id": "34",
        "address": "172.16.0.4/24"
      }
    ]
  }
}

If you'll assign this to me I'll tag it in my PR

jeremypng avatar Jan 22 '25 23:01 jeremypng

Blocked by #7598

jeremystretch avatar Feb 07 '25 20:02 jeremystretch

I believe this has been resolved by the work on #7598. For example, the following query will match all sites with to which the tag named "Alpha" has been assigned:

query {
  site_list(filters: {tags: {name: {exact: "Alpha"}}}) {
    id
    name
  }
}

This change will be implemented in NetBox v4.3.

jeremystretch avatar Mar 10 '25 19:03 jeremystretch