Make getDocument folder-safe (resolve document folders) - #22
Merged
Conversation
…oring Mirror of the folder guard used in the relation resolvers; adds the existing _document_folder type to the document union so getDocument on a folder path resolves instead of failing on an unresolvable union type.
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.
solverat
approved these changes
Jul 20, 2026
Contributor
|
Thanks @blankse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.