[
https://issues.apache.org/jira/browse/SLING-13152?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Robert Munteanu resolved SLING-13152.
-------------------------------------
Fix Version/s: GraphQL Core 0.0.38
Assignee: Martin Schulze
Resolution: Fixed
> [GraphQL] Multiple aliased selections for the same field lose sub-field
> selections due to FQN collision in SelectedFieldWrapper
> -------------------------------------------------------------------------------------------------------------------------------
>
> Key: SLING-13152
> URL: https://issues.apache.org/jira/browse/SLING-13152
> Project: Sling
> Issue Type: Bug
> Components: GraphQL
> Reporter: Martin Schulze
> Assignee: Martin Schulze
> Priority: Major
> Fix For: GraphQL Core 0.0.38
>
>
> When a GraphQL query uses multiple aliases pointing at the same underlying
> field:
> {
> AliasA: items { ... on TypeA { rteField { html } } }
> AliasB: items { ... on TypeB { textField } }
> }
> All aliases resolve to the same fully-qualified name (FQN), e.g.
> `ParentType.items`.
> SelectedFieldWrapper stores sub-fields in a HashMap<String, SelectedField>
> keyed by
> FQN. When the second alias is processed, its entry overwrites the first,
> discarding
> the sub-field selections from AliasA.
> For fields whose values are resolved directly (scalars), this is harmless.
> For fields
> that consult the selection set at resolution time — such as MultiFormatString
> (RTE),
> which uses the sub-field list to determine which formats
> (html/plaintext/markdown) to
> render — the result is null, because the selection set appears empty.
> Steps to reproduce:
> 1. Define two CF models, ModelA (with a MultiFormatString field) and ModelB
> 2. Create a container model with a fragment-reference multifield `items`
> accepting
> both ModelA and ModelB
> 3. Query with two aliases on `items`:
> AliasA: items { ... on ModelAModel { rteField { html } } }
> AliasB: items { ... on ModelBModel { textField } }
> 4. Observe: rteField { html } returns null
> Expected: html contains the stored HTML content
> Actual: html is null
> Fix: when a duplicate FQN is encountered, merge the sub-field maps from both
> aliases instead of overwriting. This preserves all requested sub-fields
> regardless of how many aliases reference the same field.
> Affected class: SelectedFieldWrapper (and SelectionSetWrapper at the top
> level)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)