From the course: Learning GraphQL
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Handling query arguments - GraphQL Tutorial
From the course: Learning GraphQL
Handling query arguments
- [Instructor] Another really important thing to know about GraphQL is that we can create queries that have filters. So, we'll create one of these for our lift. So, we'll call this one findLiftByID. Again, we're always striving to be as clear as possible when communicating about these types, so you could call it findLiftByID, liftByID, but just think about yourself later when you're trying to query this API. Think about others who are consuming it. You probably want to be as clear and descriptive as possible. The way that this looks in the schema is we're going to create that name, and then we're going to pass in an argument. So, we'll say ID, and then we'll give it a type. And then from here we can return a lift. So it's going to be looking for that shape. Now, in order to grab that lift, we need to make a resolver that's going to loop over those values and find the correct one. So, that's going to look like this. We'll say findLiftByID. This is going to be set to a nice little…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Setting up a GraphQL server with Apollo Server4m 18s
-
(Locked)
Writing a query resolver3m 14s
-
(Locked)
Creating a custom object3m 6s
-
(Locked)
Adding an enumeration type1m 37s
-
(Locked)
Handling query arguments3m 29s
-
(Locked)
Challenge: Creating a Trail type49s
-
(Locked)
Solution: Creating a Trail type4m 13s
-
(Locked)
-
-