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

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…

Contents