Upsert Mutations #25
Comments
When can we expect to use this feature? What are workarounds for the time being? |
We introduced a A current workaround is first querying the node in question and then either using the update if it exists or the create mutation. |
Thanks for the quick response as always @marktani! So
At this point I can query |
Still doesn't look like it has made it into the Docs. Am I safe to use the undocumented version? Is this still on the horizon? I see this issue was part of the GitHub project tracker that was closed May 3rd. Has the project roadmap moved? |
Hey @mjsisley just saw this. @mvanlonden It sounds like your workflow is nicely covered by the custom authentication feature currently in beta, here's an example: https://github.com/graphcool-examples/functions/tree/master/auth0-authentication |
Would be ideal if you can run an update without knowing the id in for the model, In my mind its kind of the point of an upsert really. |
It would also be great if upserts were available within nested mutations. For example, assuming the following schema (not showing id/created/updated fields):
Let's say I wanted to add a new |
@export-mike +1 |
This has been implemented in the Prisma 1.0 release. |
Assuming this means it's usable outside of Prisma also? Just using the graphcool cloud? |
No, Prisma is being developed separately from Graphcool Framework. You can read more about Prisma and Graphcool Framework in the Forum. |
@marktani Any plans to add support to Graphcool? I would really love to use |
Thanks a lot for bringing this up @muhajirframe. There's a now a new feature request for adding |
Currently each model gets an update and a create mutation. Performing an update or create if needed requires an additional query to be performed before the mutation.
A possible solution could be an
upsertModel
mutation that would try and query the model by one of the passed fields instead of a passed ID (still need to come up with a smart way of defining which field should be used for the lookup) and updates the row. If no model object matches the query a new one will be created with the passed parameters.For the upsert mutation the parameter signatures would be similar as for the create mutation. All fields that are required for create need to be required for upsert (contrary to update where every field besides the
id
is optional).The text was updated successfully, but these errors were encountered: