Skip to content

Make getDocument folder-safe (resolve document folders) - #1126

Open
blankse wants to merge 3 commits into
pimcore:2026.3from
blankse:document-union-folder-safe
Open

blankse wants to merge 3 commits into
pimcore:2026.3from
blankse:document-union-folder-safe

Conversation

@blankse

@blankse blankse commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

getDocument(fullpath) on a folder path currently fails: DocumentType::resolveType returns null for folders, so the document union cannot resolve the abstract type at runtime ("Abstract type Document must resolve to an Object type at runtime ... received null").

This adds the already-existing _document_folder type to the union (getTypes) and resolves it (resolveType), mirroring the folder guard already present in AbstractRelationsType, ObjectsType and AnyDocumentTargetType. No new type is introduced.

Verified against a real Pimcore install: before, getDocument on a folder path errors; after, it returns document_folder. Non-folder documents are unaffected.

Related

Fixes pimcore/platform-version#491

Builds on the resolveType() folder guards merged with #1105. Those guards make a document folder resolve to _document_folder; this PR makes _document_folder an actual member of the document union, so the resolved type is a valid possible type. Both halves are needed for the document-folder case — with #1105 merged, this is the remaining one.

Since AbstractRelationsType::getTypes() and PropertyType\ObjectsType::getTypes() merge the types of the document union, the folder-inclusive union propagates to relations and properties automatically; no additional change is needed there (analogous to the object-folder handling in #1054).

Rebased onto 2026.2 after #1105 and #1054 were merged. The previous Automatic frontend build commit was dropped so the build folder matches the base branch.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Makes getDocument(fullpath) resolve document folders correctly.

Changes:

  • Adds _document_folder to the document union.
  • Resolves Document\Folder instances to that type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/GraphQL/DocumentType/DocumentType.php
blankse added a commit to blankse/data-hub that referenced this pull request Jul 20, 2026
Adding _document_folder to the document union made it appear twice in
AnyDocumentTargetType/AnyTargetType, which prepend it and then merge the
document union's types. GraphQL unions require unique members. Rely on the
document union as the single source: AnyDocumentTargetType returns its types
directly; AnyTargetType only adds _document_folder separately when the
document union itself is not merged.
blankse added a commit to blankse/data-hub that referenced this pull request Jul 22, 2026
Adding _document_folder to the document union made it appear twice in
AnyDocumentTargetType/AnyTargetType, which prepend it and then merge the
document union's types. GraphQL unions require unique members. Rely on the
document union as the single source: AnyDocumentTargetType returns its types
directly; AnyTargetType only adds _document_folder separately when the
document union itself is not merged.
@blankse
blankse force-pushed the document-union-folder-safe branch from 68eb0ed to 51fe9e4 Compare July 22, 2026 17:16
@sonarqubecloud

Copy link
Copy Markdown

@blankse
blankse force-pushed the document-union-folder-safe branch from fce982c to 5b238cc Compare September 7, 2026 11:23
blankse added a commit to blankse/data-hub that referenced this pull request Sep 7, 2026
Adding _document_folder to the document union made it appear twice in
AnyDocumentTargetType/AnyTargetType, which prepend it and then merge the
document union's types. GraphQL unions require unique members. Rely on the
document union as the single source: AnyDocumentTargetType returns its types
directly; AnyTargetType only adds _document_folder separately when the
document union itself is not merged.
@pimcore-deployments
pimcore-deployments marked this pull request as draft September 7, 2026 11:23
@blankse

blankse commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@robertSt7 Can you review this?

blankse added a commit to blankse/data-hub that referenced this pull request Sep 7, 2026
Covers both halves of the fix: DocumentType::getTypes() lists
'_document_folder' as a possible type of the 'document' union and
DocumentType::resolveType() resolves a document folder to it (without
it getDocument() on a folder path fails with "Abstract type Document
must resolve to an Object type at runtime").

Also covers the dedupe: the composed unions AnyDocumentTargetType and
AnyTargetType contain '_document_folder' exactly once when the document
union is enabled, and AnyTargetType still contains it when the document
union is disabled.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
blankse added a commit to blankse/data-hub that referenced this pull request Sep 7, 2026
Covers both halves of the fix: DocumentType::getTypes() lists the folder
type as a possible type of the 'document' union and
DocumentType::resolveType() resolves a document folder to it (without it
getDocument() on a folder path fails with "Abstract type Document must
resolve to an Object type at runtime").

Also covers the dedupe: the composed unions AnyDocumentTargetType and
AnyTargetType contain the folder type exactly once when the document
union is enabled, and AnyTargetType still contains it when the document
union is disabled.

The union members are compared by GraphQL type name: the container
inlines the tagged type services, so the same type can be a different PHP
instance depending on where it is taken from.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@blankse
blankse force-pushed the document-union-folder-safe branch from a1f4dab to cfc4e80 Compare September 7, 2026 13:39
@blankse
blankse marked this pull request as ready for review September 16, 2026 07:16
blankse and others added 3 commits September 24, 2026 15:50
…oring

The 'document' union's resolveType returned null for folders, causing
getDocument(fullpath) on a folder path to fail with an unresolvable
abstract type. Add the existing _document_folder type to the union and
resolve it, mirroring the folder guard already used in the relation
resolvers (AbstractRelationsType, ObjectsType, AnyDocumentTargetType).

(cherry picked from commit e2d50d4)
Adding _document_folder to the document union made it appear twice in
AnyDocumentTargetType/AnyTargetType, which prepend it and then merge the
document union's types. GraphQL unions require unique members. Rely on the
document union as the single source: AnyDocumentTargetType returns its types
directly; AnyTargetType only adds _document_folder separately when the
document union itself is not merged.

(cherry picked from commit 5b238cc)
Covers both halves of the fix: DocumentType::getTypes() lists the folder
type as a possible type of the 'document' union and
DocumentType::resolveType() resolves a document folder to it (without it
getDocument() on a folder path fails with "Abstract type Document must
resolve to an Object type at runtime").

Also covers the dedupe: the composed unions AnyDocumentTargetType and
AnyTargetType contain the folder type exactly once when the document
union is enabled, and AnyTargetType still contains it when the document
union is disabled.

The union members are compared by GraphQL type name: the container
inlines the tagged type services, so the same type can be a different PHP
instance depending on where it is taken from.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit cfc4e80)
@jcPimcore
jcPimcore force-pushed the document-union-folder-safe branch from cfc4e80 to 76d0d0d Compare September 24, 2026 13:59
@jcPimcore jcPimcore added this to the 2026.3.1 milestone Sep 24, 2026
@jcPimcore
jcPimcore changed the base branch from 2026.2 to 2026.3 September 24, 2026 13:59
@sonarqubecloud

Copy link
Copy Markdown

@jcPimcore jcPimcore modified the milestones: 2026.3.1, 2026.3.2 Oct 8, 2026
@brusch brusch mentioned this pull request Oct 9, 2026
45 of 74 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants