Top Banner
Introduction Origin History Usage Alternatives & useful tools End GraphQL Piotr Sroczkowski Brainhub January 23, 2017 Piotr Sroczkowski GraphQL
101

Introduction to GraphQL

Feb 08, 2017

Download

Software

Brainhub
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

GraphQL

Piotr Sroczkowski

Brainhub

January 23, 2017

Piotr Sroczkowski GraphQL

Page 2: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

Summary I

1 Introduction

2 OriginDIPSemantic triple

3 History

4 UsageHow to setup a GraphQL server?SyntaxTypesBest practices

5 Alternatives & useful tools

6 End

Piotr Sroczkowski GraphQL

Page 3: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

What is GraphQL?

Graph query language

Piotr Sroczkowski GraphQL

Page 4: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

What is GraphQL?

Graph query language

Piotr Sroczkowski GraphQL

Page 5: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

Dependency inversion principle (DIP)

one of SOLID principles

depend on abstraction, not concretion

IMO even abstract class breaks this rule

so we should depend only on interfaces

Piotr Sroczkowski GraphQL

Page 6: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

Dependency inversion principle (DIP)

one of SOLID principles

depend on abstraction, not concretion

IMO even abstract class breaks this rule

so we should depend only on interfaces

Piotr Sroczkowski GraphQL

Page 7: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

Dependency inversion principle (DIP)

one of SOLID principles

depend on abstraction, not concretion

IMO even abstract class breaks this rule

so we should depend only on interfaces

Piotr Sroczkowski GraphQL

Page 8: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

Dependency inversion principle (DIP)

one of SOLID principles

depend on abstraction, not concretion

IMO even abstract class breaks this rule

so we should depend only on interfaces

Piotr Sroczkowski GraphQL

Page 9: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

Dependency inversion principle (DIP)

one of SOLID principles

depend on abstraction, not concretion

IMO even abstract class breaks this rule

so we should depend only on interfaces

Piotr Sroczkowski GraphQL

Page 10: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

DIP in services

DIP is not only in OOP

also in SOA

it’s like joining blocks together

Piotr Sroczkowski GraphQL

Page 11: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

DIP in services

DIP is not only in OOP

also in SOA

it’s like joining blocks together

Piotr Sroczkowski GraphQL

Page 12: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

DIP in services

DIP is not only in OOP

also in SOA

it’s like joining blocks together

Piotr Sroczkowski GraphQL

Page 13: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

DIP in services

DIP is not only in OOP

also in SOA

it’s like joining blocks together

Piotr Sroczkowski GraphQL

Page 14: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

DIP in microservices

it’s not a new paradigm, it’s just an example of SOA

service discovery

Piotr Sroczkowski GraphQL

Page 15: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

DIP in microservices

it’s not a new paradigm, it’s just an example of SOA

service discovery

Piotr Sroczkowski GraphQL

Page 16: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

DIP in microservices

it’s not a new paradigm, it’s just an example of SOA

service discovery

Piotr Sroczkowski GraphQL

Page 17: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

Semantic triple

an RDF (Resouce Description Framework) data model

ex. Alice likes Bob

Piotr Sroczkowski GraphQL

Page 18: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

Semantic triple

an RDF (Resouce Description Framework) data model

ex. Alice likes Bob

Piotr Sroczkowski GraphQL

Page 19: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

Semantic triple

an RDF (Resouce Description Framework) data model

ex. Alice likes Bob

Piotr Sroczkowski GraphQL

Page 20: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

Triplestore

a proposed database for storage of triples

Piotr Sroczkowski GraphQL

Page 21: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

Triplestore

a proposed database for storage of triples

Piotr Sroczkowski GraphQL

Page 22: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

Think in graphs

Why?

UI

Graph algorithms

Piotr Sroczkowski GraphQL

Page 23: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

Think in graphs

Why?

UI

Graph algorithms

Piotr Sroczkowski GraphQL

Page 24: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

Think in graphs

Why?

UI

Graph algorithms

Piotr Sroczkowski GraphQL

Page 25: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

DIPSemantic triple

Think in graphs

Why?

UI

Graph algorithms

Piotr Sroczkowski GraphQL

Page 26: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

GraphQL history

developed internally in Facebook in 2012

publicly released in 2015

