feat(graphql): unify Binary, File, and Image field queries via DotBinaryLike #34540#35363
feat(graphql): unify Binary, File, and Image field queries via DotBinaryLike #34540#35363
Conversation
Adds a unit test suite that pins down the target contract for unifying GraphQL queries across BinaryField, FileField, and ImageField: both DotBinary and DotFileasset must implement a shared DotBinaryLike interface and expose the same 12 common properties (name, title, size, mime, versionPath, idPath, path, sha256, isImage, width, height, modDate). Tests currently red — implementation follows in a subsequent commit. Existing DotBinary assertions and DotFileasset backward-compat assertions are already green and guard against regressions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…aryLike #34540 BinaryField maps to DotBinary and FileField/ImageField map to DotFileasset. The two object types exposed completely different sub-fields, forcing clients to know which dotCMS field type backed a property and to write queries like `myfile { fileAsset { versionPath } }` while the equivalent `mybinary { versionPath }` worked directly. Introduce a shared DotBinaryLike GraphQL interface implemented by both DotBinary and DotFileasset. It declares the 12 common binary properties (name, title, size, mime, versionPath, idPath, path, sha256, isImage, width, height, modDate). DotBinary resolves them from the binary map already produced by BinaryToMapTransformer (no behavior change). DotFileasset gets a new FileAssetBinaryPropertyDataFetcher that runs the same transformer against the FileAsset/DotAsset contentlet, so the values returned are identical across all three field types. Type-specific extras stay on the concrete type — DotBinary still exposes focalPoint, DotFileasset still exposes fileName, description, fileAsset, metaData, showOnMenu, sortOrder. Existing queries continue to work. Includes: - New TypeUtil.createObjectType overloads accepting GraphQLInterfaceType varargs. - DotBinaryLike registered via ContentAPIGraphQLTypesProvider so introspection sees it. - TypeResolver dispatches on source type: Map -> DotBinary, Contentlet -> DotFileasset. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @nollymar's task in 2m 6s —— View job PR Review
Issues Found1. Performance regression — N transformer invocations per contentlet (
|
Summary
Refs #34540.
Today
BinaryFieldmaps toDotBinaryandFileField/ImageFieldmap toDotFileassetin the GraphQL schema. The two object types expose completely different sub-fields, so a client cannot write a uniform query across the three dotCMS field types:This PR introduces a shared
DotBinaryLikeGraphQL interface implemented by bothDotBinaryandDotFileasset. It declares the 12 common binary properties:name, title, size, mime, versionPath, idPath, path, sha256, isImage, width, height, modDateDotBinary— resolves them from the binary map already produced byBinaryToMapTransformer. No behavior change.DotFileasset— newFileAssetBinaryPropertyDataFetcherruns the same transformer against the underlying FileAsset/DotAssetContentlet, so the values returned are identical to those a client gets from the equivalentmybinaryquery.Type-specific extras stay on the concrete type:
DotBinarykeepsfocalPoint.DotFileassetkeepsfileName, description, fileAsset, metaData, showOnMenu, sortOrder.A
TypeResolveron the interface dispatches on the source Java type:Map→DotBinary,Contentlet→DotFileasset.Backward compatibility
DotBinaryqueries: unchanged.DotFileassetqueries (myfile { fileAsset { ... } },fileName,description, etc.): unchanged.Test plan
CustomFieldTypeBinaryLikeTest(8 tests, all green) — asserts interface presence on both concrete types, common field set, consistent scalar types, and backward-compat fields.com.dotcms.graphql.**unit-test package passes (24 tests).Commits
test(graphql): failing tests for unified DotBinaryLike interface #34540— TDD red step.feat(graphql): unify Binary, File, and Image field queries via DotBinaryLike #34540— implementation.🤖 Generated with Claude Code