Pipeline resolver field-level authorization
See original GitHub issueWhich Category is your question related to? AppSync
Amplify CLI Version 4.13.1
What AWS Services are you utilizing? AppSync, DynamoDB
Provide additional details e.g. code snippets Is it possible to use pipeline resolvers for field-level authorization? All of the tutorials and documentation I’ve run across so far show how to do an authorization check and then return either an unauthorized error or the entire query result, like this:
#if(## authorization check logic goes here)
$util.unauthorized()
#end
$util.toJson($ctx.result)
I’m wondering if it’s possible to return only some of the dynamo record fields from the result, depending on the outcome of the authorization check.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Pipeline resolvers (VTL) - AWS AppSync
Pipeline resolvers are useful for applications that, for instance, require performing an authorization check before fetching data for a field.
Read more >API (GraphQL) - Custom business logic (Lambda function ...
Secure your custom query or mutation with field-level authorization rules ... To create a pipeline resolver that calls to multiple AWS Lambda functions...
Read more >How to use Lambda authorization with AppSync
Authorization in AppSync. AppSync supports several ways for authorization, such as Cognito, AWS IAM, API key, and a custom Lambda function.
Read more >How to check permissions of an entity on create in appsync
Specifically, you are able to use AppSync pipeline resolvers to perform the authorization check before creating the note.
Read more >Amplify GraphQL Lambda @function Resolvers - Isaac - Medium
Traditional Pre/Post Resolver Pipeline with Lambda Configuration ... for our use case since we no longer had to rely on field level @auth....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello @sopranolinist Another potential solution would be to use a lambda function to handle this authorization logic you are looking for. When chaining this directive on the same field will create a pipeline resolver for the field. Function Docs here: https://docs.amplify.aws/cli/graphql-transformer/directives#function
One potential way to address this would be to use the
@auth
, a directive provided as a part of the GraphQL Transformer. Docs here on@auth
: https://docs.amplify.aws/cli/graphql-transformer/directives#field-level-authorizationAn example of the usecase you provided could be something like the following