Skip to content

optional wrapping the middleware into promises #108

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

Merged
merged 2 commits into from
Mar 1, 2017

Conversation

rapthead
Copy link
Contributor

Pull request for issue that we discuss earlier. graphql-python/graphene#423

With this changes we can disable wrapping in promises this way:

    return schema.execute('''
            query {
                field
            }
        ''',
        middleware=MiddlewareManager(
            SomeMiddleware(),
            wrap_in_promise=False,
        )
    )

@syrusakbary syrusakbary merged commit 29aba38 into graphql-python:master Mar 1, 2017
@jameswyse
Copy link

Does this work with graphene-django? How do you specify the option there?

@rapthead
Copy link
Contributor Author

rapthead commented Mar 8, 2017

I didn't use graphene-django, but i sure that this should work nice with it.
It uses same execution api, so you can use code from top comment.
But if you don't use custom middleware, overhead problem irrelevant for you.

@alonroth
Copy link

alonroth commented Jan 9, 2020

@rapthead Can you please elaborate on what this new "wrap_in_promise=False" actually supposed to fix?
I'm using Middleware to authenticate the GraphQL calls and its authenticating each connection & node in the response causing a huge overhead.

I was wondering if your fix relevant to my problem but I couldn't make it work for me...

Thanks!

@msmfco
Copy link

msmfco commented Apr 29, 2020

@alonroth`wrap_in_promise forces your middleware function to return a promise, but remove the need for graphql-python to wrap every middleware returned value into a promise.
If your middlewares are already returning promises, then it's a good optimization.

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

Successfully merging this pull request may close these issues.

5 participants