Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/GraphQL/DocumentType/DocumentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ public function __construct(Service $graphQlService, PageType $pageType, LinkTyp
*/
public function getTypes(): array
{
return array_merge($this->types, $this->customTypes);
$folderType = $this->getGraphQlService()->getDocumentTypeDefinition('_document_folder');

return array_merge($this->types, [$folderType], $this->customTypes);
}

/**
Expand Down Expand Up @@ -112,6 +114,8 @@ public function resolveType($element, $context, ResolveInfo $info)
return $this->hardlinkType;
} elseif ($element instanceof Document\Snippet) {
return $this->snippetType;
} elseif ($element instanceof Document\Folder) {
return $this->getGraphQlService()->getDocumentTypeDefinition('_document_folder');
}

return null;
Expand Down
10 changes: 1 addition & 9 deletions src/GraphQL/General/AnyDocumentTargetType.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,9 @@ public function __construct(Service $graphQlService, $config = ['name' => 'AnyDo
*/
public function getTypes(): array
{
$types = [];

$service = $this->getGraphQlService();
$documentFolderType = $service->getDocumentTypeDefinition('_document_folder');

$types[] = $documentFolderType;
$documentUnionType = $this->getGraphQlService()->getDocumentTypeDefinition('document');
$supportedDocumentTypes = $documentUnionType->getTypes();
$types = array_merge($types, $supportedDocumentTypes);

return $types;
return $documentUnionType->getTypes();
}

public function resolveType($element, $context, ResolveInfo $info)
Expand Down
4 changes: 3 additions & 1 deletion src/GraphQL/General/AnyTargetType.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public function getTypes(): array
$types[] = $assetFolderType;
}

if ($service->querySchemaEnabled('document_folder')) {
if ($service->querySchemaEnabled('document_folder') && !$service->querySchemaEnabled('document')) {
// The 'document' union already includes _document_folder; only add it
// separately when the document union itself is not merged below.
$documentFolderType = $service->getDocumentTypeDefinition('_document_folder');
$types[] = $documentFolderType;
}
Expand Down
Loading