Skip to content

MiddlewareManager only decorates the first field encountered #15

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

Closed
patrys opened this issue Nov 19, 2018 · 1 comment
Closed

MiddlewareManager only decorates the first field encountered #15

patrys opened this issue Nov 19, 2018 · 1 comment

Comments

@patrys
Copy link
Contributor

patrys commented Nov 19, 2018

get_middleware_resolvers is implemented as a generator:

https://github.com/graphql-python/graphql-core-next/blob/f6b078bddae4dd8a48ebf878a6fd5fbbac52bd1b/graphql/execution/middleware.py#L56-L58

The generator object is then assigned to self._middleware_resolvers:

https://github.com/graphql-python/graphql-core-next/blob/f6b078bddae4dd8a48ebf878a6fd5fbbac52bd1b/graphql/execution/middleware.py#L30-L32

As the generator is not consumed and unrolled into a list at this point, it is exhausted during the reduce() call of the first field construction:

https://github.com/graphql-python/graphql-core-next/blob/f6b078bddae4dd8a48ebf878a6fd5fbbac52bd1b/graphql/execution/middleware.py#L46-L50

As the generator is now exhausted, all other calls to reduce() will immediately receive StopIteration so no other field is wrapped.

patrys added a commit to patrys/graphql-core-next that referenced this issue Nov 19, 2018
patrys added a commit to patrys/graphql-core-next that referenced this issue Nov 19, 2018
@Cito Cito closed this as completed in #16 Nov 25, 2018
Cito pushed a commit that referenced this issue Nov 25, 2018
@Cito
Copy link
Member

Cito commented Nov 25, 2018

Thanks @patrys - I can confirm the issue and your fix, and added a regression test for this.

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