-
Notifications
You must be signed in to change notification settings - Fork 180
Use Promises in execute context #59
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
Conversation
@syrusakbary that is great stuff! So if I use a library that returns a So what I am imagining is using the Is that something that should work with this implementation? |
Neat! |
Process and thread executor should be able to delegate to a pool (shared or individual pool per execution) of finite size. To prevent large queries from blowing the OS |
@Globegitter is not necessarily that, your resolver function could return a |
But if you want to use |
This PR improves the executor abstraction by using Promises.
At the same time, removes all the usage of the Middlewares as are no longer necessary.
The
Promise
implementation is based in aplus with a lot of improvements and fixes likePromise.all
,promise_for_dict
,promise.do_resolve
.The resolvers can now return a raw object or a promise.
Executors
The following executors are available:
graphql.execution.executors.asyncio.AsyncioExecutor
: This executor executes the resolvers in the Python asyncio event loop.graphql.execution.executors.asyncio.GeventExecutor
: This executor executes the resolvers in the Gevent event loop.graphql.execution.executors.asyncio.ProcessExecutor
: This executor executes each resolver as a processgraphql.execution.executors.asyncio.ThreadExecutor
: This executor executes each resolver in a Thread.graphql.execution.executors.asyncio.SyncExecutor
: This executor executes each resolver synchronusly (default).Usage
You can specify the executor to use via the executor keyword argument in the
grapqhl.execution.execute
function.If no executor is specified,
SyncExecutor
will be used by default.