Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
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.
New Terms:
- 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
Further Reading:
Tutorial: Getting started with GraphQL queries and mutations, by Tim Lucas
-
0:05
So you've gotten your first taste of GraphQL.
-
0:07
Now we're going to dive in and understand the different parts that make up a query.
-
0:12
In this video, we'll briefly go over each part before explaining them in more detail
-
0:17
in the videos that follow.
-
0:19
At its most basic, a query is composed of three parts,
-
0:23
the query declaration, the endpoint, and the fields.
-
0:27
The query declaration tells GraphQL that we'll only be retrieving information and
-
0:32
not making any changes.
-
0:35
In the curly braces following the query declaration,
-
0:38
we specify which endpoint or endpoints we'd like to call.
-
0:43
In this case, we're calling the topMoviebyRevenue endpoint,
-
0:47
which will return the top earning movie we have in our backend.
-
0:51
In the curly braces following the endpoint name,
-
0:54
we specify the fields we want returned for that endpoint.
-
0:58
This is how we tell GraphQL to include or
-
1:01
exclude certain properties from our response.
-
1:05
So that's the basic anatomy of a query.
-
1:07
In the next video,
-
1:09
you'll learn how to tell GraphQL which fields you want included in your response.
You need to sign up for Treehouse in order to download course files.
Sign up