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.

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