```java private GraphQLRequest getPostWithCommentsRequest(String id) { String document = "query getPost($id: ID!) { " + "getPost(id: $id) { " + "id " + "title " + "rating " + "status " + "comments { " + "items { " + "id " + "postID " + "content " + "} " + "} " + "} " + "}"; return new SimpleGraphQLRequest<>( document, Collections.singletonMap("id", id), Post.class, new GsonVariablesSerializer()); } ``` ```kotlin private fun getPostWithCommentsRequest(id: String): GraphQLRequest { val document = ("query getPost(\$id: ID!) { " + "getPost(id: \$id) { " + "id " + "title " + "rating " + "status " + "comments { " + "items { " + "id " + "postID " + "content " + "} " + "} " + "} " + "}") return SimpleGraphQLRequest( document, mapOf("id" to id), Post::class.java, GsonVariablesSerializer()) } ``` Then query for the Post: ```java Amplify.API.query(getPostWithCommentsRequest("[POST_ID]"), response -> Log.d("MyAmplifyApp", "response" + response), error -> Log.e("MyAmplifyApp", "error" + error) ); ``` ```kotlin Amplify.API.query(getPostWithCommentsRequest("[POST_ID]"), { Log.d("MyAmplifyApp", "Response = $it") }, { Log.e("MyAmplifyApp", "Error!", it) } ) ``` ```kotlin try { val response = Amplify.API.query(getPostWithCommentsRequest("[POST_ID]")) Log.d("MyAmplifyApp", "Query response = $response") } catch (error: ApiException) { Log.e("MyAmplifyApp", "Query error", error) } ```