Skip to content

Conversation

@llamafilm
Copy link
Contributor

@llamafilm llamafilm commented Sep 6, 2025

Fixes: #20253

Define a custom filter method for contacts using the @strawberry_django.filter_field decorator.

@jnovinger jnovinger requested review from a team and jeremystretch and removed request for a team September 8, 2025 03:41
@llamafilm
Copy link
Contributor Author

I found a simpler / better solution — the contacts field should actually be a ContactAssignmentFilter. This way I can write more complex queries like this:

{
  site_list(
    filters: {
      contacts: {
        contact:{name:{contains:"Dwight"}}
        role:{name:{exact:"Operational"}}
        priority:PRIORITY_PRIMARY
      }
    }) {
    name
  }
}

@jeremystretch
Copy link
Member

I think this is actually a bug, as it doesn't seem possible to filter by contacts at all using the current implementation of ContactFilterMixin. I suspect the mixin was intended to use ContactAssignmentFilter originally.

Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @llamafilm!

@jeremystretch jeremystretch merged commit 55cda3c into netbox-community:main Sep 19, 2025
7 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GraphQL filter location list by contacts

2 participants