From the course: Learning GraphQL (2021)

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Adding variables

Adding variables

- [Instructor] Currently our filters are inline. In other words, we're adding these statuses inline into this query, but it's also possible to create variables for anything we're sending into these queries. Sending variables means that I can pass dynamic data into the query at runtime. Let's say I had a dropdown or something where I wanted to let our users select the status. I could set up our query to make this possible. So, here on line one, here's what I'll do. I'm going to use the dollar sign and status. And then this is our GraphQL variable. We know it's a variable because of the dollar sign and we can call these whatever we want. But the important thing is we need to set the type appropriately. So, I'll say LiftStatus. And a very important thing that we need to do is to match the status exactly. So, LiftStatus doesn't have an exclamation mark. If we added one, we would break the query. Now, that I've done this,…

Contents