API Mashup: Combining APIs using GraphQL Schema Stitching

A presentation at GitHub Universe 2018 in October 2018 in San Francisco, CA, USA by Rouven Weßling

Slide 1

Slide 1

API Mashup Combining APIs using GraphQL Schema Stitching By Rouven Wessling

Slide 2

Slide 2

Hi, I’m Rouven Developer Evangelist, lover of APIs and cake @RouvenWessling

Slide 3

Slide 3

Slide 4

Slide 4

Don’t let a CMS get in the way of shipping software. Contentful provides a content infrastructure that enables teams to power content in any digital product.

Slide 5

Slide 5

5 Let’s talk about APIs

Slide 6

Slide 6

I like to call APIs “Lego for Developers” Image by Arto Alanenpää CC-BY-SA 4.0 https://commons.wikimedia.org/wiki/File:Lego_dublo_arto_alanenpaa_5.JPG

Slide 7

Slide 7

Developers ❤ APIs @RouvenWessling

Slide 8

Slide 8

GraphQL A short introduction @RouvenWessling

Slide 9

Slide 9

GraphQL Advantages • • • • • • Strongly typed schema Introspectable Get just the data you want Get all the data you want Frontend-driven data selection Composable @RouvenWessling

Slide 10

Slide 10

GraphQL https://medium.com/airbnb-engineering/reconciling-graphql-and-thrift-at-airbnb-a97e8d290712 @RouvenWessling

Slide 11

Slide 11

GraphQL https://medium.com/airbnb-engineering/reconciling-graphql-and-thrift-at-airbnb-a97e8d290712 @RouvenWessling

Slide 12

Slide 12

GraphQL https://medium.com/airbnb-engineering/reconciling-graphql-and-thrift-at-airbnb-a97e8d290712 @RouvenWessling

Slide 13

Slide 13

GraphQL https://medium.com/airbnb-engineering/reconciling-graphql-and-thrift-at-airbnb-a97e8d290712 @RouvenWessling

Slide 14

Slide 14

Who uses GraphQL? @RouvenWessling

Slide 15

Slide 15

Who uses GraphQL? @RouvenWessling

Slide 16

Slide 16

GraphQL Example Schema @RouvenWessling

Slide 17

Slide 17

GraphQL Example Schema @RouvenWessling Query

Slide 18

Slide 18

GraphQL Example Schema @RouvenWessling Query Result

Slide 19

Slide 19

Hello World @RouvenWessling

Slide 20

Slide 20

Hello World @RouvenWessling

Slide 21

Slide 21

Hello World @RouvenWessling

Slide 22

Slide 22

Hello World @RouvenWessling

Slide 23

Slide 23

Hello World Schema @RouvenWessling

Slide 24

Slide 24

Hello World Schema @RouvenWessling Query

Slide 25

Slide 25

Hello World Schema @RouvenWessling Query Result

Slide 26

Slide 26

Back to the Legos APIs Image by Arto Alanenpää CC-BY-SA 4.0 https://commons.wikimedia.org/wiki/File:Lego_dublo_arto_alanenpaa_5.JPG

Slide 27

Slide 27

Developers ❤ APIs @RouvenWessling

Slide 28

Slide 28

50% of apps use 2-5 APIs

Slide 29

Slide 29

9% use more than 25 APIs* *Global Development Survey Vol. 1 © 2017 Evans Data Corp

Slide 30

Slide 30

That’s a lot of Legos Image by Arto Alanenpää CC-BY-SA 4.0 https://commons.wikimedia.org/wiki/File:Lego_dublo_arto_alanenpaa_5.JPG

Slide 31

Slide 31

You need to know… • …which API holds which data • …how to authenticate against each API • …which fields indicate a reference to another API @RouvenWessling

Slide 32

Slide 32

A herculean task

Slide 33

Slide 33

What if we could have everything in one API?

Slide 34

Slide 34

What if APIs aren’t just legos?

Slide 35

Slide 35

What if APIs are like music?

Slide 36

Slide 36

A mashup is a song that’s created by blending two existing songs together.

Slide 37

Slide 37

A great mashup is a good song in itself, but also leaves it sources recognizable .

Slide 38

Slide 38

Say you have two songs Some indie rock @RouvenWessling

