Skip to content

MiddlewareManager only decorates the first field encountered #15

Closed
@patrys

Description

@patrys

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.

Activity

added a commit that references this issue on Nov 19, 2018
883315d
added a commit that references this issue on Nov 19, 2018
4d03e85
added a commit that references this issue on Nov 25, 2018
6a9814d
Cito

Cito commented on Nov 25, 2018

@Cito
Member

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

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

      MiddlewareManager only decorates the first field encountered · Issue #15 · graphql-python/graphql-core