Skip to content
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

Path to 0.5.0 #53

Closed
32 tasks done
syrusakbary opened this issue Apr 19, 2016 · 14 comments
Closed
32 tasks done

Path to 0.5.0 #53

syrusakbary opened this issue Apr 19, 2016 · 14 comments

Comments

@syrusakbary
Copy link
Member

syrusakbary commented Apr 19, 2016

Version 0.5.0 compatible with the GraphQL Apr 2016 spec.
Related Pull Requests: #54 #59

Features

  • Improve error handling Improve Error Handling #41
  • Add ability to add custom errors (inheriting from GraphQLError)
  • Expose all the function and classes
  • Move modules from graphql.core.* to graphql.*
  • Make tests relative to the directories
  • Isolate promise package into own package in PyPI pypromise ☺️

Breaking changes

Improve the executor to be closer to the reference implementation:

  • Uses Promise instead of Deferred as it simplifies the implementation. Use parallel resolvers automatically as default behavior when available. Related PR: Use Promises in execute context #59

Commit Checklist

Implement the commits from GraphQL-js:

@Globegitter
Copy link
Contributor

@syrusakbary We have been looking a lot into a parallel middleware in our app (on Python 2.7). I was planning on open sourcing them, but the one we currently use is a simple ThreadPool middleware (the gevent middleware turned out not to be compatible with our app because we use grpc). That has its own issues though because it actually is spinning off threads. So our latest approach would be to use Futures (grpc is also using futures), which has a nice backport to python 2.7: https://github.com/agronholm/pythonfutures as well with an additional package to make it then-able: https://github.com/dvdotsenko/python-future-then

Apart from the fact that this would be neater for our app (so I will already be slightly more biased towards a futures solution), I also do think it is the more pythonic solution and more and more projects (like grpc) do actually implement the futures interface. So this would in my opinion, generally make it easier to integrate with the parallel middleware.

Since this is something that we need in our app and it has been on our internal TODO, that might be something that I, or possibly one of my colleagues could tackle. But the earliest for me would be sometime towards end of next week.

cc @alamaison

@sdcooke
Copy link
Contributor

sdcooke commented Apr 21, 2016

I've ported a few more commits:

Add to unit tests to ensure test accepts both edits of enter and leave: graphql/graphql-js@d2c005a
in graphql-python/graphql-core#56

Add test for parseLiteral on ComplexScalar: graphql/graphql-js@b3a5127
in graphql-python/graphql-core#57

Extract completeListValue funciton from CompleteValue: graphql/graphql-js@ab77470
Extract completeLeafValue from CompleteValue: graphql/graphql-js@4c5904c
Extract completeObjectValue from CompleteValue: graphql/graphql-js@5a13648
Extract completeAbstractValue from CompleteValue: graphql/graphql-js@d484f31
Add invariant for unreachable condition: graphql/graphql-js@7a15a3f
in graphql-python/graphql-core#58

Nit: fix missing quote in error message: graphql/graphql-js@db0924a
is already fixed so doesn't need doing

@syrusakbary
Copy link
Member Author

syrusakbary commented Apr 21, 2016

@Globegitter I think using futures is reasonable given the python context.
The main goal for using Promises is simplify the executor classes for only have one that could work in any case (sync or async resolver resolution).

If we could achieve it in a simple way with futures I think would be a good idea to use it instead of Promises. (Seems could be completely possible by using python-future-then 😉 )

@syrusakbary
Copy link
Member Author

@sdcooke you did a great work!

@syrusakbary
Copy link
Member Author

syrusakbary commented Apr 22, 2016

@Globegitter after researching and trying to implement using only futures I realized that everything would work great if we "promesify" the Futures automatically and have the advantages of using Promises at the same time.

So we can have the nice approach of Promises, but allowing the developer to use either a Deferred or Future if they want to. The Promise approach will not force any way for choosing how will be the executor (if asyncio, concurrent.futures, a Thread pool and so on), but will be only a layer on top of that.

@Globegitter
Copy link
Contributor

@syrusakbary That sounds like a quite good option. What exactly would 'promesifying' Futures in your opinion mean? Would this just be adding the .then interface or more than that? I suppose a .catch could be quite handy as well.

@syrusakbary
Copy link
Member Author

@Globegitter What I meant with promesifying Futures is wrapping each future in a Promise (will be done in the grapqhl library, with no extra effort from the developer).

Here is the related PR for Promises, if you want a take al look.
graphql-python/graphql-core#59

And here is the code for each executor... you might find useful too!
https://github.com/graphql-python/graphql-core/tree/features/promises/graphql/execution/executors

@Globegitter
Copy link
Contributor

Thanks, that is amazing progress @syrusakbary! Also this might be part of fixing #41 but it seems in your PR to 0.4.14 you missed: graphql/graphql-js@3d27953

@syrusakbary
Copy link
Member Author

syrusakbary commented Apr 28, 2016

@Globegitter I skipped intentionally this as we already pass the originalError to the GraphQLError exception.
https://github.com/graphql-python/graphql-core/blob/master/graphql/core/execution/executor.py#L230

Maybe what is not as obvious and need to be improved is that this original error is in the stack attr of the GraphQLError.
https://github.com/graphql-python/graphql-core/blob/master/graphql/core/error.py#L15

@syrusakbary
Copy link
Member Author

@sdcooke any other port of the graphql-js commits will be welcome! 😉

@sdcooke
Copy link
Contributor

sdcooke commented Apr 28, 2016

I haven't disappeared! Just not finding enough time to get to it right now. I'm currently battling against relay connections in graphene!

@syrusakbary
Copy link
Member Author

All the changes are now in the master branch. Closing this issue :)

@Globegitter
Copy link
Contributor

Wow that's amazing progress. Great job @syrusakbary! :)

@syrusakbary
Copy link
Member Author

syrusakbary commented May 5, 2016

This new graphql-core version will be pushed to PyPI soon.
I'm working in updating all external dependencies (aka graphene, graphql_relay, graphql-django-view, django-graphiql, flask-graphql) to support the new code structure and upload a new version for them too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants