Closed albertonaperijr closed 5 years ago
Hi @albertonaperijr,
This was a bug from v0.1.0-v0.1.2 and was fixed in v0.1.3. Please upgrade to the latest v0.3.0.
Original issue here #34
Hi @chemdrew,
I'm actually encountering this issue using the latest version (v0.3.0). I'm not sure if the issue #34 was actually related to this case since it's using an array of InputObjects directly as an argument while in this case, I need the array of InputObjects inside of an InputObject.
Thanks.
Payment.java
@GraphQLProperty(name = "createPayment", arguments = {
@GraphQLArgument(name = "input")
})
public class Payment {
private String paymentId;
public String getPaymentId() {
return paymentId;
}
public void setPaymentId(String paymentId) {
this.paymentId = paymentId;
}
@Override
public String toString() {
return "Payment{" +
"paymentId='" + paymentId + '\'' +
'}';
}
}
Main.java
public class Main {
public static void main(String[] args) {
InputObject item1 = new InputObject.Builder()
.put("name", "test1")
.put("currency", "USD")
.put("price", 5.00)
.build();
InputObject item2 = new InputObject.Builder()
.put("name", "test2")
.put("currency", "USD")
.put("price", 5.00)
.build();
List<InputObject> items = new ArrayList<InputObject>();
items.add(item1);
items.add(item2);
InputObject input = new InputObject.Builder()
.put("currency", "USD")
.put("totalAmount", 10.00)
.put("items", items)
.build();
final GraphQLRequestEntity requestEntity = GraphQLRequestEntity.Builder()
.url("https://graphql.example.com")
.request(Payment.class)
.arguments(new Arguments("createPayment", new Argument("input", input)))
.build();
System.out.println(requestEntity.getRequest());
}
}
prints out
query { createPayment (input:{totalAmount:10.0,currency:"USD",items:[{price:5.0,name:"test1",currency:"USD"},{price:5.0,name:"test2",currency:"USD"}]}) { paymentId } }
Can you post more of your code to see if it matches up?
Hi @chemdrew,
I've created a sample project and tried to run the code and it's working just fine. I'm not sure why it's not working on one of my existing projects.
Anyway, thanks for taking the time to solve this issue.
Yeah, for sure, no problem. Let me know if the issue persists or you recreate it in the latest version though, wanna make sure there aren’t any bugs hiding.
It's working now. I think the issue was with my IDE (IntelliJ). I'd updated the dependency version in my pom.xml but it didn't automatically update the local dependencies when clicking the run button.
I've fixed it by manually running mvn idea:idea
and mvn clean install
in the command line.
E.g.
I've tried it with the code below but items are not generating properly.
Actual Output:
Expected Output:
Thanks.