-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closes #20679 - Duplicate all GraphQL hierarchy objects to separate V1 and V2 namespaces #20667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature
Are you sure you want to change the base?
Conversation
|
I've added a basic test to sanity-check the v1/v2 types. It's currently failing on the dummy plugin, which raises the question: How should we handle plugins? |
|
After some experimentation here's what I think would be a reasonable way to handle plugins, though feedback is welcome. We populate the schema by automatically pulling in plugin types from the registry: This last line doesn't distinguish between V1 and V2 types, but it could. I'm thinking we could just presume that any Query object found in the registry with the This means existing plugins, without doing anything, would have their schemas behave in the V2 way (pagination, To alleviate that, another way to do this (though less consistent) would be to treat plugins in the opposite sense of core NetBox as regards the suffixes, in other words: This would allow existing plugins to retain their current behavior and they could opt-in to the V2 behavior by creating However, the downside of this approach (aside from the inconsistency) is that it would generate no pressure to deprecate the old style, and when V1 disappears the unchanged plugins would then "become" V2 schemas with the same disruption as we would have now. But at least it gives plugin authors enough runway to prepare one way or the other. And another downside is that once we deprecate V1, the plugin GraphQL schemas would have a lot of messy Is all the rigmarole of this second approach worthwhile weighed against the disruption of existing plugins silently switching to the V2 behavior as in the first approach? Comments welcome. |
|
Thanks for pushing the V1/V2 namespacing work and for asking about plugin handling - much appreciated. Small note: Since this PR was opened, there have been several GraphQL changes on From the plugin side, I ported two plugins from NetBox v4.2 GraphQL to v4.3, which was fairly disruptive. I think it helps to separate two concerns:
To keep V2 clean, I’d suggest exposing non‑ported plugin schemas only under V1. Once a plugin is updated, it can add a proper V2 schema. That way, installing a not‑yet‑ported plugin doesn’t create a mixed V1/V2 API surface within V2. Based on the open PRs around GraphQL V2, it looks like plugin authors will need to adopt at least the following:
For discovery, keeping an explicit Happy to help test with my plugins if that’s useful. If I’ve misunderstood anything above, please correct me - and thanks again for driving this forward! |
Closes: #20679
This has been tested such that the V1 and V2 configurations work as expected as per the
GRAPHQL_DEFAULT_VERSIONsetting. A thorough review would be to look at all the field type definitions and ensure that I didn't miss anyV1suffixes or_v1module paths in thestrawberry.lazystatements.Note that enums and lookups are not namespaced, though types and filter types are.