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

Batch Delete Join Table Item When Original Item Is Deleted - Graphql Mutations #644

Closed
LoukasGP opened this issue Jul 12, 2022 · 1 comment
Labels

Comments

@LoukasGP
Copy link

LoukasGP commented Jul 12, 2022

Which Category is your question related to?
API.graphql mutation

Amplify CLI Version
Version: 8.0.1

What AWS Services are you utilizing?
AppSync

Provide additional details e.g. code snippets. Be sure to remove any sensitive data.

I've come across this documentation that notes batch is not supported, and thus requires a custom resolver.

I've also come across this feature request for cascading delete with DynamoDB Streams and Lambda.

I see there is an example for a batch put custom resolver, however, I'm new to VTL transformers, and would like some guidance for setting up a batch delete transformer.

Use Case:

There is a @model for JobListing, and one for Images. They have a ManyToMany Relationship. When I delete an Image record from DynamoDB, all JobListingImage records for that image need to be deleted as well.

I've considered looping through the JobListingImage records, but there could be a possiblity where there are 100,000 records to query and then delete. This does not appear like a good, nor viable solution.

Any help would be appreciated,

Luke

@LoukasGP LoukasGP added the question Further information is requested label Jul 12, 2022
@josefaidt josefaidt transferred this issue from aws-amplify/amplify-cli Jul 12, 2022
@sundersc
Copy link
Contributor

Hi @LoukasGP - Your usecase can be achived by AppSync's BatchDeleteItem operation.

Here is an example of BatchDeleteItem operation from AppSync docs.
https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-dynamodb-batch.html

VTL programming guide:
https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-reference-programming-guide.html#aws-appsync-resolver-mapping-template-reference-programming-guide

AppSync resolver tutorials:
https://docs.aws.amazon.com/appsync/latest/devguide/tutorials.html

Please see if these help. Let us know if you have questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants