```java
private GraphQLRequest getTodoRequest(String id) {
String document = "query getTodo($id: ID!) { "
+ "getTodo(id: $id) { "
+ "id "
+ "name "
+ "}"
+ "}";
return new SimpleGraphQLRequest<>(
document,
Collections.singletonMap("id", id),
Todo.class,
new GsonVariablesSerializer());
}
```
```kotlin
private fun getTodoRequest(id: String): GraphQLRequest {
val document = ("query getTodo(\$id: ID!) { "
+ "getTodo(id: \$id) { "
+ "id "
+ "name "
+ "}"
+ "}")
return SimpleGraphQLRequest(
document,
mapOf("id" to id),
Todo::class.java,
GsonVariablesSerializer())
}
```
Then, query for the Todo by a todo id
```java
Amplify.API.query(getTodoRequest("[TODO_ID]"),
response -> Log.d("MyAmplifyApp", "response" + response),
error -> Log.e("MyAmplifyApp", "error" + error)
);
```
```kotlin
Amplify.API.query(getTodoRequest("[TODO_ID]"),
{ Log.d("MyAmplifyApp", "Response = $it") },
{ Log.e("MyAmplifyApp", "Error!", it) }
)
```
```kotlin
try {
val response = Amplify.API.query(getTodoRequest("[TODO_ID]"))
Log.d("MyAmplifyApp", "Query response = $response")
} catch (error: ApiException) {
Log.e("MyAmplifyApp", "Query failed", error)
}
```