Closed
Description
mutation new_mutation($email:JSON!,$password:JSON!)
{
Account
{
AccountLogin(input:{credentials:{email:$email,password:$password}})
{
obj
}
}
}
and this is function:
private void mutation()
{
try {
JSONObject jsonBody1 = new JSONObject();
JSONObject jsonBody2 = new JSONObject();
jsonBody1.put("email", "orient@blueeast.com");
jsonBody2.put("password", "Ori@1");
Myapolloclient.getmyapolloclient().mutate(
New_mutationMutation.builder().email(jsonBody1).password(jsonBody2).build()).enqueue(new ApolloCall.Callback<New_mutationMutation.Data>(){
@Override
public void onResponse(@Nonnull Response<New_mutationMutation.Data> dataResponse) {
Log.d("response", dataResponse.data().Account().__typename());
}
@Override
public void onFailure(@Nonnull ApolloException e) {
}
});
} catch (Throwable t) {
Log.d("exception", t.toString());
}
}
Activity
Ali-zain-javed commentedon Apr 19, 2018
@digitalbuddha @sav007 please sir review this ,thanks
digitalbuddha commentedon Apr 19, 2018
Why would need to make json instead of passing strings?
Ali-zain-javed commentedon Apr 19, 2018
@digitalbuddha Sir when i use this same error occur
mutation new_mutation($email:JSON!,$password:JSON!)
{
Account
{
AccountLogin(input:{credentials:{email:$email,password:$password}})
{
obj
}
}
}
//////////////////////////////////////////////////calll
Ali-zain-javed commentedon Apr 19, 2018
04-19 11:52:36.469 13430-13451/com.sourcey.materialloginexample E/AndroidRuntime: FATAL EXCEPTION: Apollo Dispatcher
Process: com.sourcey.materialloginexample, PID: 13430
java.lang.IllegalArgumentException: Can't map GraphQL type: JSON to: class java.lang.Object. Did you forget to add custom type adapter?
at com.apollographql.apollo.response.ScalarTypeAdapters.adapterFor(ScalarTypeAdapters.java:30)
at com.apollographql.apollo.internal.json.InputFieldJsonWriter.writeCustom(InputFieldJsonWriter.java:72)
at com.example.alizain.new_apollo_example.New_mutationMutation$Variables$1.marshal(New_mutationMutation.java:149)
at com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor.httpRequestBody(ApolloServerInterceptor.java:147)
at com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor.httpCall(ApolloServerInterceptor.java:112)
at com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor$1.run(ApolloServerInterceptor.java:78)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Ali-zain-javed commentedon Apr 19, 2018
Sir server side accept object but from there data passing through string ,so error is creating
sav007 commentedon Apr 23, 2018
You should pass
email
argument as aString
or create a separate GraphQL type for it.sav007 commentedon May 1, 2018
With this PR you can now pass JSON as argument: #897