Does Elide GraphQL support cascading delete?
QubitPi opened this issue · 3 comments
QubitPi commented
Hi Elide team, we have a question on DELETE/REMOVE operation in GraphQL API:
If say we have an Author/Book relationship, where 1 author links to multiple books. When we create an author with 3 books and later delete that author by specifying author ID only, will all 3 books be deleted as well? If so, does data model needs to be annotated with some JPA annotation? We read through the documentation but failed to find the answer.
Thanks,
Jack
aklish commented
Elide itself doesn’t cascade deletes but JPA can. You have to a note the
model with JPA annotations.
…On Sun, Dec 24, 2023 at 7:15 AM Jack ***@***.***> wrote:
Hi Elide team, we have a question on DELETE/REMOVE operation in GraphQL
API:
If say we have an Author/Book relationship, where 1 author links to
multiple books. When we create an author with 3 books and later delete that
author by *specifying author ID only*, will all 3 books be deleted as
well? If so, do data model needs to be annotated with some JPA annotation?
Thanks,
Jack
—
Reply to this email directly, view it on GitHub
<#3134>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABVH6QPOASOVMRXHOXW6PMDYLATFVAVCNFSM6AAAAABBBQ5SMKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA2TKMBZG43DINA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
QubitPi commented
Thank you. That worked. Please let me know if you would like this to be included in elide documentation and I'm happy to do it
jkusa commented
Elide itself doesn’t cascade deletes but JPA can. You have to a note the model with JPA annotations.
Here is an example in Yavin:
@OneToMany(mappedBy = "dashboard", cascade = [CascadeType.REMOVE], orphanRemoval = true)
var widgets: MutableSet<DashboardWidget> = mutableSetOf()