how to run a function before all generated resolvers ? #2714
Labels
graphql-transformer-v1
Issue related to GraphQL Transformer v1
pending-response
Issue is pending response from the issue author
question
General question
Which Category is your question related to?
@function
directiveAmplify CLI Version
3.17.0
What AWS Services are you utilizing?
lambda, dynamodb
Provide additional details e.g. code snippets
As an example, i have a custom lambda function which performs custom authorization checks before an action. (@auth directive does not match my requirements, where users can belong to hundreds of groups). The function acts as a gate keeper, throwing an Unautorized exception when the user is not allowed to perform the action on a resource, otherwise forwarding the initial request.
I'd like to run this "gatekeeper" function before the generated vtl runs.
As per the documentation, the @function directive overrides the vtl.
Is it possible to implement some sort of pipeline resolver mixing lambda and vtl.
Another example might be to use a custom lambda function to filter items out from a vtl.
I was thinking about a custom directives like
That would be used as follow:
When query/mutation is run, the check function is called with all initial arguments, the function performs whatever logic it needs to do and can also update the arguments, including $context.stash and the execution resumes to the generated VTL.
The text was updated successfully, but these errors were encountered: