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

Support applying middleware to both subscription subscribe and resolve functions #569

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cuzzlor
Copy link

@cuzzlor cuzzlor commented Aug 22, 2023

Problem defn

When using GraphQL shield to apply rules across the schema, subscription rules are not executed for subscription subscribe operations.

Issue

The applyMiddlewareToField function does not take into account that subscription resolvers can have both subscribe and resolve functions defined.

When applyMiddlewareToField runs, if resolve is defined, subscribe is ignored.

This means that GraphQL shield rules (and other middlewares) are not applied to subscription subscribe operations.

Proposed fix

@leiyangyou posted a patch over here:
#561

This patch worked for me, allowing GraphQL shield middleware rules to be executed during the subscribe operation of subscriptions.

All the tests pass with this variant of applyMiddlewareToField, however it is a pretty solid change to the function's structure.

I was not quickly able to work out how to add a test validating the proposed fix.

…e applied to both subscribe and resolve subscription resolver functions
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

Successfully merging this pull request may close these issues.

None yet

1 participant