Defer mutate update to mutate create

This commit is contained in:
Jake Barnby 2022-05-03 17:41:02 +12:00
parent 87333e2eb0
commit 71a0cb59b5
No known key found for this signature in database
GPG key ID: A4674EBC0E404657

View file

@ -596,17 +596,15 @@ class Builder
);
}
private static function mutateUpdate(string $collectionId, Database $dbForProject): callable
private static function mutateUpdate(
App $utopia,
Request $request,
Response $response,
Database $dbForProject,
string $collectionId
): callable
{
return fn($type, $args, $context, $info) => new CoroutinePromise(
function (callable $resolve, callable $reject) use ($collectionId, $type, $args, $dbForProject) {
try {
$resolve($dbForProject->updateDocument($collectionId, $args['id'], new Document($args)));
} catch (\Throwable $e) {
$reject($e);
}
}
);
return self::mutateCreate($utopia, $request, $response, $dbForProject, $collectionId);
}
private static function mutateDelete(string $collectionId, Database $dbForProject): callable