0

I have a mutation query to be passed to aappsync graphql query as shown below which should be passed from Java client code

{
    "query": "mutation UpdateUser{setUserInformationAdmin(information: {UserName:\"testUser20SK\",Email:\"testUser20SK@lb.de\",Enabled:true,SecurityHintEnabled:true,Api:\"Default\"})}",
    "variables": null,
    "operationsName": null
}

The problem here is the input strings should be in the format \"testUser20SK\" when passing to the query.

But when I give the input in the format for example:

queryBuilder.append("{\"query\":\"mutation UpdateUser{setUser(information: {UserName:\""+userInformation.getUserName()+"\"");

it sends the input as UserName:"testUser20SK"

The query is working only when input is passed as UserName:\"testUser20SK\"

Is there a way to pass input in the format UserName:\"testUser20SK\" in Java code instead of UserName:"testUser20SK".

While writing this questipn itself I had struggled because the \ was not displaying properly.

Manushi
  • 597
  • 1
  • 7
  • 26
  • Put three backslashes before the quote instead of just one. A double backslash translates to a backslash, and the third backslash is the one you already have, which quotes the quotes. – RealSkeptic Aug 10 '21 at 13:02
  • Yes. works. Actually I am trying it for past 5 hours but it worked only after I posted the question here. – Manushi Aug 10 '21 at 13:04

1 Answers1

0

Passing the input in the format worked for me

 queryBuilder.append("{\"query\":\"mutation UpdateUser{setUserInformation(information: {UserName:\\\""+userInformation.getUserName()+"\\\"");
Manushi
  • 597
  • 1
  • 7
  • 26