From 97e2c777e31262d2fd0147ef4c9038841cad6d26 Mon Sep 17 00:00:00 2001 From: weisswurstkanone Date: Wed, 29 Apr 2020 12:50:25 +0200 Subject: [PATCH] GraphQL Mutation createAssetFolder always said "unable to resolve parent" #208 --- src/GraphQL/Mutation/MutationType.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/GraphQL/Mutation/MutationType.php b/src/GraphQL/Mutation/MutationType.php index 153290e7..58db76af 100644 --- a/src/GraphQL/Mutation/MutationType.php +++ b/src/GraphQL/Mutation/MutationType.php @@ -672,10 +672,25 @@ public function getCreateFolderResolver($elementType) return static function ($value, $args, $context, ResolveInfo $info) use ($elementType, $me) { $parent = null; - if (isset($args["parentId"])) { - $parent = AbstractObject::getById($args["parentId"]); - } else if (isset($args["path"])) { - $parent = AbstractObject::getByPath($args["path"]); + + if ($elementType == "asset") { + if (isset($args["parentId"])) { + $parent = Asset::getById($args["parentId"]); + } else if (isset($args["path"])) { + $parent = Asset::getByPath($args["path"]); + } + } else if ($elementType == "document") { + if (isset($args["parentId"])) { + $parent = Document::getById($args["parentId"]); + } else if (isset($args["path"])) { + $parent = Document::getByPath($args["path"]); + } + } else { + if (isset($args["parentId"])) { + $parent = AbstractObject::getById($args["parentId"]); + } else if (isset($args["path"])) { + $parent = AbstractObject::getByPath($args["path"]); + } } if (!$parent) {