<BlockSwitcher>
<Block name="Java">

```java
private GraphQLRequest<Post> 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());
}
```

</Block>
<Block name="Kotlin">

```kotlin
private fun getPostWithCommentsRequest(id: String): GraphQLRequest<Post> {
    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())
}
```

</Block>
</BlockSwitcher>

Then query for the Post:

<BlockSwitcher>
<Block name="Java">

```java
Amplify.API.query(getPostWithCommentsRequest("[POST_ID]"),
    response -> Log.d("MyAmplifyApp", "response" + response),
    error -> Log.e("MyAmplifyApp", "error" + error)
);
```

</Block>
<Block name="Kotlin - Callbacks">

```kotlin
Amplify.API.query(getPostWithCommentsRequest("[POST_ID]"),
    { Log.d("MyAmplifyApp", "Response = $it") },
    { Log.e("MyAmplifyApp", "Error!", it) }
)
```

</Block>
<Block name="Kotlin - Coroutines">

```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)
}
```

</Block>
</BlockSwitcher>
