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
Add @upsert
directive and nested mutation operations to create or update a model regardless whether it exists
#1005
Add @upsert
directive and nested mutation operations to create or update a model regardless whether it exists
#1005
Conversation
Co-Authored-By: Benedikt Franke <benedikt@franke.tech>
I am really impressed with how quickly you were able to dig into this and added a solid implementation with comprehensive tests, while sticking to the existing codestyle. Apart from the doc entry in the directives reference, there is also https://lighthouse-php.com/master/eloquent/getting-started.html#update and https://lighthouse-php.com/master/eloquent/nested-mutations.html |
Thanks! Added missing documentation. |
|
||
$executeMutation = function () use ($model, $args): Model { | ||
return $this->executeMutation($model, new Collection($args))->refresh(); | ||
return $this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer this indentation
Massive effort and great job on this cool new feature, @joskfg Thank you! |
@upsert
directive and nested mutation operations to create or update a model regardless whether it exists
Resolves #995
Changes
Upsert
Use the @upsert directive to update a model with
a given
id
or create it if it does not exist.Since upsert can create or update your data you must have all the minimum fields for a creation as required.
The
id
is always required and must be marked as fillable in the model.Nested mutations
You can now expose a nested operation
upsert
in all nested mutations that support theupdate
operation.Breaking changes
-