Closed bpillai closed 6 years ago
Hi @bpillai, yes.
List<String> stringList = new ArrayList<String>();
stringList.add("string1");
stringList.add("string2");
stringList.add("string3");
InputObject input = new InputObject.Builder<Object>()
.put("input1", 1)
.put("input2", true)
.put("input3", stringList)
.put("input4", "string")
.build();
List<InputObject> inputs = new ArrayList<InputObject>();
inputs.add(input);
inputs.add(input);
GraphQLRequestEntity requestEntity = GraphQLRequestEntity.Builder()
.url(EXAMPLE_URL)
.arguments(new Arguments("test", new Argument("id", inputs)))
.request(TestModel.class)
.build();
returns with
query {
test (id:[InputObject{map={input4=string, input3=[string1, string2, string3], input2=true, input1=1}},InputObject{map={input4=string, input3=[string1, string2, string3], input2=true, input1=1}}]) {
...
hi @chemdrew : this creates an invalid syntax . I was looking for query { test (id:[{input4=string, input3=[string1, string2, string3], input2=true, input1=1},{input4=string, input3=[string1, string2, string3], input2=true, input1=1}}]) {} instead of query { test (id:[InputObject{map={input4=string, input3=[string1, string2, string3], input2=true, input1=1}},InputObject{map={input4=string, input3=[string1, string2, string3], input2=true, input1=1}}]) {
rather than updating the toString adding the following in the StringUtils.java formatGraphQLArgumentList seems to solve the issue .
private static String formatGraphQLArgumentList(List values) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("["); Pattern p = Pattern.compile("^\$"); for (Object value: values) { if (stringBuilder.length() != 1) stringBuilder.append(","); Matcher m = p.matcher("" + value); System.out.println(value.getClass()); if (value instanceof String && !"null".equalsIgnoreCase((String) value) && !m.find()) { stringBuilder.append("\"").append(value).append("\""); } else if (value instanceof InputObject) { stringBuilder.append(((InputObject) value).getMessage()); } else { stringBuilder.append(value); } } stringBuilder.append("]"); return stringBuilder.toString(); }
:facepalm: great catch! Would you like to open the pull request fixing my mistake as you described there for some credit as a contributor?
I am not able to push the branch to your repository git push -u origin feature/add-list-of-input-objects-in-arguments git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
I’ll be home to look into and help correct it in about an hour or so
Oh, just create a fork of this repo. Commit to your fork, then raise the pull request from your fork
PR : https://github.com/americanexpress/nodes/pull/36 I have signed the CLA . But is marked as pending . If the code changes are available master soon that would be great . Thank you .
Awesome, sometimes it takes a few minutes to update. Will just check on that periodically
Thank you for your first contribution on Nodes! Congrats!
example
xyz(abc:[{def:enum, value:"string"},{def:enum, value:"string"}]) { }