joaovitorsilvestre / graphene-mongodb

Implementation of Graphene and Mongoengine
MIT License
14 stars 4 forks source link

Update to the latest version of Graphene #35

Closed stratosgear closed 6 years ago

stratosgear commented 6 years ago

Hi @joaovitorsilvestre ,

First let me start off by saying this is an excellent library tying mongoengine and graphene together. I'm surprised it does not have more stars here in Github.

I forked your repo and tried to bring everything online with the latest versions of the required packages, but the level of abstractions were too much for me to handle.

Graphene has introduced some breaking changes that are well documented, but still I could not make the required code changes.

Are you still involved with the library at all...? It might be a little easier for you to upgrade your code. I hope!

Here are the requirements.txt:

aniso8601==3.0.0
appdirs==1.4.3
graphene==2.1
graphql-core==2.0
graphql-relay==0.4.5
iso8601==0.1.12
mongoengine==0.15.0
promise==2.1
pymongo==3.6.1
pyparsing==2.2.0
rx==1.6.1
six==1.11.0
typing==3.6.4

and requirements-dev.txt:

attrs==17.4.0
click==6.7
coverage==4.5.1
flask-graphql==1.4.1
flask==0.12.2
graphql-core==2.0
itsdangerous==0.24
jinja2==2.10
markupsafe==1.0
mock==2.0.0
mongomock==3.9.0
more-itertools==4.1.0
pbr==4.0.2
pluggy==0.6.0
promise==2.1
py==1.5.3
pytest-cov==2.5.1
pytest==3.5.0
pytz==2018.4
rx==1.6.1
sentinels==1.0.0
six==1.11.0
typing==3.6.4
werkzeug==0.14.1

that I used (I passed your requirements*.txt through pipenv and had everything updaded to their latest version)

Without a proper update of your code I'm afraid all this nice work that you've done cannot be used in any recent projects.

Once again, here is a big proactive thanks!

Thanks!

stratosgear commented 6 years ago

Well,

I have good news and bad news... :smiley:

The good news is that if I change in the def resolver in graphene_mongo/models.py from:

        def auto_resolver(root, args, contex, info):
            return resolver_query(g_schema, mongo_doc, args, info, is_list=is_list, validator=validator)

to

        def auto_resolver(root, info, **kwargs):
            return resolver_query(g_schema, mongo_doc, kwargs, info, is_list=is_list, validator=validator)

implementing only the major breaking change from Graphene's 2.x upgrade, then I get the /graphiqlGUI properly resolving all my queries and mutations I tried on your test models. And that's with all packages updated to their latest version. I'll keep testing it...

The bad news is that the majority of the tests still fail.

Starting from the test suite apparently was too much for me.

Nonetheless, having 90% of the tests failing is not inspiring at all, so if you can still fix that I think you have a gem!!!

Thanks!

stratosgear commented 6 years ago

I spoke too soon. My tests with mutation queries were done in your version of the repo not mine, so more changes are required in the mutation methods.

You can see the changes in my commit in my repo (ignore the pipfile changes)

joaovitorsilvestre commented 6 years ago

I really apreciated the complements, thanks.

I'm at work right now, but soon as I get to home I will help you to fix that. :)

joaovitorsilvestre commented 6 years ago

I did a small change at the setup of the tests and I belive that it fixed the most part of tests that were failing, you can see in 35_update_to_graphene2 (it has your fixes too).

The schema_builder was creating a graphene.Schema object with mutation even when it was not required (the argument mutations as None). And it breaks the assert of the function define_field_map (graphql.type.definition) because was sending a empty dict, which its not accepted anymore.

I didn't have time to fixed the other 4 tests that still failing. Soon I'll check it out.

stratosgear commented 6 years ago

Hey, thanks for looking it up. I'll keep you posted on any other findings, while I start using this on my pet project.