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

Only first middleware is ran through decorator #227

Closed
seb-b opened this issue Apr 12, 2022 · 1 comment
Closed

Only first middleware is ran through decorator #227

seb-b opened this issue Apr 12, 2022 · 1 comment

Comments

@seb-b
Copy link
Contributor

seb-b commented Apr 12, 2022

If multiple middleware are added to the register_query_field, only the first one is ran e.g.

class FistMiddleware(object):
   def resolve(self, next, root, info, **args):
        print("Running first")
        return next(root, info, **args)
        
class SecondMiddleware(object):
   def resolve(self, next, root, info, **args):
        print("Running second")
        return next(root, info, **args)
        
 @register_query_field("demo", middleware=[FistMiddleware, SecondMiddleware])
 class Demo(models.Model):
      ....

Then the output is only 'Running first'. Switching the order means only second is outputted.

I think it's because of this line here where only the first field_middleware is returned in the loop instead of yielding all of them.

@zerolab
Copy link
Member

zerolab commented Apr 13, 2022

@seb-b that is a great catch. Do you have time to submit a PR?

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

2 participants