Piotr Sroczkowski GraphQL

Page 27: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

GraphQL history

developed internally in Facebook in 2012

publicly released in 2015

Piotr Sroczkowski GraphQL

Page 28: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

GraphQL history

developed internally in Facebook in 2012

publicly released in 2015

Piotr Sroczkowski GraphQL

Page 29: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Node

express-graphqlhttps://github.com/graphql/express-graphql

or graphql-serverhttps://github.com/apollostack/graphql-server

Piotr Sroczkowski GraphQL

Page 30: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Node

express-graphqlhttps://github.com/graphql/express-graphql

or graphql-serverhttps://github.com/apollostack/graphql-server

Piotr Sroczkowski GraphQL

Page 31: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Node

express-graphqlhttps://github.com/graphql/express-graphql

or graphql-serverhttps://github.com/apollostack/graphql-server

Piotr Sroczkowski GraphQL

Page 32: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

The simplest way

1 git clone https:// github.com/apollostack/apollo -

↪→ starter -kit

2 cd apollo -starter -kit

3 git checkout server -only

4 npm install

5 npm start

Piotr Sroczkowski GraphQL

Page 33: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Queries

1 {

2 hero {

3 name

4 }

5 }

1 {

2 "data": {

3 "hero": {

4 "name": "R2 -D2"

5 }

6 }

7 }

Piotr Sroczkowski GraphQL

Page 34: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Queries

1 {

2 hero {

3 name

4 }

5 }

1 {

2 "data": {

3 "hero": {

4 "name": "R2 -D2"

5 }

6 }

7 }

Piotr Sroczkowski GraphQL

Page 35: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Queries

1 {

2 hero {

3 name

4 }

5 }

1 {

2 "data": {

3 "hero": {

4 "name": "R2 -D2"

5 }

6 }

7 }

Piotr Sroczkowski GraphQL

Page 36: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Queries

1 {

2 human(id: "1000") {

3 name

4 height

5 }

6 }

1 {

2 "data": {

3 "human": {

4 "name": "Luke Skywalker",

5 "height": 1.72

6 }

7 }

8 }

Piotr Sroczkowski GraphQL

Page 37: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Queries

1 {

2 human(id: "1000") {

3 name

4 height

5 }

6 }

1 {

2 "data": {

3 "human": {

4 "name": "Luke Skywalker",

5 "height": 1.72

6 }

7 }

8 }

Piotr Sroczkowski GraphQL

Page 38: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Queries

1 {

2 human(id: "1000") {

3 name

4 height

5 }

6 }

1 {

2 "data": {

3 "human": {

4 "name": "Luke Skywalker",

5 "height": 1.72

6 }

7 }

8 }

Piotr Sroczkowski GraphQL

Page 39: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Aliases

1 {

2 empireHero: hero(episode: EMPIRE) {

3 name

4 }

5 jediHero: hero(episode: JEDI) {

6 name

7 }

8 }

1 {

2 "data": {

3 "empireHero": {

4 "name": "Luke Skywalker"

5 },

6 "jediHero": {

7 "name": "R2 -D2"

8 }

9 }

10 }

Piotr Sroczkowski GraphQL

Page 40: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Aliases

1 {

2 empireHero: hero(episode: EMPIRE) {

3 name

4 }

5 jediHero: hero(episode: JEDI) {

6 name

7 }

8 }

1 {

2 "data": {

3 "empireHero": {

4 "name": "Luke Skywalker"

5 },

6 "jediHero": {

7 "name": "R2 -D2"

8 }

9 }

10 }

Piotr Sroczkowski GraphQL

Page 41: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Aliases

1 {

2 empireHero: hero(episode: EMPIRE) {

3 name

4 }

5 jediHero: hero(episode: JEDI) {

6 name

7 }

8 }

1 {

2 "data": {

3 "empireHero": {

4 "name": "Luke Skywalker"

5 },

6 "jediHero": {

7 "name": "R2 -D2"

8 }

9 }

10 }

Piotr Sroczkowski GraphQL

Page 42: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Fragments - input

1 {

2 leftComparison: hero(episode: EMPIRE) {

3 ... comparisonFields

4 }

5 rightComparison: hero(episode: JEDI) {

6 ... comparisonFields

7 }

8 }

9

