netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
16.39k stars 2.6k forks source link

GraphQL: querying ip_address_list with filtering on a parent will not work even if the scheme describes this as StrFilterLookup #18126

Open dxks opened 3 days ago

dxks commented 3 days ago

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

v4.1.7

Python Version

3.11

Steps to Reproduce

Using a simple IP-Adress-List to get multiple ip-addresses for multiple prefixes:

query {
    ip_address_list (filters: {parent: {in_list: ["10.1.10.0/27", "10.100.10.0/27"]}}) {
        id
        address
    }
}

causing the error:

{
  "data": null,
  "errors": [
    {
      "message": "Cannot resolve keyword 'parent' into field. Choices are: address, assigned_object, assigned_object_id, assigned_object_type, assigned_object_type_id, bookmarks, comments, contacts, created, custom_field_data, description, dns_name, fhrpgroup, id, interface, journal_entries, last_updated, local_address, nat_inside, nat_inside_id, nat_outside, remote_address, role, services, status, subscriptions, tagged_items, tags, tenant, tenant_id, termination_a_ip, termination_z_ip, tunnel_terminations, vminterface, vrf, vrf_id",
      "locations": [
        {
          "line": 2,
          "column": 5
        }
      ],
      "path": [
        "ip_address_list"
      ]
    }
  ]
}

Expected Behavior

Querying the IP-Addresses for multiple Prefixes results in a list of all IPs. Unfortunately this is also not supported querying all Prefixes and retrieve the specific ip addresses in a prefix.

Observed Behavior

An error was raised showing that using parent in filters is not supported.

pl0xym0r commented 1 day ago

same issue as #17681 : use of parent as filter for IpRange and IpAddress

Even, using the doc for autotype_decorator :

For other filter fields a function needs to be created for Strawberry with the naming convention filter_{fieldname} which is auto detected and called by Strawberry, this function uses the filterset to handle the query.

modify search_by_parent by filter_parent didn't help.