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

Adding middleware keeps subscriptions events from returning #91

Open
justuswilhelm opened this issue Feb 2, 2022 · 4 comments
Open

Comments

@justuswilhelm
Copy link

I have a middleware that populates info.context with several data loaders that are needed to pull in related objects. When I add the middleware to the GraphQL WS consumer, the subscription stops returning results. If I remove the middleware (by making the middleware list empty), it continues returning results, albeit they are incorrect because of the missing loaders.

My middleware is really simple

def loader_middleware(next, root, info, *args, **kwargs):
    """Add loaders to info.context."""
    info.context.loader = Loader()
    return next(root, info, *args, **kwargs)

and it is added like this

    middleware = [
        middleware.loader_middleware,
    ]

And then, when I trigger a subscription broadcast, it does not return anything when testing the subscription in GraphiQL.

How well tested is the middleware implementation? Is there anything to watch out for?

@justuswilhelm
Copy link
Author

I'm willing to put a bounty of 250 USD on this issue. Solving this would very much de-block our project development.

@tony
Copy link

tony commented Feb 15, 2022

Also having this issue

CC'ing other data loader related issues that may be bumping into this, #67 #55.

@justuswilhelm
Copy link
Author

So the issue are the data loaders and the resulting promises? Interesting. Perhaps there is a workaround?

@prokher
Copy link
Member

prokher commented Apr 27, 2023

The version 1.0.0rc1 is available in PyPI, the middleware-related routines are pretty much different now. Please check whether the issues is still here.

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

No branches or pull requests

3 participants