With arguments, drill down into specific fields to get specific data. The API describes which arguments certain fields can accept. Filter the data based on the arguments.
- [Narrator] By querying fields, we've already…been able to gather a ton of useful data.…With arguments, we can drill down…into specific fields to select specific data.…In GraphQL, every field and every nested object…can have its own set of arguments.…Viewer doesn't have any arguments,…so we're going to replace this query…with one for repositoryOwner.…So when I hit Control and Space,…we're going to notice that repositoryOwner…is about halfway down there.…
Excellent.…So when we want to add any arguments,…we're going to use these parentheses,…then I'm going to use the login argument,…and I'm going to set this equal to the repositoryOwner…that I want to look up.…So here we're going to look for Eve Porcello.…And then we're going to continue our query…as we would before.…Now, inside of our repositoryOwner query,…we're going to look for ID,…we're going to grab the value of path,…as well as the value for URL.…
Awesome!…So when I click play on this, it's going to return…the ID, the path, and the URL…for this particular repositoryOwner.…
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