10 fragment comparisonFields on Character {

11 name

12 appearsIn

13 friends {

14 name

15 }

16 }

Piotr Sroczkowski GraphQL

Page 43: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Fragments - output I

1 {

2 "data": {

3 "leftComparison": {

4 "name": "Luke Skywalker",

5 "appearsIn": [

6 "NEWHOPE",

7 "EMPIRE",

8 "JEDI"

9 ],

10 "friends": [

11 {

12 "name": "Han Solo"

13 },

14 {

15 "name": "Leia Organa"

Piotr Sroczkowski GraphQL

Page 44: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Fragments - output II

16 },

17 {

18 "name": "C-3PO"

19 },

20 {

21 "name": "R2 -D2"

22 }

23 ]

24 },

25 "rightComparison": {

26 "name": "R2 -D2",

27 "appearsIn": [

28 "NEWHOPE",

29 "EMPIRE",

30 "JEDI"

31 ],

Piotr Sroczkowski GraphQL

Page 45: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Fragments - output III

32 "friends": [

33 {

34 "name": "Luke Skywalker"

35 },

36 {

37 "name": "Han Solo"

38 },

39 {

40 "name": "Leia Organa"

41 }

42 ]

43 }

44 }

45 }

Piotr Sroczkowski GraphQL

Page 46: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Variables - input I

1 query HeroNameAndFriends($episode: Episode) {

2 hero(episode: $episode) {

3 name

4 friends {

5 name

6 }

7 }

8 }

Piotr Sroczkowski GraphQL

Page 47: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Variables - output I

1 {

2 "data": {

3 "hero": {

4 "name": "R2 -D2",

5 "friends": [

6 {

7 "name": "Luke Skywalker"

8 },

9 {

10 "name": "Han Solo"

11 },

12 {

13 "name": "Leia Organa"

14 }

15 ]

Piotr Sroczkowski GraphQL

Page 48: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Variables - output II

16 }

17 }

18 }

Piotr Sroczkowski GraphQL

Page 49: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Directives I

1 query Hero($episode: Episode , $withFriends: Boolean !)

↪→ {

2 hero(episode: $episode) {

3 name

4 friends @include(if: $withFriends) {

5 name

6 }

7 }

8 }

Piotr Sroczkowski GraphQL

Page 50: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Mutations I

1 mutation CreateReviewForEpisode($ep: Episode!, $review

↪→ : ReviewInput !) {

2 createReview(episode: $ep , review: $review) {

3 stars

4 commentary

5 }

6 }

Piotr Sroczkowski GraphQL

Page 51: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Inline fragments I

1 query HeroForEpisode($ep: Episode !) {

2 hero(episode: $ep) {

3 name

4 ... on Droid {

5 primaryFunction

6 }

7 ... on Human {

8 height

9 }

10 }

11 }

Piotr Sroczkowski GraphQL

Page 52: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Meta fields I

1 {

2 search(text: "an") {

3 __typename

4 ... on Human {

5 name

6 }

7 ... on Droid {

8 name

9 }

10 ... on Starship {

11 name

12 }

13 }

14 }

Piotr Sroczkowski GraphQL

Page 53: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Types

Scalar types

Enumeration types

Interfaces

Union types

Input types

Piotr Sroczkowski GraphQL

Page 54: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Types

Scalar types

Enumeration types

Interfaces

Union types

Input types

Piotr Sroczkowski GraphQL

Page 55: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Types

Scalar types

Enumeration types

Interfaces

Union types

Input types

Piotr Sroczkowski GraphQL

Page 56: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Types

Scalar types

Enumeration types

Interfaces

Union types

Input types

Piotr Sroczkowski GraphQL

Page 57: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Types

Scalar types

Enumeration types

Interfaces

Union types

Input types

Piotr Sroczkowski GraphQL

Page 58: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Types

Scalar types

Enumeration types

Interfaces

Union types

Input types

Piotr Sroczkowski GraphQL

Page 59: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Scalar types

Int

Float

String

Boolean

Id

You can also define your custom scalar types ex. scalar Date

Piotr Sroczkowski GraphQL

Page 60: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Scalar types

Int

Float

String

Boolean

Id

You can also define your custom scalar types ex. scalar Date

Piotr Sroczkowski GraphQL

Page 61: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Scalar types

Int

Float

String

Boolean

Id

You can also define your custom scalar types ex. scalar Date

Piotr Sroczkowski GraphQL

Page 62: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Scalar types

Int

Float

String

Boolean

Id

You can also define your custom scalar types ex. scalar Date

Piotr Sroczkowski GraphQL

Page 63: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Scalar types

Int

Float

String

Boolean

Id

You can also define your custom scalar types ex. scalar Date

Piotr Sroczkowski GraphQL

Page 64: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Scalar types

Int

Float

String

Boolean

Id

You can also define your custom scalar types ex. scalar Date

Piotr Sroczkowski GraphQL

Page 65: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Scalar types

Int

Float

String

Boolean

Id

You can also define your custom scalar types ex. scalar Date

Piotr Sroczkowski GraphQL

Page 66: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Enumeration types

1 enum Episode {

2 NEWHOPE

3 EMPIRE

4 JEDI

5 }

Piotr Sroczkowski GraphQL

Page 67: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Type modifiers

1 type Character {

2 name: String!

3 appearsIn: [Episode ]!

4 }

Piotr Sroczkowski GraphQL

Page 68: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Interface

1 interface Character {

2 id: ID!

3 name: String!

4 friends: [Character]

5 appearsIn: [Episode ]!

6 }

Piotr Sroczkowski GraphQL

Page 69: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Interface implementation

1 type Human implements Character {

2 id: ID!

3 name: String!

4 friends: [Character]

5 appearsIn: [Episode ]!

6 starships: [Starship]

7 totalCredits: Int

8 }

Piotr Sroczkowski GraphQL

Page 70: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Union types

1 union SearchResult = Human | Droid | Starship

Piotr Sroczkowski GraphQL

Page 71: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Input types

1 input ReviewInput {

2 stars: Int!

3 commentary: String

4 }

1 mutation CreateReviewForEpisode($ep: Episode!,

↪→ $review: ReviewInput !) {

2 createReview(episode: $ep , review: $review)

↪→ {

3 stars

4 commentary

5 }

6 }

Piotr Sroczkowski GraphQL

Page 72: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Input types

1 input ReviewInput {

2 stars: Int!

3 commentary: String

4 }

1 mutation CreateReviewForEpisode($ep: Episode!,

↪→ $review: ReviewInput !) {

2 createReview(episode: $ep , review: $review)

↪→ {

3 stars

4 commentary

5 }

6 }

Piotr Sroczkowski GraphQL

Page 73: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Input types

1 input ReviewInput {

2 stars: Int!

3 commentary: String

4 }

1 mutation CreateReviewForEpisode($ep: Episode!,

↪→ $review: ReviewInput !) {

2 createReview(episode: $ep , review: $review)

↪→ {

3 stars

4 commentary

5 }

6 }

Piotr Sroczkowski GraphQL

Page 74: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Best practices

HTTP

JSON (with GZIP)

Versioning

Nullability

Pagination

Server-side Batching & Caching

Piotr Sroczkowski GraphQL

Page 75: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Best practices

HTTP

JSON (with GZIP)

Versioning

Nullability

Pagination

Server-side Batching & Caching

Piotr Sroczkowski GraphQL

Page 76: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Best practices

HTTP

JSON (with GZIP)

Versioning

Nullability

Pagination

Server-side Batching & Caching

Piotr Sroczkowski GraphQL

Page 77: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Best practices

HTTP

JSON (with GZIP)

Versioning

Nullability

Pagination

Server-side Batching & Caching

Piotr Sroczkowski GraphQL

Page 78: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Best practices

HTTP

JSON (with GZIP)

Versioning

Nullability

Pagination

Server-side Batching & Caching

Piotr Sroczkowski GraphQL

Page 79: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Best practices

HTTP

JSON (with GZIP)

Versioning

Nullability

Pagination

Server-side Batching & Caching

Piotr Sroczkowski GraphQL

Page 80: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Best practices

HTTP

JSON (with GZIP)

Versioning

Nullability

Pagination

Server-side Batching & Caching

Piotr Sroczkowski GraphQL

Page 81: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Pagination example

1 {

2 hero {

3 name

4 friends(first :2) {

5 name

6 }

7 }

8 }

