Skip to content

Commit

Permalink
GraphQL Mutation createAssetFolder always said "unable to resolve par…
Browse files Browse the repository at this point in the history
…ent" #208
  • Loading branch information
weisswurstkanone committed Apr 29, 2020
1 parent eda7332 commit d1dcf62
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/GraphQL/Mutation/MutationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ public function build(&$config = [], $context = [])
$this->buildUpdateAssetMutation($config, $context);
$this->buildCreateFolderMutation("asset", $config, $context);
$this->buildCreateFolderMutation("object", $config, $context);
$this->buildCreateFolderMutation("document", $config, $context);
$this->buildUpdateFolderMutation("asset", $config, $context);
$this->buildUpdateFolderMutation("object", $config, $context);
$this->buildUpdateFolderMutation("document", $config, $context);
$this->buildDeleteAssetMutation($config, $context);
$this->buildDeleteDocumentMutation($config, $context);
$this->buildDeleteFolderMutation("asset", $config, $context);
Expand Down Expand Up @@ -695,10 +697,14 @@ public function getCreateFolderResolver($elementType)
if ($elementType === "asset") {
$newInstance = new Folder();
$newInstance->setFilename($args["filename"]);
} else {
$newInstance = new \Pimcore\Model\DataObject\Folder();
} else if ($elementType === "object") {
$newInstance = new DataObject\Folder();
$newInstance->setFilename($args["filename"]);
} else if ($elementType === "document"){
$newInstance = new Document\Folder();
$newInstance->setKey($args["key"]);
}

$newInstance->setParentId($parent->getId());

$newInstance->save();
Expand Down Expand Up @@ -762,6 +768,8 @@ public function buildUpdateFolderMutation($type, &$config, $context)
$configuration = $context['configuration'];
if ($type === "asset") {
$element = Folder::getById($id);
} else if ($type == "document") {
$element = Document\Folder::getById($id);
} else {
$element = \Pimcore\Model\DataObject\Folder::getById($id);
}
Expand Down

0 comments on commit d1dcf62

Please sign in to comment.