GraphQL

Puzzle Tech Workshop 2018

https://slides.com/hupf/tws18-graphql/live

Agenda

Introduction

Build a GraphQL service with GraphQL.js

Open hacking

Introduction

History

Developed by Facebook 2012

Public release 2015

Free Software

GraphQL.js (reference implementation) = MIT License

 

Specification:

https://facebook.github.io/graphql/

Cross-plattform

Servers

C# / .NET
Clojure
Elixir
Erlang
Go
Groovy
Java
JavaScript
PHP
Python
Scala
Ruby

Clients

C# / .NET
Clojurescript
Go
Java / Android
JavaScript
Swift / Objective-C iOS
Python

Pros

Strongly typed schema

Clients define the structure of the data required

Rich open-source ecosystem

Cross-platform

Integrates in existing code and data

Introspective

Concept

Extract trees from the app data graph

Source: https://blog.apollographql.com/graphql-explained-5844742f195e

GraphQL is...

...an application-layer protocol

...a query language for your API

...a server-side runtime for executing queries

...a type system you define for your data

GraphQL isn't...

...a graph database

...tied to any specific database or storage engine

Title Text

Source: https://graphql.org/learn/thinking-in-graphs/

Supports

Reading data = Queries

Writing data = Mutations

Realtime updates = Subscriptions

Clients

Send HTTP requests

 

Complex clients (e.g. Relay):

Automatically handle batching, caching, and other features

HTTP Requests

Either:

GET (query string)

 

Or:

POST (JSON body)

HTTP Responses

JSON body:

{
  "data": { ... },
  "errors": [ ... ]
}

GraphQL vs. REST

REST = architectural concept

GraphQL = query language, specification and collection of tools

REST = leverages HTTP

GraphQL = invents own conventions

REST = resources

GraphQL = entity graph

REST = entities identified by URLs

GraphQL = single endpoint /graphql

REST = schema?

GraphQL = schema!

Hands on

GraphQL Miniworkshop

By Mathis Hofer

GraphQL Miniworkshop

  • 789