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
Become a member
to unlock all features

Level Up!

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


    Explore Refactored GraphQL Queries


    In this lesson, we’ll look at a refactored Pet Library which includes a range of new queries that aim to minimize argument usage and naming collisions that require aliases. To follow along with these queries, go to the Pet Library GraphQL Playground.



    Become a Member to view code

    You must be a Pro 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
    orLog In




    Instructor: The pet library just got some funding, some VC money, so we're going to open up our browser and head over to the new version of the app. We're going to go to

    You'll notice our new endpoint here at the center of the screen. With a larger budget comes more engineers and some enhancements to our API, one of which is that we have some more specific queries that may be easier to track.

    Let's write our query for totalPets. We'll see 25, but we have these new queries here, availablePets. We also have checkedOutPet, and we can access those values without having to use any filters or send any arguments.

    We also have another query here called customersWithPets. Now, if we look at this in the schema, we'll see that this query will return a list of all of the customers who currently have pets checked out.

    This refactor gives us access to the same data, but we don't have to use as many arguments, and we've moved a lot of the logic of filtering, sorting to the server instead of having to handle this in the playground.