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

Added runAuthAfterResolver option to change execution order of authorization rules and resolvers. #1518

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

Conversation

bghtrbb
Copy link

@bghtrbb bghtrbb commented Jul 14, 2023

A new runAuthAfterResolver boolean field was added to the IOptions interface to allow configuring this option.

The generateFieldMiddlewareFromRule function was updated to check the runAuthAfterResolver option and call the rule's resolve method either before or after the main GraphQL resolver, depending on the value.

  • If runAuthAfterResolver is true, it will call the rule's resolve after running the main resolver function.
  • If false or unspecified, it maintains the existing behavior of calling the rule resolve first.
  • This allows customizing whether the authorization rule logic runs before or after the main resolver execution.

Some reasons this change may have been made:

  • To avoid running expensive authorization logic unnecessarily if the resolver itself fails.
  • It allows the authorization logic to be influenced by or even directly use the outcome of the resolver. This is useful for situations where the decision on authorization depends on the result of the resolver or how the resolver execution concludes.

Overall this change provides more control over the timing and ordering of the authorization rules vs the resolvers when generating Auth Rules.

…erator functions to customize the execution order of authorization rules and resolvers.
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