pythongraphqlgraphene-python

How to use middleware after resolver in graphene?


Using Graphql in Node, you can use middlewares BEFORE or AFTER the resolver, using, for example, Prisma.

In Python, using Graphene, I could only find a way to use middleware BEFORE the resolver.

Is there a way to use middlewares AFTER the resolver in Python?


Solution

  • How about:

    class SomeMiddleware(object):
        def resolve(self, next, root, info, **args):
            next_node = next(root, info, **args)
            ...logic...
            return next_node