Strawberry Graphql does not allow extension by plugins #10674

Closed
opened 2025-12-29 21:34:35 +01:00 by adam · 3 comments
Owner

Originally created by @129828 on GitHub (Jan 20, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.0.9

Python Version

3.10

Steps to Reproduce

In versions before V4 it was possible to extend the graphql api using plugins:
For example a plugin that added EVPN data was able to be queried from the vlan:

{
  vlan_list{
    vid
    evpnvcvlan{
      evpn_vc {
      	vni
      }
    }
  }
}

This was done in the plugin itself and allowed to easily create links back and forth.

For example from a publicly available plugin, the netbox-bgp previously had this behaviour where it was possible to use graphql to query nested data.:

{
 device_list{
    bgpsession_set{
    	name
    }
  }
}

But in V4

{
 device_list{
    bgpsession_set{} <-- Yields an error
  }
}

And looking through the documentation of the strawberry api, I cannot seem to find a way to reenable this functionality.
The only option would be to first get all devices and then all bgpsession which have the device assigned, but the whole point of graphql is to only do a single request.

previous issue about this #17242

Expected Behavior

In version 4 it should still be possible to query the graphql api by using nested data from plugins, as right now it's only possible to do this using the netbox provided models.

Observed Behavior

It is not possible to use graphql to query nested plugin data

Originally created by @129828 on GitHub (Jan 20, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.0.9 ### Python Version 3.10 ### Steps to Reproduce In versions before V4 it was possible to extend the graphql api using plugins: For example a plugin that added EVPN data was able to be queried from the vlan: ``` { vlan_list{ vid evpnvcvlan{ evpn_vc { vni } } } } ``` This was done in the plugin itself and allowed to easily create links back and forth. For example from a publicly available plugin, the netbox-bgp previously had this behaviour where it was possible to use graphql to query nested data.: ``` { device_list{ bgpsession_set{ name } } } ``` But in V4 ``` { device_list{ bgpsession_set{} <-- Yields an error } } ``` And looking through the documentation of the strawberry api, I cannot seem to find a way to reenable this functionality. The only option would be to first get all devices and then all bgpsession which have the device assigned, but the whole point of graphql is to only do a single request. previous issue about this #17242 ### Expected Behavior In version 4 it should still be possible to query the graphql api by using nested data from plugins, as right now it's only possible to do this using the netbox provided models. ### Observed Behavior It is not possible to use graphql to query nested plugin data
adam added the type: bugtopic: GraphQL labels 2025-12-29 21:34:35 +01:00
adam closed this issue 2025-12-29 21:34:35 +01:00
Author
Owner

@jeremypng commented on GitHub (Jan 23, 2025):

With the proposed GraphQL redesign here #18431, a decorator could be used to load plugin reverse relationships defined in the plugin and add them to the statically defined type attributes and filter attributes. We need a strongly typed schema/pattern in the plugin for this though and not let it end up in the same place the autotype_decorator ended up in inference confusion.

@jeremypng commented on GitHub (Jan 23, 2025): With the proposed GraphQL redesign here #18431, a decorator could be used to load plugin reverse relationships defined in the plugin and add them to the statically defined type attributes and filter attributes. We need a strongly typed schema/pattern in the plugin for this though and not let it end up in the same place the autotype_decorator ended up in inference confusion.
Author
Owner

@peteeckel commented on GitHub (Apr 11, 2025):

@jeremypng can you elaborate a bit on how such a decorator should work? I'm not deep enough into Strawberry to figure out myself - a hint in the right direction would be great!

@peteeckel commented on GitHub (Apr 11, 2025): @jeremypng can you elaborate a bit on how such a decorator should work? I'm not deep enough into Strawberry to figure out myself - a hint in the right direction would be great!
Author
Owner

@jeremystretch commented on GitHub (Apr 22, 2025):

I'm afraid this is an inherent limitation resulting from our move to Strawberry under #9856. As @jeremypng mentions above, we're adapting the way GraphQL filters are constructed in NetBox v4.3, which may open an opportunity for improved plugin integration. I invite anyone interested in this functionality to experiment and submit a feature request detailing their proposed solution.

@jeremystretch commented on GitHub (Apr 22, 2025): I'm afraid this is an inherent limitation resulting from our move to Strawberry under #9856. As @jeremypng mentions above, we're adapting the way GraphQL filters are constructed in NetBox v4.3, which may open an opportunity for improved plugin integration. I invite anyone interested in this functionality to experiment and submit a feature request detailing their proposed solution.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10674