GraphQL - Building a next generation API (Free)

This is a guest lecture done at the Faculty of Computer and Information Science in Ljubljana for students that are enrolled into Web Technologies.

First we dive into REST (a quick theoretical summary) and then we show a service built on NodeJS and MongoDB which contains simple REST endpoints for a blog.

After that we check the advantages and disadvantages of REST and talk about how GraphQL came to be. We explain the theory behind it and how it works and then we show an Apollo Server implementation which connects to the REST service we built earlier.

After the break we dive into the theoretical aspects of GraphQL and open topics in that area, these include language formalization for easier analysis and caching.

Part 1: Explaining REST with live coding, REST vs GraphQL and GraphQL with live coding

Introduction (0:00)

Telling the agenda and breaking into the mood.

Introduction into REST (8:30)

We quickly describe how REST works and talk about building a simple blog application backend.

Live coding (11:59)

We do some live coding - we show the pieces we already have for our REST service and complete our endpoints using the Express framework on NodeJS, MongoDB for our database and Swagger for our documentation.

Checking out the endpoints (29:59)

A summary of how many endpoints we made just for fetching our data. We present some of the disadvantages of fetching data on the frontend and how this affect frontend developers.

Intro into how GraphQL came into existence (36:08)

Talking about how Facebook had problems switching to mobile and what triggered the construction of GraphQL.

Looking at our application in a graph-like way (41:55)

Trying to transform our little blog application in a graph representation using nodes as our models.

GraphQL explaining the chunks (45:28)

We explain how GraphQL is structured, we show what a schema is and what queries, mutations, resolvers and subscriptions are on our little blog example.

Live coding (58:27)

We fill in some code for our blog application using Apollo Server. Apollo Server will use the RestDataSource to communicate with our blog rest service. We also check out GraphiQL.

Q & A (1:15:28)

Some Q & A regarding GraphQL.

Part 2: Academia perspective - How to formalize GraphQL and do analysis

Formalization of GraphQL (1:22:16)

We talk a little about prof. Olaf Hartig and how he is making the first steps into formalizing GraphQL as a language to do analysis on it. We also show how he constructed two algorithms that allows us to solve the query depth problem more effectively.

Note: Some corrections for this part - I was kindly reminded by prof. Hartig that this was a joint venture with prof. Jorge Perez and that he is actually from Sweden.

Caching (1:33:06)

We talk about caching and how graph based analysis could help with that.

The end (1:35:04)

From here on we talk about other challenges and do the rest of the Q&A.

Sample project code: