Skip to content

Add missing DocumentElementType Renderlet#1005

Open
blankse wants to merge 8 commits into
pimcore:2026.xfrom
blankse:renderlet
Open

Add missing DocumentElementType Renderlet#1005
blankse wants to merge 8 commits into
pimcore:2026.xfrom
blankse:renderlet

Conversation

@blankse

@blankse blankse commented Nov 18, 2025

Copy link
Copy Markdown
Contributor

Adds GraphQL support for the Renderlet document editable, which was previously missing from the document element types.

Introduces a new RenderletType exposing the editable's _editableType, _editableName, id, type, subtype and the referenced relation (resolved as an anytarget element), plus the corresponding Renderlet query field config generator and its service registration.

@blankse blankse marked this pull request as draft November 18, 2025 13:27
@blankse blankse changed the title Add missing DocumentElementrType Renderlet Add missing DocumentElementType Renderlet Nov 18, 2025
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
21 New Major Issues (required ≤ 0)
3 New Bugs (required ≤ 0)
1 New Critical Issues (required ≤ 0)
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@blankse blankse marked this pull request as ready for review November 18, 2025 13:54
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
21 New Major Issues (required ≤ 0)
1 New Critical Issues (required ≤ 0)
B Reliability Rating on New Code (required ≥ A)
3 New Bugs (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Adds a RenderletType GraphQL type and its query field config generator,
modeled on the existing RelationsType, exposing the editable's
_editableType/_editableName/id/type/subtype and its single relation
target. Registers the generator service and baselines the new static()
usage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@blankse blankse changed the base branch from 1.9 to 2026.1 June 9, 2026 12:58
blankse and others added 3 commits June 9, 2026 12:59
Extract a resolveRenderlet() helper for the simple editable fields so the
repeated instanceof checks no longer live inside getInstance(), reducing its
cognitive complexity below the threshold. Drop the unused resolver parameters
from those fields and wrap the relation resolver signature to stay within the
line-length limit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@blankse

blankse commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

@kingjia90 Can you review this also please?

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

This PR adds GraphQL query support for the Pimcore "Renderlet" document editable, which was previously the only document element type missing a GraphQL type. It introduces a new RenderletType (exposing _editableType, _editableName, id, type, subtype, and the referenced relation resolved as an anytarget element), a matching Renderlet field-config generator, and wires them up via service configuration. The remainder of the diff is a regenerated studio frontend build (new hash directory 64084715… replacing 785fd5b2…).

Changes:

  • New RenderletType GraphQL object type, mirroring the existing RelationType (uses getO() for the relation target instead of getElement()).
  • New Renderlet query field config generator + service registration in graphql.yml, and a phpstan-baseline entry for the new static() usage.
  • Regenerated studio build artifacts and a refreshed manifest/publicPath hash.

Reviewed changes

Copilot reviewed 12 out of 27 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/GraphQL/DocumentElementType/RenderletType.php New GraphQL type exposing Renderlet fields and relation
src/GraphQL/DocumentElementQueryFieldConfigGenerator/Renderlet.php New generator returning RenderletType, consistent with siblings
src/Resources/config/graphql.yml Registers the Renderlet type generator service
phpstan-baseline.neon Baselines the new static() warning for RenderletType
src/Resources/public/studio/build/64084715.../* Regenerated studio frontend build artifacts (new hash dir)
src/Resources/public/studio/build/785fd5b2.../* Removed previous studio build artifacts

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

@blankse

blankse commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@kingjia90 Every time I work with the DataHub GraphQL API, I find errors. It’s happened again today #1115. It seems I’m the only one submitting bug fixes. But these have been left unresolved since November. I wonder if we’re the only ones using this API...

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

Copilot reviewed 12 out of 27 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/Resources/public/studio/build/64084715-c37d-4575-98f2-2172027a803c/mf-stats.json:25

  • This PR bundles a complete Studio frontend rebuild — the entire build output directory is regenerated under a new hash (64084715-c37d-4575-98f2-2172027a803c) and the previous one (785fd5b2-5311-4070-9fc4-81949c904ac6) is removed, including thousands of lines of regenerated/minified JS. The PR description only covers the backend GraphQL Renderlet document editable (PHP type, config generator, service registration, phpstan baseline). There is no frontend source change in this PR that requires this rebuild, and the Renderlet GraphQL type does not depend on the Studio bundle. Please confirm whether this frontend rebuild is intentional; if not, consider splitting it out so the backend change can be reviewed and reverted independently of the generated assets.

@kingjia90

Copy link
Copy Markdown
Contributor

Solid structure (mirrors RelationType, wiring is correct), but two real bugs and some noise:

  1. RenderletType.php:77relation is almost always null in production. getO() doesn't lazy-load, and $o is stripped when documents are serialized into the core cache. Any cache-hit document resolves relation to null despite a valid target. Fix: call $value->load() first (like core does everywhere).

  2. RenderletType.php:77 — leaks unpublished targets. Relation::getElement() filters unpublished elements; getO() doesn't, and nothing downstream compensates. Add a publish check alongside the load() fix.

  3. RenderletType.php:59type field is useless. Renderlet::getType() is hardcoded to 'renderlet', so type always equals _editableType and never tells you if the target is an asset/document/object. Use the target's real type (what getData()['type'] returns) — it's new public schema, hard to change later.

  4. Docs01_Document_Queries.md supported-editables list not updated.

Address code review feedback on the new Renderlet document element type:

- relation: call load() before getO(). getO() does not lazy-load and $o is
  stripped from the serialized document in the core cache, so cache-hit
  documents resolved relation to null despite a valid target.
- relation: filter unpublished targets, mirroring Relation::getElement().
  getO() does no publish check and nothing downstream compensated.
- type: expose the target's real element type via getData()['type'] instead
  of Renderlet::getType(), which is hardcoded to 'renderlet' and duplicated
  _editableType.
- doc: add Renderlet to the supported page element types list.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@blankse

blankse commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in 980e713.

  1. relation null on cache hits — now calls $value->load() before getO(). getO() doesn't lazy-load and $o is stripped by Renderlet::__sleep(), so cache-hit documents were resolving to null.
  2. Unpublished targets — added a Element\Service::doHideUnpublished() / isPublished() filter, mirroring what Relation::getElement() does internally.
  3. type field — now resolves via getData()['type'] (the real asset/document/object type) instead of Renderlet::getType(), which is hardcoded to 'renderlet' and duplicated _editableType.
  4. Docs — added Renderlet to the supported page element types list in 01_Document_Queries.md.

blankse and others added 3 commits July 2, 2026 10:12
Both lines exceeded the 120-character limit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

@kingjia90 kingjia90 requested a review from Copilot July 2, 2026 11:28
@kingjia90 kingjia90 modified the milestones: 2026.2.1, 2026.3.0 Jul 2, 2026
@kingjia90 kingjia90 added Improvement and removed Bug labels Jul 2, 2026
@kingjia90 kingjia90 changed the base branch from 2026.1 to 2026.x July 2, 2026 11:29

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

Copilot reviewed 13 out of 28 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants