Amplify-cli: How can I add Lambda Pipeline Resolver to Type with @model

Created on 30 Oct 2019  路  5Comments  路  Source: aws-amplify/amplify-cli

I am trying to sanitize the WYSIWYG input from the user with https://www.npmjs.com/package/dompurify.
After doing some reading, I decided to try adding pipeline lambda resolver to existing
type Record @model @searchable @auth(rules: [{allow: groups, groups: ["sys_admin"], operations:[create, update, delete]}])

I found the tutorial on how to add a custom resolver here :
https://aws-amplify.github.io/docs/cli-toolchain/graphql?sdk=js#add-a-custom-resolver-that-targets-an-aws-lambda-function

but not sure how this lambda resolver can be used in Type with @model directive.
This was also asked before here: https://github.com/aws-amplify/amplify-cli/issues/867

if removing @model directive is the only option, what steps need to be performed in order to keep the same functionalities?

graphql-transformer question

All 5 comments

Pipeline resolvers are not supported by the CLI toolchain, only as custom resources as you said and from that point you need to go full manual, but it is something we're actively looking into to bring it to the CLI.

Do you need pipeline resolver or a single lambda resolver that can be achieved today with the @function directive would help?

@attilah thank you for the clarification.

yes. I think a single lambda resolver also helps. however, by looking at the document, I also need to remove @model directive in order to add @function to the mutation.

@monaye Yes, you are right. You can have the @function on a field of a type or in Query for example. The docs has a complete sample about this at: https://aws-amplify.github.io/docs/cli-toolchain/graphql#function

I'm closing the issue, if you have new things to ask feel free to reopen at a later time.

@monaye I think this is an example for what you were looking for : https://dev.to/aws-builders/direct-lambda-resolvers-with-aws-amplify-and-appsync-2k3j

@monaye Yes, you are right. You can have the @function on a field of a type or in Query for example. The docs has a complete sample about this at: https://aws-amplify.github.io/docs/cli-toolchain/graphql#function

I'm closing the issue, if you have new things to ask feel free to reopen at a later time.

Should we have closed this issue? Or maybe a feature request needs to be created.
As I understand the main question of this issue is not resolved yet. It is, to my knowledge, not yet supported to use lambda resolvers on types that are annotated with @model.

Is this on the planning already?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rehos picture rehos  路  3Comments

gabriel-wilkes picture gabriel-wilkes  路  3Comments

YikSanChan picture YikSanChan  路  3Comments

nicksmithr picture nicksmithr  路  3Comments

kangks picture kangks  路  3Comments