-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Replace graphene-django with Strawberry #9856
Comments
Given the recent release of graphene-django 3.0, we've decided to put on hold the exploration of alternative GraphQL API implementations and proceed with upgrading. (#10472 has been opened to track this work.) I'm going to close this issue with the assumption that moving to graphene-django 3.0 is tenable. If we discover otherwise, this will need to be reopened. |
Reopening issue - Graphene Django is still pretty much dead. strawberry-django meanwhile has quite a bit of activity, they have also released https://github.com/blb-ventures/strawberry-django-plus which makes it potentially more viable. |
Investigating this, one issue is that the filtering syntax is different between the two libraries. Graphene
Strawberry
The filtering lookup syntax (greater than, less than, case-insensitive compare) is also different:
Strawberry
For stawberry, allowing lookups on fields forces the lookup to be present, so it forces this somewhat awkward syntax:
Strawberry
|
I think it's a reality of switch and frankly it's not that crazy. |
After further research some issues came up with strawberry. Here are some pros, cons and more detailed explanation for discussion: Note: If you do actively use GraphQL then please take a look at this and make comments as it will effect your code... Pros (of using strawberry):
Cons:
The major downside of strawberry is they don't support django-filters. They used to, but ripped it out without almost any warning on a prior release when they refactored to use data-classes. This has a couple side-effects:
More detail / examples
So the top part with the comment #NetBoxModelFilterSet would need to be on each filter definition. Type definitions (CircuitType) do support field definition inheritance so the duplication of field definitions is only needed on the filters. Note: The inheriting from the filtersets is a bit of a hack to support calling of the custom filter functions (see below).
strawberry:
There is no not operators (cid_n) as not is a graphql operator so you could query with {not {cid: ... which should get the same result. |
strawberry-graphql-django - Issue for adding support for django_filters: strawberry-graphql/strawberry-django#448 |
Very happy to announce this has been completed for the upcoming v4.0 release! Thank you @arthanson! |
NetBox version
v3.2.7
Feature type
Change to existing functionality
Proposed functionality
Replace NetBox's existing GraphQL implementation, which was built using graphene-django, with Strawberry. graphene-django unfortunately is no longer being maintained, and is no longer compatible with Django 4.0 and later releases (something which we currently work around via a monkey patch).
Use case
The goal here will be to keep the new GraphQL API as backward-compatible as possible, and to leverage any new features of Strawberry where they might be beneficial. Further research is needed to determine the migration strategy.
Database changes
No changes to the database schema are anticipated
External dependencies
Replace graphene-django with strawberry
The text was updated successfully, but these errors were encountered: