Reasonable GraphQL

@VladimirNovick

GDE & Independent Consultant

Web / Mobile / VR / AR / IoT

vnovick.com

REST vs GraphQL

https://swapi.co/api/planets/1

https://swapi.co/api/species/1

https://swapi.co/api/vehicles/1

https://swapi.co/api/films/1

https://swapi.co/api/people/1

https://swapi.co/api/spaceships/1

REST in ReasonML

Fetching...

bs-fetch

Decoding...

bs-json

So where is the problem?

It's demo time

Why REST is bad?

  • No knowledge of data types
  • Even minor changes can introduce breaking changes
  • No stability

GraphQL

A query language for your API

GraphQL SDL

Resolvers

It's demo time

How we can get started

Installations

Send Introspection query

saves graphql_schema to disk

Create Apollo client

Wrap component with Provider

Define query by using graphql_ppx

Create query component

Wrap UI in created query component

Treat all optional types

It's demo time

It's demo time

Authentication

Tips and Tricks

use jsConverter

use bsRecord

https://github.com/jaredly/get_in_ppx

Thank You

@VladimirNovick