Execute Queries within the AWS AppSync Console

nader dabit
Instructornader dabit
Share this video with your friends

Social Share Links

Send Tweet

In this lesson, we’ll execute queries against the new AWS AppSyncGraphQL API, showing how to query for both a single item and a list of items.

Instructor: [00:02] To begin querying for data, we first need to make sure that there's data available in our database to query against. To go ahead and input the data into our database, we'll go ahead and execute a couple of createTodo mutations.

[00:31] Now that the mutations have been executed, we can click on docs and then query to view the available queries. Here we see two available queries, getTodo, which returns a single to-do, and listTodos, which returns an array of to-dos. The first query we'd like to execute is the listTodos query.

[00:52] ListTodos returns a TodoConnection input. TodoConnection contains an items array and a next token that's a string. For our query, we'll only return the array of items. Each item in the items array is a type of to-do which has a property of id, title, and completed. When we execute this query, we should see listTodos return with an array of items.

[01:41] The next query we'd like to execute is getTodo. getTodo takes in an id as as argument and returns a single to-do. To test this out, we'll create a query called get that will execute the getTodo query, passing in the id of the workout to-do.

[02:14] ListTodos also has a filter property that's useful for doing filtering and searching. We'll test this out by creating a listTodos query with a filter that filters on the title with titles only containing the string "workout."

[02:51] It may be useful to filter our to-dos based on the completed value. To test this out, let's go ahead and execute a mutation to update the completed value of one of our to-dos to true.

[03:19] Now we can update our filter to filter on the completed value equal to true.