You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by an...@apache.org on 2023/08/25 03:18:09 UTC

[sling-org-apache-sling-graphql-core] 01/01: Fix a problem with Union Failures were fields with

This is an automated email from the ASF dual-hosted git repository.

andysch pushed a commit to branch issue/union-failures
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-graphql-core.git

commit b2140ab4f64f7ee37bcfeab38a653c2255d1887c
Author: Andreas Schaefer <sc...@me.com>
AuthorDate: Thu Aug 24 20:17:13 2023 -0700

    Fix a problem with Union Failures were fields with
    
    the same name are ignored when in an union
---
 .../apache/sling/graphql/core/engine/SelectedFieldWrapper.java    | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/main/java/org/apache/sling/graphql/core/engine/SelectedFieldWrapper.java b/src/main/java/org/apache/sling/graphql/core/engine/SelectedFieldWrapper.java
index 39f6eeb..df0a04d 100644
--- a/src/main/java/org/apache/sling/graphql/core/engine/SelectedFieldWrapper.java
+++ b/src/main/java/org/apache/sling/graphql/core/engine/SelectedFieldWrapper.java
@@ -62,6 +62,14 @@ public class SelectedFieldWrapper implements SelectedField {
                             selectedChildField.objectTypeNames.add(objectTypeName);
                         }
                     }
+                    // also merge fields
+                    for (graphql.schema.SelectedField field : sf.getSelectionSet().getFields()) {
+                        if (!selectedChildField.subFieldMap.containsKey(field.getName())) {
+                            SelectedFieldWrapper childField = new SelectedFieldWrapper(field);
+                            selectedChildField.subFieldMap.put(field.getName(), childField);
+                            selectedChildField.subFields.add(childField);
+                        }
+                    }
                 }
             });
         }