Slide 39

Slide 39

Say you have two songs Some indie rock and an electronic track @RouvenWessling

Slide 40

Slide 40

Say you have two songs Some indie rock and an electronic track can make for a great mashup @RouvenWessling

Slide 41

Slide 41

An Example

Slide 42

Slide 42

We got a lot of Open Source projects And it’s getting hard to keep track of them. @RouvenWessling

Slide 43

Slide 43

We need a dashboard • Pull information from GitHub • Store metadata in Contentful • Pull information from other services, e.g. TravisCI @RouvenWessling

Slide 44

Slide 44

Content model @RouvenWessling

Slide 45

Slide 45

Setup GitHub Contentful Stitching Proxy @RouvenWessling

Slide 46

Slide 46

t ’t s e k a Photo by Lindsay Henwood on Unsplash e L ti t s p e y b t s p e

Slide 47

Slide 47

Step 1 A remote schema Photo by freestocks.org on Unsplash

Slide 48

Slide 48

A remote schema @RouvenWessling

Slide 49

Slide 49

A remote schema @RouvenWessling

Slide 50

Slide 50

A remote schema @RouvenWessling

Slide 51

Slide 51

A remote schema @RouvenWessling

Slide 52

Slide 52

¿Por qué no los dos? Step 2 Photo by Priscilla Du Preez on Unsplash

Slide 53

Slide 53

¿Por qué no los dos? @RouvenWessling

Slide 54

Slide 54

¿Por qué no los dos? @RouvenWessling

Slide 55

Slide 55

¿Por qué no los dos? @RouvenWessling

Slide 56

Slide 56

¿Por qué no los dos? @RouvenWessling

Slide 57

Slide 57

Schemas GitHub @RouvenWessling Contentful

Slide 58

Slide 58

Problem Photo by Joao Tzanno on Unsplash

Slide 59

Slide 59

Our schemas conflict GitHub @RouvenWessling Contentful

Slide 60

Slide 60

Step 3 Schema transformation Photo by Suzanne D. Williams on Unsplash

Slide 61

Slide 61

Schema transformation @RouvenWessling

Slide 62

Slide 62

Schema transformation @RouvenWessling

Slide 63

Slide 63

Schema transformation @RouvenWessling

Slide 64

Slide 64

Schemas transformed GitHub @RouvenWessling Contentful

Slide 65

Slide 65

Step 4 Snitches get stitches

Slide 66

Slide 66

Snitches get stitches @RouvenWessling

Slide 67

Slide 67

Snitches get stitches @RouvenWessling

Slide 68

Slide 68

Snitches get stitches @RouvenWessling

Slide 69

Slide 69

Snitches get stitches @RouvenWessling

Slide 70

Slide 70

Too Easy? Photo by Alain d'Alché on Unsplash

Slide 71

Slide 71

Snitches get stitches - part 2 @RouvenWessling

Slide 72

Slide 72

Snitches get stitches - part 2 @RouvenWessling

Slide 73

Slide 73

Snitches get stitches - part 2 @RouvenWessling

Slide 74

Slide 74

Snitches get stitches - part 2 @RouvenWessling

Slide 75

Slide 75

Snitches get stitches - part 2 @RouvenWessling

Slide 76

Slide 76

Schemas stitched GitHub @RouvenWessling Contentful

Slide 77

Slide 77

Bonus Enrich data Photo by Boudewijn Huysmans on Unsplash

Slide 78

Slide 78

Enrich data @RouvenWessling

Slide 79

Slide 79

Enrich data @RouvenWessling

Slide 80

Slide 80

Demo

Slide 81

Slide 81

Stop treating your APIs like silos. Photo by David Pennington on Unsplash

Slide 82

Slide 82

Use schema stitching to allow developers to seamlessly access data across APIs.

Slide 83

Slide 83

And make some music.

Slide 84

Slide 84

ROUVEN WEßLING Twitter: @RouvenWessling Email: rouven@contentful.com

Slide 85

Slide 85

Come work with me West Coast Evangelist based in the SF Bay Area Email: rouven@contentful.com

Slide 86

Slide 86

ROUVEN WEßLING Twitter: @RouvenWessling Email: rouven@contentful.com