Make getDocument folder-safe (resolve document folders) - #1126
Conversation
There was a problem hiding this comment.
Pull request overview
Makes getDocument(fullpath) resolve document folders correctly.
Changes:
- Adds
_document_folderto thedocumentunion. - Resolves
Document\Folderinstances to that type.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
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.
68eb0ed to
51fe9e4
Compare
|
…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).
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.
fce982c to
5b238cc
Compare
|
🚫 Issue-link guardrail failed — this PR has been converted to draft. Every PR must reference a tracking issue in
Add the link with a keyword in the PR description (not in a comment): https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests When fixed, press Ready for review to re-run the checks. |
|
@robertSt7 Can you review this? |
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>
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>
a1f4dab to
cfc4e80
Compare
|



getDocument(fullpath)on a folder path currently fails:DocumentType::resolveTypereturnsnullfor folders, so thedocumentunion 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_foldertype to the union (getTypes) and resolves it (resolveType), mirroring the folder guard already present inAbstractRelationsType,ObjectsTypeandAnyDocumentTargetType. No new type is introduced.Verified against a real Pimcore install: before,
getDocumenton a folder path errors; after, it returnsdocument_folder. Non-folder documents are unaffected.Related
Builds on the
resolveType()folder guards merged with #1105. Those guards make a document folder resolve to_document_folder; this PR makes_document_folderan actual member of thedocumentunion, 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()andPropertyType\ObjectsType::getTypes()merge the types of thedocumentunion, 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 buildcommit was dropped so the build folder matches the base branch.