WTF is GraphQL?

Eve Porcello
InstructorEve Porcello

Share this video with your friends

Send Tweet
Published 3 years ago
Updated 10 months ago

GraphQL is a query language for your API, which means that you can query or ask for the data that you need in one request, and you'll get one response as JSON. In this lesson, we'll introduce the key features of GraphQL.

Instructor: [00:00] GraphQL is a query language for your API, which means that you can query, or ask, for the data that you need in one request, and you'll get one response as JSON. To test the GraphQL service, you can use GraphQL Playground.

[00:12] GraphQL Playground is an in-browser API explorer. What Postman is to Rest, GraphQL Playground is to GraphQL. GraphQL has one endpoint, which you'll see here in the center. On the left, I'll write a query, and on the right, I'll get some data back.

[00:27] Then every field I ask for returns some data. Each of these fields maps to a function on the server called a resolver. Resolvers return data for a field. GraphQL isn't tied to any specific database, so resolvers can get this data from anywhere, from a database, from a Rest API, a JSON file, anywhere.

[00:49] GraphQL is a type system for your API, which means that you can define your API's types in a document called a schema. The schema provides documentation to the playground, and I can view all of the types and queries available on this service under the schema panel.

[01:05] To change data, we'll use a GraphQL mutation. If I wanted to set the status of a chairlift, I'd send the ID of the chairlift in the new status. This will change the status of that lift.

[01:16] Finally, you can listen for data changes with GraphQL subscriptions. If I send a subscription for lift status change, it's going to listen for any changes in lift status, and report those back to me.

[01:29] To recap, GraphQL is a query language for your API. It's self-documenting, and isn't tied to any specific database or data source. You get data by sending queries, you change data with mutations, and you listen for data changes with subscriptions.

Aizaz Khaja
Aizaz Khaja
~ 3 years ago

A very good, succinct summary of GraphQL!

Nathan Birrell
Nathan Birrell
~ 3 years ago

πŸ‘πŸΌπŸ‘πŸΌπŸ‘πŸΌ

Mark Shust
Mark Shust
~ 3 years ago

Wonderful quick summary!

Yusuf
Yusuf
~ 3 years ago

:dancer: