Slide 1

Slide 1 text

Marc-Andre Giroux - GraphQL Galaxy 2020 It Depends Examining GraphQL Myths & Assumptions

Slide 2

Slide 2 text

Marc-Andre Giroux GitHub Montreal, Canada

Slide 3

Slide 3 text

It Depends

Slide 4

Slide 4 text

Caching We’re thinking of using GraphQL as our API Terrible mistake! Say bye to caching.

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

https://tools.ietf.org/html/rfc7234

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Solutions must be looked at from a specific context

Slide 11

Slide 11 text

There’s some truth to it

Slide 12

Slide 12 text

Conventions

Slide 13

Slide 13 text

Flexibility vs Cache Hits

Slide 14

Slide 14 text

Performance We’re thinking of using GraphQL as our API Cool! Why are you choosing GraphQL over other API styles? Because… performance!

Slide 15

Slide 15 text

Is GraphQL faster than ____?

Slide 16

Slide 16 text

GET /user { viewer { name age } }

Slide 17

Slide 17 text

The trade-off, though, is that a uniform interface degrades efficiency, since information is transferred in a standardized form rather than one which is specific to an application's needs. The REST interface is designed to be efficient for large-grain hypermedia data transfer, optimizing for the common case of the Web, but resulting in an interface that is not optimal for other forms of architectural interaction. https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm

Slide 18

Slide 18 text

One Query to Rule them All

Slide 19

Slide 19 text

viewer { contributionsCollection { commitContributionsByRepository { contributions { nodes { commitCount } } } } repositories(first: 100) { nodes { name issues(first: 100) { nodes { body } } } } issues(first: 100) { edges { node { author { login } } } }

Slide 20

Slide 20 text

@defer & @stream

Slide 21

Slide 21 text

viewer { contributionsCollection { commitContributionsByRepository { contributions { nodes { commitCount } } } } repositories(first: 100) @defer { nodes { name issues(first: 100) { nodes { body } } } } issues(first: 100) @defer { edges { node { author { login } } } }

Slide 22

Slide 22 text

Full Circle?

Slide 23

Slide 23 text

Make Tradeoffs, Mitigate Downsides

Slide 24

Slide 24 text

Predictability

Slide 25

Slide 25 text

BFF The Backend-For-Frontend Pattern

Slide 26

Slide 26 text

https://samnewman.io/patterns/architectural/bff/

Slide 27

Slide 27 text

BFFs are not only about representation

Slide 28

Slide 28 text

Autonomy

Slide 29

Slide 29 text

type User { name: String! age: Int! Friends: [User!]! }

Slide 30

Slide 30 text

type User { name: String! nameForAndroid: String! age: Int! ageForThisOneClient: Int! friends: [User!]! friendsForXBOX: [XBOXFriend!]! }

Slide 31

Slide 31 text

Complete Separation

Slide 32

Slide 32 text

“One Graph”

Slide 33

Slide 33 text

type User { name: String! nameForAndroid: String! age: Int! ageForThisOneClient: Int! friends: [User!]! friendsForXBOX: [XBOXFriend!]! }

Slide 34

Slide 34 text

It Depends

Slide 35

Slide 35 text

Why this is important

Slide 36

Slide 36 text

We want GraphQL to succeed

Slide 37

Slide 37 text

We want developers using GraphQL to succeed.

Slide 38

Slide 38 text

In which context?

Slide 39

Slide 39 text

Compared to what?

Slide 40

Slide 40 text

What are the trade-offs?

Slide 41

Slide 41 text

Thank You! @__xuorig__ book.productionreadygraphql.com twitch.tv/graphqlfm - youtube.com/c/GraphQLFM/ (30% OFF GRAPHQLGALAXY30)