Following up on the checkOut
mutation from the previous video, we’ll take a closer look at how to check in a pet using a pet id. Then we’ll look at the allCustomers
query and find out the history of pet checkouts for all customers.
To follow along with these queries, go to the Pet Library GraphQL Playground.
Instructor: [00:00] We had a lot of fun with the pet, but now it's time to check them back in. We have another named mutation in the schema called checkin, and this should going to take in the ID of the pet we want to check in.
[00:11] Remember, we need to have our authorization token present in order to do this. Let's check in that same pet that we checked out, S2. The checkin mutation returns an object called checkout. Let's figure out what that is.
[00:26] checkout returns a pet, a checkout date, a check-in date, and whether or not the pet is late. There are a bunch of different metadata fields on that type. Let's look at the name of the pet, get the checkout date, get the check-in date, and whether or not the pet is late.
[00:42] When I click play on this, we should see all of those different fields for our pet. Now that we've checked out and checked in a pet, we can look at this data on this query called allCustomers. We can query username, which should return all of the usernames to us.
[00:56] We see my username here at the bottom. Then I can also add checkout history. Now, checkout history is going to return a list of checkouts. That checkout object we saw before should have all of the pet details.
[01:11] We see the pet details for other folks, and we see Switchblade here toward the bottom. For each of them, we can find the name of the pet and the ID.