Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Change Check In Status with a GraphQL Mutation

    Eve PorcelloEve Porcello
    graphqlGraphQL

    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.

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    Instructor: 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.

    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.

    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.

    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.

    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.

    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.

    Discuss

    Discuss