Introduction to GraphQL

Introduction to GraphQL GraphQL Exploration Exercise


This course has been updated! We now recommend you take the Server-Side GraphQL in Node.js course.

Check out a free preview of the full Introduction to GraphQL course:
The "GraphQL Exploration Exercise" Lesson is part of the full, Introduction to GraphQL course featured in this preview video. Here's what you'd learn in this lesson:

Students are instructed to set aside 10 minutes to explore the code, and the GraphQL playground.

Get Unlimited Access Now

Transcript from the "GraphQL Exploration Exercise" Lesson

>> Scott Moss: So that's just a super basic example of GraphQL. I'm sure you guys have a lot of questions about what's going on, and that's the whole point of this course, is we're gonna dive through all the things that I just did plus more in more detail to figure out what's actually happening.

[00:00:13] But in the meantime, what I want you to do is take what I did and add some more types to your cat or whatever you did, or maybe even add another type. And see if you can make some more queries, or maybe add some more fields to this cat, and don't forget to update your resolvers to take advantage of that.

[00:00:30] For instance, if I was gonna add another field on cat called age, and it's a number or integer,
>> Scott Moss: And if I save this, let the server rebuild, just to show you what will happen if I don't update my resolver. And I come back here, I'll refresh this so I get some nice autocomplete, and now, you can see that I can type an age.

[00:00:55] But because I didn't update my resolver to send back an age, actually this will be fine, cuz I didn't put a requirement on it. Yeah, let me put a requirement on it.
>> Scott Moss: Okay, so now if I go back and I try to execute this I'll get an error, because I didn't update my resolver to send back an age, and age is supposed to be required.

[00:01:18] So as you can see, it starts to get very complicated. But just play around with it. I didn't tell you about any of the types, so you can just use strings for everything. You saw that I used something called int, you can try that. But just see if you can add some fields, add some more stuff to the resolver down here,