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.35k stars 2.6k forks source link

wip: Filter by custom fields in graph ql #18012

Open christophbeberweil opened 1 week ago

christophbeberweil commented 1 week ago

Works on : #7598

I worked on issue #7598 and made progress. Unfortunaltely, I hit some roadblocks and none of the maintainers were available to answer my questions. I open this merge request with my partial solution so that it might be of use for the project in the future.

I utilized autotype_decorator, which is used to communicate the filterset to graphql, in order to add CustomField entries with the same logic applied as in netbox.filtersets.NetBoxModelFilterSet. The code calls create_attribute_and_function for each custom field of the current model. This successfully adds a new filter to GraphQL, which is recognized in the backend. Unfortunately, there are still some problems: