0
votes

(I am a beginner) I am trying to do an AppSync query from my Android app with Amplify. I'm following the steps as in this page- https://aws-amplify.github.io/docs/android/api#run-a-query After executing the following code,

  public void query(){
        mAWSAppSyncClient.query(ListTodosQuery.builder().build())
                .responseFetcher(AppSyncResponseFetchers.CACHE_AND_NETWORK)
                .enqueue(todosCallback);
    } 

The GraphQL Callback response is supposed to be like:

{
  "data": {
    "listTodos": {
      "items": [
        {
          "id" : ...
        }]}}}

But I keep receiving the response as:

com.apollographql.apollo.api.Response@df0e853

It doesn't have any other data. Why is this so? Why is the response in this format?

(I tried running the listTodos query in the AppSync console and I get the right response there, with data and all the items in the DynamoDB)

1

1 Answers

2
votes

com.apollographql.apollo.api.Response@df0e853 is the instance of the response object. You should be able to access response.data():

    private GraphQLCall.Callback<ListTodosQuery.Data> todosCallback = new GraphQLCall.Callback<ListTodosQuery.Data>() {
        @Override
        public void onResponse(@Nonnull Response<ListTodosQuery.Data> response) {
            Log.i("Results", response.data().listTodos().items().toString());
            // do something with response.data() here
        }
        // ...
    };
    ```