From 85e78238fe331922eb571d8d230a6aeb2e02a656 Mon Sep 17 00:00:00 2001 From: Joost Farla Date: Wed, 4 Oct 2023 13:46:53 +0200 Subject: [PATCH] Fix GraphQL source --- .../engine/fetch/FetchPlanner.java | 2 +- .../graphql/mapper/AbstractGraphQlMapper.java | 20 ++++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/engine/src/main/java/nl/geostandaarden/imx/orchestrate/engine/fetch/FetchPlanner.java b/engine/src/main/java/nl/geostandaarden/imx/orchestrate/engine/fetch/FetchPlanner.java index d33df0af..1ccb815a 100644 --- a/engine/src/main/java/nl/geostandaarden/imx/orchestrate/engine/fetch/FetchPlanner.java +++ b/engine/src/main/java/nl/geostandaarden/imx/orchestrate/engine/fetch/FetchPlanner.java @@ -201,7 +201,7 @@ private FetchOperation fetchSourceObject(ObjectTypeRef sourceTypeRef, Set } else { var targetModel = modelMapping.getSourceModel(targetTypeRef.getModelAlias()); - // TODO: Refactoe + // TODO: Refactor if (property.getCardinality().isSingular()) { selectedProperties.add(SelectedProperty.builder() .property(property) diff --git a/source-graphql/src/main/java/nl/geostandaarden/imx/orchestrate/source/graphql/mapper/AbstractGraphQlMapper.java b/source-graphql/src/main/java/nl/geostandaarden/imx/orchestrate/source/graphql/mapper/AbstractGraphQlMapper.java index 71fe3de6..bd9b3e9e 100644 --- a/source-graphql/src/main/java/nl/geostandaarden/imx/orchestrate/source/graphql/mapper/AbstractGraphQlMapper.java +++ b/source-graphql/src/main/java/nl/geostandaarden/imx/orchestrate/source/graphql/mapper/AbstractGraphQlMapper.java @@ -8,7 +8,6 @@ import nl.geostandaarden.imx.orchestrate.engine.exchange.DataRequest; import nl.geostandaarden.imx.orchestrate.engine.exchange.SelectedProperty; import nl.geostandaarden.imx.orchestrate.engine.source.SourceException; -import nl.geostandaarden.imx.orchestrate.model.Relation; abstract class AbstractGraphQlMapper { @@ -20,8 +19,8 @@ protected SelectionSet createSelectionSet(Set selectedProperti } var fields = selectedProperties.stream() - .map(this::getField) - .toList(); + .map(this::getField) + .toList(); return new SelectionSet(fields); } @@ -29,19 +28,12 @@ protected SelectionSet createSelectionSet(Set selectedProperti private Field getField(SelectedProperty property) { SelectionSet selectionSet = null; -// if (!ObjectUtils.isEmpty(property.getSelectedProperties())) { -// selectionSet = createSelectionSet(new ArrayList<>(property.getSelectedProperties())); -// } - - if (property.getProperty() instanceof Relation) { - var refField = property.getProperty() - .getCardinality() - .isSingular() ? "ref" : "refs"; - selectionSet = new SelectionSet(List.of(new Field(refField, selectionSet))); + if (property.getNestedRequest() != null) { + selectionSet = createSelectionSet(property.getNestedRequest() + .getSelectedProperties()); } return new Field(property.getProperty() - .getName(), List.of(), selectionSet); + .getName(), List.of(), selectionSet); } - }