Piotr Sroczkowski GraphQL

Page 82: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Batching - library

https://github.com/nodkz/react-relay-network-layer

Piotr Sroczkowski GraphQL

Page 83: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

How to setup a GraphQL server?SyntaxTypesBest practices

Batching - library

https://github.com/nodkz/react-relay-network-layer

Piotr Sroczkowski GraphQL

Page 84: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

Useful tools

Relay https://github.com/facebook/relay

GraphiQL https://github.com/graphql/graphiql

Adrenaline https://github.com/gyzerok/adrenaline

Apollo clienthttps://github.com/apollostack/apollo-client

Apollo iOShttps://github.com/apollostack/apollo-ios

Piotr Sroczkowski GraphQL

Page 85: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

Useful tools

Relay https://github.com/facebook/relay

GraphiQL https://github.com/graphql/graphiql

Adrenaline https://github.com/gyzerok/adrenaline

Apollo clienthttps://github.com/apollostack/apollo-client

Apollo iOShttps://github.com/apollostack/apollo-ios

Piotr Sroczkowski GraphQL

Page 86: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

Useful tools

Relay https://github.com/facebook/relay

GraphiQL https://github.com/graphql/graphiql

Adrenaline https://github.com/gyzerok/adrenaline

Apollo clienthttps://github.com/apollostack/apollo-client

Apollo iOShttps://github.com/apollostack/apollo-ios

Piotr Sroczkowski GraphQL

Page 87: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

Useful tools

Relay https://github.com/facebook/relay

GraphiQL https://github.com/graphql/graphiql

Adrenaline https://github.com/gyzerok/adrenaline

Apollo clienthttps://github.com/apollostack/apollo-client

Apollo iOShttps://github.com/apollostack/apollo-ios

Piotr Sroczkowski GraphQL

Page 88: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

Useful tools

Relay https://github.com/facebook/relay

GraphiQL https://github.com/graphql/graphiql

Adrenaline https://github.com/gyzerok/adrenaline

Apollo clienthttps://github.com/apollostack/apollo-client

Apollo iOShttps://github.com/apollostack/apollo-ios

Piotr Sroczkowski GraphQL

Page 89: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

Useful tools

Relay https://github.com/facebook/relay

GraphiQL https://github.com/graphql/graphiql

Adrenaline https://github.com/gyzerok/adrenaline

Apollo clienthttps://github.com/apollostack/apollo-client

Apollo iOShttps://github.com/apollostack/apollo-ios

Piotr Sroczkowski GraphQL

Page 90: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

Alternatives

Falcor (not yet available)

SPARQL

Graph databases like Neo4j, ArangoDB

Piotr Sroczkowski GraphQL

Page 91: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

Alternatives

Falcor (not yet available)

SPARQL

Graph databases like Neo4j, ArangoDB

Piotr Sroczkowski GraphQL

Page 92: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

Alternatives

Falcor (not yet available)

SPARQL

Graph databases like Neo4j, ArangoDB

Piotr Sroczkowski GraphQL

Page 93: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

Alternatives

Falcor (not yet available)

SPARQL

Graph databases like Neo4j, ArangoDB

Piotr Sroczkowski GraphQL

Page 94: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

What problems does it solve?

client - server and microservices communication

more precise than REST

versioning

Piotr Sroczkowski GraphQL

Page 95: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

What problems does it solve?

client - server and microservices communication

more precise than REST

versioning

Piotr Sroczkowski GraphQL

Page 96: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

What problems does it solve?

client - server and microservices communication

more precise than REST

versioning

Piotr Sroczkowski GraphQL

Page 97: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

What problems does it solve?

client - server and microservices communication

more precise than REST

versioning

Piotr Sroczkowski GraphQL

Page 98: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

Sources

The examples have been got from GraphQL official sitehttp://graphql.org/learn/

Piotr Sroczkowski GraphQL

Page 99: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

Sources

The examples have been got from GraphQL official sitehttp://graphql.org/learn/

Piotr Sroczkowski GraphQL

Page 100: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

The end

Thank you

Piotr Sroczkowski GraphQL

Page 101: Introduction to GraphQL

IntroductionOriginHistoryUsage

Alternatives & useful toolsEnd

The end

Thank you

Piotr Sroczkowski GraphQL