Skip to content

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.

1 participant