Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1384 fix arrays #1385

Merged
merged 1 commit into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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