graphene-sqlalchemy-filter
graphene-sqlalchemy-filter copied to clipboard
Provide basic support for graphene/graphene-sqlalchemy>=3.0
- Update references to
ResolveInfo
toGraphQLResolveInfo
- Add handling for beta tags in Graphene version
I'm getting 'GraphQLResolveInfo' object has no attribute 'field_asts' connection_field.py using this on a simple query with a filter. Using field_nodes
instead of field_asts does the trick for me:
https://github.com/art1415926535/graphene-sqlalchemy-filter/blob/3d00712619d65678ec71056ce655f6d5c5ddf97e/graphene_sqlalchemy_filter/connection_field.py#L105
It seems they have renamed this property in GQL Python 3 See here: https://github.com/graphql-python/graphql-core/blob/8e72bfc8a8a9368d665e4c3b881ddb0ad8a9ebdf/src/graphql/type/definition.py#L541
Updated the field_asts
references to field_nodes
, thanks for the catch @erikwrede.
Also added a less hacky way of building the gqls_version
tuple when dealing with versions with beta tags i,e, 3.0.0b1
. The remaining GraphQLResolveInfo
references have been updated in the tests as well.
Seems to be working for me, thanks!
Furthermore, I have observed that with Graphene 3, Variable types for filter Variables seem to be parsed more strictly. Currently, to prevent having to implement custom filters for many-to-one relationships, I filter using the Integer SQLAlchemy foreign keys. I'm not using the foreign keys anywhere else in the model.
Example:
query$parentUid: Int) {
child(filters: {parentUid: $parentUid})
}
Using graphene2, i could easily pass the desired ID of the parent as a string (which was convenient, because db primary keys are automatically converted to ID by graphene, which is a string). With graphene 3, this hack does not work anymore and I need to parse the string first, otherwise the query will fail. Maybe someone else has got this use case as well, so it might be helpful to note some "breaking" changes somewhere?
Maybe it should also be noted, that graphene-sqlalchemy 3 itself implemented a solution for N+1 batching, so maybe the reference to the SQLalchemy package is no longer necessary?
Other than that, everything seems to be working as usual.
@art1415926535 any chance we could get a beta release on that for further testing?
graphene has officially upgraded to v3, waiting for this to be merged.
@art1415926535 any chance of getting this merged? Thanks for an excellent lib and the work that's gone into this.
Hi team. Just want to know when this could be merged? The work here has been fantastic, and I was looking to use this.
Graphene v3 officially supports SQLAlchemy v1.4 which has more intuitive syntax for database selects, deletes, and updates that are compatible with the upcoming SQLAlchemy
v2 release. It also supports async IO for dataloaders, which I hope will improve performance. This is the last package in the python SQLAlchemy
, Flask
, GraphQL
stack that we use that is dependent on the older graphene
version.
The file changes in the PR seem straightforward. Is there a reason, such as an unforseen dependency, that is causing the delay? Of course these are COVID times too, so I'm hoping for the best.
As others have stated, this has been a valuable addition. It was the final piece of the puzzle in our switch to using GraphQL
.
After looking at the code for the FilterableConnectionField Class, I see that dataloaders are supported by default, after some troubleshooting of the graphene documentation. Hooray. Is this applied to all fields, including those that are not filtered? I'm not that versed in some of the concepts in the file, hence the question.
When this PR would be merged? Please comment
@cooldudemcgeexl I've tried to contact art1415926535
about merging this with no response. What's the best way to implement this external to the current graphene-sqlalchemy-filter
python package? Should I just download the code from this PR and add it as a separate library for my application?
I've opened an issue with the graphene-sqlalchemy
repo to see whether they would be interested in taking over this code as it is so useful.
- https://github.com/graphql-python/graphene-sqlalchemy/issues/335
@palisadoes the graphene sqlalchemy repo is also almost unmaintained... an important fix pull request has been stuck waiting for approval for months now. As long as you're waiting, just add this to your requirements.txt instead of the current library dependency:
git+https://github.com/cooldudemcgeexl/graphene-sqlalchemy-filter.git
it will work as long as @cooldudemcgeexl does not modify the repo, which I hope he doesn't since its a great quick fix!
Thanks. I'll do that as a stop gap.
If neither graphene-sqlalchemy-filter
nor graphene-sqlalchemy
is being maintained. Should we all migrate to Django or something else? I don't want to be trapped using unmaintained code.
I used @cooldudemcgeexl fix and everything seems to be working fine. The feature this library provides is mandatory but its sad to see this going unmaintained.
@palisadoes For me personally, it's too late to move my projects over to Django, since they're too far in terms of development.
One of the main developers of the graphql python core laid the issue out very well over here: https://github.com/graphql-python/graphene-sqlalchemy/issues/326#issuecomment-1001021478
Sadly, I don't think I have enough experience with graphene or sqlalchemy to start maintaining such a complex library ecosystem, but me and many others would like to help out and have some guidance by someone more experienced with SQLAlchemy.
@erikwrede I'm willing to partially sponsor integration of this feature into graphene-sqlalchemy
. Would any of the others on this thread be willing to approach their employers, or do so personally?
- https://github.com/graphql-python/graphene-sqlalchemy/issues/326#issuecomment-1082352313
@cooldudemcgeexl Would you be interested in doing some sponsored work to integrate graphene-sqlalchemy-filter
into graphene-sqlalchemy
?
@palisadoes I'd also partially sponsor getting this integrated
@palisadoes How much of sponsor required for this? I would do partial sponsor as well.
Thanks @dave-brennan and @riyasdeens
@sabard and @PaulSchweizer are working on a requirements Google Doc to help determine the expected time and cost. Join us on the #graphene-sqlalchemy-filter
channel on the Graphene Slack organization. The link can be found here https://github.com/graphql-python/graphene
Let us know on the channel whether you'd like to participate in the doc and your comments on the pricing, etc. as the appropriate times approach.
What's the status? :slightly_smiling_face:
@Redysz planning is done. Implementation is in progress, please check the recent PRs in graphene-sqlalchemy.
What's the status? slightly_smiling_face
Please take a look here, for example:
- https://github.com/graphql-python/graphene-sqlalchemy/pull/356