Explore Refactored GraphQL Queries

Eve Porcello
InstructorEve Porcello
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 3 years ago

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.

Instructor: [00:00] 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 https://funded-pet-library.moonhighway.com.

[00:13] 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.

[00:28] 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.

[00:43] 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.

[00:54] 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.

egghead
egghead
~ 43 minutes ago

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

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

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!

Markdown supported.
Become a member to join the discussionEnroll Today