Handle not present field in GraphQL request in Java

141 Views Asked by At

I have a GraphQL application running. In another application, I am trying to send mutation request in which a field is omitted (using Java). How can I ensure that GraphQL can handle my request as expected. For example if I have MyInput = {field1: "val1", field2: null}, and I want to update field1 only. How can I construct a request such that GraphQL handles it as {field1: "val1"}?

class MyInput {
    String field1;
    String field2;
}

class MyClient {
public void callGraphQlApi(String query, MyInput input, String optName) {
Map<String, Object> vars = new HashMap<>();
vars.put("request", input);
//send GraphGL request using FeignClient POST request
}
}
0

There are 0 best solutions below