Course info
Aug 19, 2016
2h 10m

Want to get up and running with building and consuming GraphQL APIs? In this course, Building Scalable APIs with GraphQL, you'll learn what separates GraphQL from other languages and API runtimes, like REST APIs, as well as what problems GraphQL solves, and how to use it for declarative data communication. This course is a good place to start for learning GraphQL, but to get the most from this course, you should have some experience with JavaScript and with databases, like MongoDB and PostgreSQL. You'll learn how to create a GraphQL schema and how to use it via any interface, including an HTTP-based one. You'll learn about the different features of the GraphQL language as well as how to build them in a GraphQL server. Next, you'll learn to use multiple databases with GraphQL, how to model relationships between different entities and collections, and how to use caching and batching via tools like Dataloader to avoid extra queries to the database and to solve problems like the N+1 queries problem. Finally, you'll learn how to work with promises, mutations, union types, and how to use database views with GraphQL. By the end of this course, you'll know how to build and consume a GraphQL API, and how to do so efficiently.

About the author
About the author

Samer Buna is a polyglot coder with years of practical experience in designing, implementing, and testing software, including web and mobile applications development, API design, functional programming, optimization, system administration, databases, and scalability. Samer worked in several industries including real estate, government, education, and publications

More from the author
Node.js: Getting Started
3h 29m
Sep 11, 2018
Advanced React.js
3h 54m
Jul 21, 2017
React.js: Getting Started
1h 43m
Apr 12, 2017
More courses by Samer Buna
Section Introduction Transcripts
Section Introduction Transcripts

GraphQL Query Language
Welcome back. The GraphQL Query Language is designed around flexible syntax that is easy to read and understand. In this module, we'll explore the language syntax and learn the different features it supports. We'll first talk about fields and types in more details, explore the use of GraphQL variables, see how to customize the server behavior with directives, and also with aliases. We'll talk about fragments which I think is one of the most important features to understand about GraphQL. And we'll end this module by exploring how to write and execute a GraphQL mutation operation.

GraphQL Runtime
Now that we know how to speak the GraphQL language as a client, it's time to learn how to create a server that understands the same language. We are going to build a real data API for a naming-contest application. This is a simple application where users can create a contest to name something, like a book or a blog, or even a company. Ideally they'll offer some kind of reward for a winning name, and other users of the application can propose names and vote on names. I have implemented this application before, long time ago, and it's running under Bootname. com. It's mostly server-rendered HTML with a little bit of jQuery that uses a RESTful APIs. After designing the new GraphQL API for this idea in this course, I am hoping to rewrite Bootname. com at some point to actually use this new GraphQL API. To build an API, we first need to have some sources of data. We will be using two different databases in this course. Postgres, which is a free open source relational databases (it's just like MySQL, but much better). We will be using Postgres to store all of our transactional data. We'll also use MongoDB, the community edition, which is also free and open source. MongoDB is as NoSQL, document-oriented database. We'll use it to store aggregate information about our data, like counts and averages. It's not unusual to have a situation like this in a real project where you have to read data from multiple sources. Since we'll be using the GraphQL JavaScript implementation from Facebook, you'll also need to have the latest Node. js installed on your system to follow along. If you don't have Node, Postgres, or Mongo, you should stop the course here and go install them first.

Data Loader and GraphQL Mutations
In the last module, we started the implementation of the GraphQL API server for this data structure. We've so far worked with two tables in Postgres and one collection in Mongo. In this module, we'll continue implementing the rest of the API for this data structure, and implement mutations to add a contest and propose a name on a contest. We'll also see how to solve the N+1 problem and avoid extra database queries in general in the GraphQL executor. We'll see how to work with database views and how to create and use Unions to model multiple GraphQL types under one type.