Skip to content

Adding middleware keeps subscriptions events from returning #91

Description

@justuswilhelm

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?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions