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.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!