SlideShare a Scribd company logo
GraphQL – the future
of APIs?
- OR -

GraphQL in a brief
Dmitry Stropalov, Sizmek Kraków 2017
What is GraphQL
• GraphQL is a (query) language
- declarative

- hierarchical 

- strongly typed
• GraphQL is a runtime

- execution layer

- technology agnostic
2
Yet another technology?
• Era of mobile devices

• Flexibility & Transparency

• Productivity & Costs
3
Some example
4
I have a data. What’s next?
5
1. Define a schema for data representation
GraphQL Schema:
type Campaign {
name: ID!
title: String
running: Boolean
ads: [Ad]
}
Elixir DSL:
object :campaign do
field :id, non_null(:id)
field :title, :string
field :running, :boolean
field :ads, list_of(:ad),
resolve: assoc(:ads)
end
I have a data. What’s next?
6
2. Define a schema of queries and mutations
GraphQL Schema:
type Query {
campaign(id: ID!): Campaign
}
Elixir DSL:
field :campaign, :campaign do
arg :id, non_null(:id)
resolve &CampaignResolver.find/2
end
I have a data. What’s next?
7
3. Implement resolvers for queries and mutations
Elixir:
def find(%{id: id}, _info) do
case Repo.get(Campaign, id) do
nil -> {:error, "Campaign #{id} not found"}
campaign -> {:ok, campaign}
end
end
I have a data. What’s next?
8
4. Make some queries
GraphQL query:
query {
campaign(id: 1) {
running
ads {
budget {
amount
}
}
}
}
GraphQL mutation:
mutation {
createCampaign(
title: "New campaign",
running: false, ads: [
{title: “LI 1"}
]) {
id
}
}
GraphQL Schema
9
• Scalar Types

• Lists & Enumeration Types

• Object Types

• Interfaces & Unions

• Arguments

• Input types
Scalar Types
10
• Int: A signed 32‐bit integer.

• Float: A signed double-precision floating-point value.

• String: A UTF‐8 character sequence.

• Boolean: true or false.

• ID: non human-readable String.

• Custom scalars via scalar keyword.
Lists & Enumeration Types
• Lists defined with [ and ] around type.

• Enum – special type of scalar with a restricted set of
possible values:



enum Episode {

FIRST

SECOND

THIRD

}
11
Object Types
• Object type – named set of fields with theirs types.

• Fields could be scalars or other object types, enums, lists.

• Fields could be marked as non-nullable:



type Ad {

title: String!

targetings: [Targeting!]!

}
12
Interfaces & Unions
• Interface – an abstract object type:

interface Player {

nickname: String!

}

type User implements Player {

nickname: String!

…

}

• Union – specifies a set of possible object types:

union SearchResult = Picture | Video | Document



search(text: "Kraków") {

… on Picture { size }

… on Video { length }

… on Document { format }

}
13
Arguments
• Every field of an object type can have zero or more
arguments:

type FuelTank {

volume(unit: VolumeUnit = LITRE): Float

}

• All arguments are named.

• Could be required or optional.
14
Input Types
• Input types – object types used for mutations.

• Input and output object types can’t be mixed.

• No arguments on input object fields.
15
GraphQL Queries
16
Fields, aliases, fragments and other things
Introspection & Docs
• Introspection is built-in via special __schema object.

• Any type introspection via __type object.

• Documentation is a part of schema definition:



@desc "Get campaign by ID."

field :campaign, :campaign do

arg :id, non_null(:id), description: "Specifies campaign ID.”

resolve &CampaignResolver.find/2

end
17
API Versioning
• GraphQL can’t have “v1”-style versioning.

• Evolution is the key.
18
One more “v1” thing
19
–Monty Python
“And now for something completely different …”
20
The Glory of REST
21
From the article “Richardson Maturity Model” by M.Fowler
GraphQL & REST
• GraphQL is a language, specification and tools while REST is an
architectural concept.

• GraphQL is completely independent of a transport protocol used.

• With GraphQL you can think in terms of a business logic objects
instead of resources.

• Different caching approaches.

• API payload optimisations.

• Field usage monitoring.
22
Adoption
• Facebook

• GitHub

• Twitter

• Airbnb

• The New York Times

• Wirtualna Polska

• Coursera

• Dailymotion
23
The End

More Related Content

Similar to GraphQL – the future of APIs?

GraphQl Introduction
GraphQl IntroductionGraphQl Introduction
GraphQl Introduction
AbhayKumarAgrawal1
 
Angular
AngularAngular
Angular
Lilia Sfaxi
 
GraphQL + relay
GraphQL + relayGraphQL + relay
GraphQL + relay
Cédric GILLET
 
HyperGraphQL
HyperGraphQLHyperGraphQL
HyperGraphQL
Szymon Klarman
 
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScriptMongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
MongoDB
 
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
All Things Open
 
Tutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHPTutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHP
Andrew Rota
 
Graphql usage
Graphql usageGraphql usage
Graphql usage
Valentin Buryakov
 
How and Where in GLORP
How and Where in GLORPHow and Where in GLORP
How and Where in GLORP
ESUG
 
GraphQL 101
GraphQL 101GraphQL 101
GraphQL 101
Paul Withers
 
Revealing ALLSTOCKER
Revealing ALLSTOCKERRevealing ALLSTOCKER
Revealing ALLSTOCKER
Masashi Umezawa
 
Building a GraphQL API in PHP
Building a GraphQL API in PHPBuilding a GraphQL API in PHP
Building a GraphQL API in PHP
Andrew Rota
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptx
arjun431527
 
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
Databricks
 
OODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsOODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objects
Shanmuganathan C
 
Chapter02 graphics-programming
Chapter02 graphics-programmingChapter02 graphics-programming
Chapter02 graphics-programming
Mohammed Romi
 
OpenAPI development with Python
OpenAPI development with PythonOpenAPI development with Python
OpenAPI development with Python
Takuro Wada
 
Enforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code GenerationEnforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code Generation
Tim Burks
 
AngularConf2015
AngularConf2015AngularConf2015
AngularConf2015
Alessandro Giorgetti
 
The advantage of developing with TypeScript
The advantage of developing with TypeScript The advantage of developing with TypeScript
The advantage of developing with TypeScript
Corley S.r.l.
 

Similar to GraphQL – the future of APIs? (20)

GraphQl Introduction
GraphQl IntroductionGraphQl Introduction
GraphQl Introduction
 
Angular
AngularAngular
Angular
 
GraphQL + relay
GraphQL + relayGraphQL + relay
GraphQL + relay
 
HyperGraphQL
HyperGraphQLHyperGraphQL
HyperGraphQL
 
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScriptMongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
 
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
 
Tutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHPTutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHP
 
Graphql usage
Graphql usageGraphql usage
Graphql usage
 
How and Where in GLORP
How and Where in GLORPHow and Where in GLORP
How and Where in GLORP
 
GraphQL 101
GraphQL 101GraphQL 101
GraphQL 101
 
Revealing ALLSTOCKER
Revealing ALLSTOCKERRevealing ALLSTOCKER
Revealing ALLSTOCKER
 
Building a GraphQL API in PHP
Building a GraphQL API in PHPBuilding a GraphQL API in PHP
Building a GraphQL API in PHP
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptx
 
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
 
OODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsOODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objects
 
Chapter02 graphics-programming
Chapter02 graphics-programmingChapter02 graphics-programming
Chapter02 graphics-programming
 
OpenAPI development with Python
OpenAPI development with PythonOpenAPI development with Python
OpenAPI development with Python
 
Enforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code GenerationEnforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code Generation
 
AngularConf2015
AngularConf2015AngularConf2015
AngularConf2015
 
The advantage of developing with TypeScript
The advantage of developing with TypeScript The advantage of developing with TypeScript
The advantage of developing with TypeScript
 

Recently uploaded

Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 

Recently uploaded (20)

Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 

GraphQL – the future of APIs?

  • 1. GraphQL – the future of APIs? - OR - GraphQL in a brief Dmitry Stropalov, Sizmek Kraków 2017
  • 2. What is GraphQL • GraphQL is a (query) language - declarative - hierarchical - strongly typed • GraphQL is a runtime - execution layer - technology agnostic 2
  • 3. Yet another technology? • Era of mobile devices • Flexibility & Transparency • Productivity & Costs 3
  • 5. I have a data. What’s next? 5 1. Define a schema for data representation GraphQL Schema: type Campaign { name: ID! title: String running: Boolean ads: [Ad] } Elixir DSL: object :campaign do field :id, non_null(:id) field :title, :string field :running, :boolean field :ads, list_of(:ad), resolve: assoc(:ads) end
  • 6. I have a data. What’s next? 6 2. Define a schema of queries and mutations GraphQL Schema: type Query { campaign(id: ID!): Campaign } Elixir DSL: field :campaign, :campaign do arg :id, non_null(:id) resolve &CampaignResolver.find/2 end
  • 7. I have a data. What’s next? 7 3. Implement resolvers for queries and mutations Elixir: def find(%{id: id}, _info) do case Repo.get(Campaign, id) do nil -> {:error, "Campaign #{id} not found"} campaign -> {:ok, campaign} end end
  • 8. I have a data. What’s next? 8 4. Make some queries GraphQL query: query { campaign(id: 1) { running ads { budget { amount } } } } GraphQL mutation: mutation { createCampaign( title: "New campaign", running: false, ads: [ {title: “LI 1"} ]) { id } }
  • 9. GraphQL Schema 9 • Scalar Types • Lists & Enumeration Types • Object Types • Interfaces & Unions • Arguments • Input types
  • 10. Scalar Types 10 • Int: A signed 32‐bit integer. • Float: A signed double-precision floating-point value. • String: A UTF‐8 character sequence. • Boolean: true or false. • ID: non human-readable String. • Custom scalars via scalar keyword.
  • 11. Lists & Enumeration Types • Lists defined with [ and ] around type. • Enum – special type of scalar with a restricted set of possible values:
 
 enum Episode {
 FIRST
 SECOND
 THIRD
 } 11
  • 12. Object Types • Object type – named set of fields with theirs types. • Fields could be scalars or other object types, enums, lists. • Fields could be marked as non-nullable:
 
 type Ad {
 title: String!
 targetings: [Targeting!]!
 } 12
  • 13. Interfaces & Unions • Interface – an abstract object type:
 interface Player {
 nickname: String!
 }
 type User implements Player {
 nickname: String!
 …
 } • Union – specifies a set of possible object types:
 union SearchResult = Picture | Video | Document
 
 search(text: "Kraków") {
 … on Picture { size }
 … on Video { length }
 … on Document { format }
 } 13
  • 14. Arguments • Every field of an object type can have zero or more arguments:
 type FuelTank {
 volume(unit: VolumeUnit = LITRE): Float
 } • All arguments are named. • Could be required or optional. 14
  • 15. Input Types • Input types – object types used for mutations. • Input and output object types can’t be mixed. • No arguments on input object fields. 15
  • 16. GraphQL Queries 16 Fields, aliases, fragments and other things
  • 17. Introspection & Docs • Introspection is built-in via special __schema object. • Any type introspection via __type object. • Documentation is a part of schema definition:
 
 @desc "Get campaign by ID."
 field :campaign, :campaign do
 arg :id, non_null(:id), description: "Specifies campaign ID.”
 resolve &CampaignResolver.find/2
 end 17
  • 18. API Versioning • GraphQL can’t have “v1”-style versioning. • Evolution is the key. 18
  • 19. One more “v1” thing 19
  • 20. –Monty Python “And now for something completely different …” 20
  • 21. The Glory of REST 21 From the article “Richardson Maturity Model” by M.Fowler
  • 22. GraphQL & REST • GraphQL is a language, specification and tools while REST is an architectural concept. • GraphQL is completely independent of a transport protocol used. • With GraphQL you can think in terms of a business logic objects instead of resources. • Different caching approaches. • API payload optimisations. • Field usage monitoring. 22
  • 23. Adoption • Facebook • GitHub • Twitter • Airbnb • The New York Times • Wirtualna Polska • Coursera • Dailymotion 23