Instructor: 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.
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.
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.
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.
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."
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.
Now we can update our filter to filter on the completed value equal to true.