Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Introduction to GraphQL!
You have completed Introduction to GraphQL!
Preview
In this video, we’ll go over GraphQL at a high level, and learn about some of its more exciting features.
New Terms:
- Schema - A special kind of document that describes how a GraphQL endpoint can receive and send information
- Query Language - The syntax we use to write GraphQL queries that retrieve data from an endpoint
- Self-documenting API - An API that can be easily understood just by reading its schema -- no extra documentation needed
Further Reading:
GraphQL Documentation: Introduction to GraphQL
GraphQL Documentation: Schemas and Types
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
[MUSIC]
0:00
Hi there, I'm Isaac Lee and
welcome to introduction to GraphQL.
0:04
In this course,
I'll show you a whole new method for
0:10
fetching data from your backend.
0:12
You'll learn how to request data in the
exact shape we wanna get it, make changes
0:14
to our data, and use some handy tricks
to make our code even more reusable.
0:19
GraphQL is composed of two main parts,
the query language,
0:24
which is used to request data, and the
framework that processes these queries.
0:28
In this course,
we'll be focusing on the query language,
0:34
which is the meat of GraphQL.
0:36
GraphQL's unique language allows
us to specify the exact format
0:39
that we want to receive our data in.
0:43
Other benefits of GraphQL will
include self documenting APIs,
0:46
the ability to fetch deeply nested
data in a single request and
0:50
the ability to mount GraphQL
in front of any existing API.
0:54
So what exactly do we mean
by self documenting API?
0:59
This just mean that by
looking at the API's schema,
1:03
it's easy to understand what the data
coming out of it will look like.
1:06
Let's take a quick look
at an example schema.
1:11
As you can see,
the schema looks a lot like JSON,
1:14
without knowing anything
else like GraphQL.
1:18
I can guess that this movie
object will have an ID field,
1:20
a title field, a tagline field,
and the studio field.
1:24
Since the schema is expressed
in a format we're familiar with,
1:29
you can easily predict which queries
will work and which ones won't.
1:32
Building on this concept makes fetching
deeply nested data easier than ever.
1:37
If we need data that is nested inside
of another object, like Studio for
1:43
example, we can just look at
the schema for the nested object.
1:47
Which in this case, is the Studio type.
1:50
And right away, we know which fields
are available for our response.
1:53
Lastly, GraphQL is super
flexible as a backend.
1:58
When it comes to developing new APIs,
you can start from scratch
2:02
with a GraphQL server that communicates
directly with your database.
2:06
However, if you already have an API
that's responsible for communicating with
2:10
your database, you can just bolt
GraphQL right in front of that API.
2:14
GraphQL doesn't care where the data
comes from which makes it useful for
2:19
a wide variety of applications.
2:23
We won't be covering how to implement
a GraphQL backend in this course.
2:25
Just know that when it comes time to,
2:29
GraphQL can be implemented in
just about any environment.
2:31
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up