Handling nested update mutation



I’m working on an app that will allow to create event with some informations. In particular, different attending prices have to be set. Here is a summary of the types:

type Activite @model {
id: ID! @isUnique
price: [Price!]! @relation(name: “PriceActivite”)
… + more fields not useful for the discussion

type Price @model {
id: ID! @isUniquer
description: String!
price: Float!
activite: Activite! @relation(name: “PriceActivite”)

Create a new “Activite” is OK. My question is how to handle an update of the event through which the prices array may (or may not) change? The prices array may be longer with fewer entries, or longer with new entries, just updated or not changed at all.

What is the good practice for the nested update? If I perform separate updates (prices, then activite), won’t there be a error in the activite update as I won’t specify any prices that are required?



After some tests, I didn’t succeed in updating anything with the above configuration. I can’t update an activite with nested mutation. I can’t create a new price since activite is required in its type.

The only way I found is to remove the required on the activite field of type Price, update a modified price or create a new one and connect it to the corresponding activity.

Is there any way to perform this in a more efficient way?