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

GraphQL API Cascade Deletion #3024

Closed
dan-codes1 opened this issue Jun 15, 2023 · 8 comments
Closed

GraphQL API Cascade Deletion #3024

dan-codes1 opened this issue Jun 15, 2023 · 8 comments
Labels
api Issues related to the API category feature-request Request a new feature

Comments

@dan-codes1
Copy link

Describe the bug

Hi, I'd like to clarify something. I noticed that when I delete the source model of relational data using GraphQL, its relationships still stay in the database. Is this normal behaviour? I'd expect that if a model is deleted (especially the source model), all its other relationships should get deleted as well and not be queried.
I'm currently having to delete each of it's relational data at the moment. I just thought to clarify / raise this.

Steps To Reproduce

Steps to reproduce the behavior:
1. Create a schema with relational data.
2. Try to delete it.
3. The main data deletes, but leaves its other relational data.

Expected behavior

To delete the data and all its relations automatically.

Amplify Framework Version

2.8.0

Amplify Categories

API

Dependency manager

Swift PM

Swift version

5

CLI version

11.1.1

Xcode version

14

Relevant log output

<details>
<summary>Log Messages</summary>


INSERT LOG MESSAGES HERE
```

Is this a regression?

Yes

Regression additional context

No response

Device

iPhone 14

iOS Version

15

Specific to simulators

No response

Additional context

No response

@phantumcode phantumcode added the datastore Issues related to the DataStore category label Jun 19, 2023
@atierian atierian added api Issues related to the API category question General question and removed datastore Issues related to the DataStore category labels Jun 20, 2023
@royjit
Copy link
Contributor

royjit commented Jun 22, 2023

Hi @dan-codes1 Thank you for reaching us. Could you please clarify on what you mean by delete source model of relational data using GraphQL ? Are you deleting the an item by calling Amplify.Datastore.delete or are you going to AppSync console and invoking a delete operation?
As per this #933 deleting a parent should delete all the child items.

@royjit royjit added the pending-community-response Issue is pending response from the issue requestor label Jun 22, 2023
@royjit royjit self-assigned this Jun 30, 2023
@dan-codes1
Copy link
Author

@royjit for example, let us say we have Post and Comment models. A Post can have many Comment (@hasmany relationship).

If I call try await Amplify.API.mutate(request: .delete(Post)), it deletes the post model, but leaves all the comments that belong to the post undeleted.

This is what I mean. I expect that if a Post is deleted, then all the Comment that belongs to the post get deleted as well.

@royjit
Copy link
Contributor

royjit commented Jul 7, 2023

Cascade delete is supported only in Datastore and not in API GraphQL, you have to delete each item individually.

@dan-codes1
Copy link
Author

Noted. Can this be made a feature request? @royjit

@royjit
Copy link
Contributor

royjit commented Jul 14, 2023

Marking this as a feature request, will update here when we have more info to share.

@royjit royjit added feature-request Request a new feature and removed pending-community-response Issue is pending response from the issue requestor labels Jul 14, 2023
@royjit royjit removed their assignment Jul 14, 2023
@github-actions
Copy link
Contributor

This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!

@dan-codes1 dan-codes1 changed the title GraphQL API Relational Data Deletion GraphQL API Cascade Deletion Jul 14, 2023
@dan-codes1
Copy link
Author

@royjit just realized this is already also a feature request in the category-api repo: aws-amplify/amplify-category-api#273

@atierian atierian removed the question General question label Jan 8, 2024
Copy link
Contributor

github-actions bot commented May 7, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to the API category feature-request Request a new feature
Projects
None yet
Development

No branches or pull requests

4 participants