Skip to content

Commit

Permalink
Merge pull request #1385 from robp94/main-issue-1384
Browse files Browse the repository at this point in the history
#1384 fix arrays
  • Loading branch information
phillip-kruger authored May 8, 2022
2 parents 3f7a7ab + 9c2eb79 commit ee2089c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ private List handleList(List list, Field field) {
if (item instanceof Map) {
result.add(includeNullCreatorParameters((Map) item, field));
} else {
// can this ever happen?
result.add(item);
}
});
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import jakarta.json.bind.annotation.JsonbCreator;
import java.net.URL;
import java.util.Set;

import static io.smallrye.graphql.client.core.Argument.arg;
import static io.smallrye.graphql.client.core.Argument.args;
Expand Down Expand Up @@ -68,14 +69,23 @@ public void testSimpleRecordWithFactory() throws Exception {
Document query = document(operation(
field("simpleWithFactory",
args(arg("input",
inputObject(prop("a", "a"), prop("b", "b")))),
inputObject(prop("a", "a"),
prop("b", "b"),
prop("c", new String[] { "c", "cc" }),
prop("d", new String[] { "d", "dd" })))),
field("a"),
field("b"))));
field("b"),
field("c"),
field("d"))));
Response response = client.executeSync(query);
System.out.println(response);
System.out.println("query.build() = " + query.build());
assertEquals("a", response.getData().getJsonObject("simpleWithFactory").getString("a"));
assertEquals("b", response.getData().getJsonObject("simpleWithFactory").getString("b"));
assertEquals("c", response.getData().getJsonObject("simpleWithFactory").getJsonArray("c").getString(0));
assertEquals("cc", response.getData().getJsonObject("simpleWithFactory").getJsonArray("c").getString(1));
assertEquals("dd", response.getData().getJsonObject("simpleWithFactory").getJsonArray("d").getString(0));
assertEquals("d", response.getData().getJsonObject("simpleWithFactory").getJsonArray("d").getString(1));
}
}

Expand Down Expand Up @@ -106,11 +116,11 @@ public record SimpleRecord(String a, String b) {

}

public record SimpleRecordWithFactory(String a, String b) {
public record SimpleRecordWithFactory(String a, String b, String[] c, Set<String> d) {

@JsonbCreator
public static SimpleRecordWithFactory build(String a, String b) {
return new SimpleRecordWithFactory(a, b);
public static SimpleRecordWithFactory build(String a, String b, String[] c, Set<String> d) {
return new SimpleRecordWithFactory(a, b, c, d);
}

}
Expand Down

0 comments on commit ee2089c

Please sign in to comment.