Include as many variables as you'd like in your queries. For extra flexibility, Eve Porcello demonstrates how to incorporate variables of different types.
- [Narrator] In the last video,…we created a single variable for the login argument.…Let's update this query to include…a couple different query variables.…First, I'm going to create a variable called n.…And n should always be an int.…So we'll say n is set to int,…and it's going to be required, so…we'll use the exclamation point.…Next up, instead of using the first five,…we're going to say that the first n…should be sent to the members as an argument.…
Next up, I'm going to add another query variable.…So like I mentioned before, as soon as I type anything,…it's going to pop up here.…And we're going to set this to 5.…Let's also adjust our operation name here on line 1.…Instead of looking for the first five,…we'll set this to the FirstNOrgMembers.…So let's go ahead and hit Play,…and we should see those same results.…If we were to change this to, let's say, 20,…this is going to find the first 20,…giving us a little bit more flexibility here.…
Of course, we can always adjust our login value here,…so if we wanted to go back to Facebook,…
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