Make queries more dynamic by adding variables for argument values. The variables panel of the interface makes the process of incorporating these much simpler.
- [Instructor] In the previous video,…we looked at how to create an operation name…to keep better track of our queries.…Now, we're going to make these queries more dynamic…by incorporating query variable definitions.…Each time I request these first five organization members,…I'm getting the details about Facebook,…because that's what I have hard-coded as this argument.…If I want to add some more flexibility,…I can make login a variable.…So the first thing I need to do here on line 1,…is add a set of parenthesis,…and the argument I'm going to send here…is going to reflect the variable.…
So we're going to say login,…and this is going to be a type of string,…and this is going to be required.…Now at this point, we're going to,…instead of using the string value for Facebook,…we're going to set this equal to login.…Therefore, I could pass in any string as a login value…and that's going to pull up those first few org members…for that particular login.…Awesome.…So the final step we need to take here…is we need to utilize this panel…
In this course, learn how to get started with GraphQL. Eve Porcello walks through the basics of this query language, diving into the data fetching specification, and helping you get up to speed with the syntax and vocabulary of GraphQL. Eve explains how to create basic queries, including how to work with arguments and multiple fields. She also goes into complex techniques for handling data, including working with aliases, fragments, and pagination. Plus, she covers how to edit and transform data with mutations.
- Learning about the origins of GraphQL
- Learning about how GraphQL makes data fetching and updating easier
- Creating basic queries
- Using multiple fields
- Understanding schemas
- Handling data
- Drilling down into nested fields with a query
- Adding variables for argument values
- Creating mutations
- Adding a reaction mutation