Give queries a custom name that describes what the query does. Eve describes anonymous queries and compares them to those that have operation names.
- [Narrator] So far, we've been querying…the GitHub API using unnamed queries.…For example, this query is going to look for…the first five members in the Facebook organization.…We will look under the organization key.…We're going to look for a login of Facebook.…And then we're going to look for the ID for the name.…And then for members, we'll pull the first five of them.…And then from here, we're going to look for just the name.…
Perfect.…So this syntax here is actually a shorthand.…We're omitting the optional query keyword…from line 1.…If we add the query keyword,…the return results are going to be exactly the same.…If you've ever worked with anonymous functions…in your programming language of choice,…this is a similar concept.…The query works, but it might be…a little harder to find this query…in a sea of others in your code base.…As an alternative, you can create…an operation name, or query name,…to distinguish queries from one another.…
Doing so is pretty simple.…We're just going to add the name of the query…
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