Skip to content

Commit

Permalink
Fix GraphQL source
Browse files Browse the repository at this point in the history
  • Loading branch information
joostfarla committed Oct 4, 2023
1 parent fc7d598 commit 85e7823
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private FetchOperation fetchSourceObject(ObjectTypeRef sourceTypeRef, Set<Path>
} else {
var targetModel = modelMapping.getSourceModel(targetTypeRef.getModelAlias());

// TODO: Refactoe
// TODO: Refactor
if (property.getCardinality().isSingular()) {
selectedProperties.add(SelectedProperty.builder()
.property(property)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends DataRequest> {

Expand All @@ -20,28 +19,21 @@ protected SelectionSet createSelectionSet(Set<SelectedProperty> selectedProperti
}

var fields = selectedProperties.stream()
.map(this::getField)
.toList();
.map(this::getField)
.toList();

return new SelectionSet(fields);
}

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);
}

}

0 comments on commit 85e7823

Please sign in to comment.