Skip to content

Commit

Permalink
Merge pull request #3555 from ingef/fix/types-for-frontend
Browse files Browse the repository at this point in the history
Bring back type structure for frontend
  • Loading branch information
thoniTUB authored Sep 17, 2024
2 parents f7d292a + 06d30b4 commit d426b67
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.bakdata.conquery.apiv1.frontend;

import jakarta.validation.constraints.NotNull;

import com.bakdata.conquery.models.types.ResultType;
import lombok.Getter;
import lombok.experimental.SuperBuilder;

@Getter
@SuperBuilder
public class FrontendResultType {
@NotNull
String type;

@Getter
@SuperBuilder
public static class List extends FrontendResultType {
@NotNull
FrontendResultType elementType;
}

public static FrontendResultType from(ResultType resultType) {
if (resultType instanceof ResultType.ListT<?> listT) {
return List.builder()
.elementType(from(listT.getElementType()))
.type("LIST").build();
}

return FrontendResultType.builder().type(resultType.typeInfo()).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class FrontendSelect {
private SelectId id;
private String label;
private String description;
private String resultType;
private FrontendResultType resultType;
@JsonProperty("default")
private Boolean isDefault;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.bakdata.conquery.apiv1.frontend.FrontendFilterConfiguration;
import com.bakdata.conquery.apiv1.frontend.FrontendList;
import com.bakdata.conquery.apiv1.frontend.FrontendNode;
import com.bakdata.conquery.apiv1.frontend.FrontendResultType;
import com.bakdata.conquery.apiv1.frontend.FrontendRoot;
import com.bakdata.conquery.apiv1.frontend.FrontendSecondaryId;
import com.bakdata.conquery.apiv1.frontend.FrontendSelect;
Expand Down Expand Up @@ -172,7 +173,7 @@ public FrontendSelect createSelect(Select select) {
.id(select.getId())
.label(select.getLabel())
.description(select.getDescription())
.resultType(select.getResultType().typeInfo())
.resultType(FrontendResultType.from(select.getResultType()))
.isDefault(select.isDefault())
.build();
}
Expand Down

0 comments on commit d426b67

Please sign in to comment.