Anatomy of a Query1:14 with Isaac Lee Morris
In this video, we will go over the different parts that make up a GraphQL query, before diving into each one in more detail in the videos that follow.
- Declaration - The keyword which starts every GraphQL query
- Endpoint - A section of a GraphQL backend responsible for returning a specific piece of all the data available
Tutorial: Getting started with GraphQL queries and mutations, by Tim Lucas
So you've gotten your first taste of GraphQL. 0:05 Now we're going to dive in and understand the different parts that make up a query. 0:07 In this video, we'll briefly go over each part before explaining them in more detail 0:12 in the videos that follow. 0:17 At its most basic, a query is composed of three parts, 0:19 the query declaration, the endpoint, and the fields. 0:23 The query declaration tells GraphQL that we'll only be retrieving information and 0:27 not making any changes. 0:32 In the curly braces following the query declaration, 0:35 we specify which endpoint or endpoints we'd like to call. 0:38 In this case, we're calling the topMoviebyRevenue endpoint, 0:43 which will return the top earning movie we have in our backend. 0:47 In the curly braces following the endpoint name, 0:51 we specify the fields we want returned for that endpoint. 0:54 This is how we tell GraphQL to include or 0:58 exclude certain properties from our response. 1:01 So that's the basic anatomy of a query. 1:05 In the next video, 1:07 you'll learn how to tell GraphQL which fields you want included in your response. 1:09
You need to sign up for Treehouse in order to download course files.Sign up