What feature are you missing?
I would love a feature similar to what Graph.cool used to have with addTo function. Basically, when I run the function upsertNode and the node already exists, I don't want the update function to overwrite my node variables but have the option to add, subtract, multiply, or divide in case of floats and ints.
Why do I want this? Well if I already call upsertNode and my intention is to add two values, I don't want to know the value of existing node, I just care about adding my new value to it.
How could this feature look like in detail? Tradeoffs?
Consider this data model:
type User {
id: ID! @unique
name: String!
numberOfLives: Int!
}
Add special parameters such as add, subtract, multiply, and divide as allowed update input
mutation {
upsertUser(
where: {
id: "my-id"
}
create: {
name: "some name"
numberOfLives: 2
}
update: {
add: {
numberOfLives: 2
}
}
)
}
This should be covered by #1349 (Atomic operations). @sorenbs can you confirm this will also work for upsert mutations?
That's correct. The update part of upsert mutations have the same capabilities as normal update mutations, so when this feature lands it will also work for upserts.
Most helpful comment
That's correct. The update part of upsert mutations have the same capabilities as normal update mutations, so when this feature lands it will also work for upserts.