SlideShare ist ein Scribd-Unternehmen logo
1 von 46
AN ELEGANT WEAPON...
FOR MORE CIVILIZED AGE
INTRODUCTION
Bartosz Sypytkowski
▪ @Horusiath
▪ b.sypytkowski@gmail.com
▪ bartoszsypytkowski.com
 REST: what is it all about...
 ... what problems does it have...
 ... and how GraphQL aims to solve them...
 ... at what cost...
 ... what can we do with it now ...
 ... and what could we hope for in the future.
AGENDA
what is it all about...
 resources ≠ operations
 CRUD over HTTP Methods
 utilization of HTTP status codes
 stateless
GET /documents/{id}
POST /documents/
PUT /documents/{id}
PATCH /documents/{id}
DELETE /documents/{id}
RESOURCES,
NOT OPERATIONS
QUIZ TIME!
WEBSOCKETS
What HTTP method will you use to
update a resource over websockets?
UNDER
FETCHING
async function getPostWithComments(postId) {
var post = await http.get('/posts/{postId}');
/* GET /posts/4277
{
"id": 4277,
"authorId": 345,
"title": "REST - why we cannot have nice things?",
"content": "a very long text"
}
*/
post.comments = await http.get('/posts/{postId}/comments');
/* GET /posts/4277/comments
[]
*/
return post;
}
OVER
FETCHING async function getPostTitle(postId) {
var post = await http.get('/posts/{postId}');
/* GET /posts/4277
{
"id": 4277,
"authorId": 345,
"title": "REST - why we cannot have nice things?",
"content": "a very long text"
}
*/
return post.title;
}
A (DOUBTFUL)
SOLUTION
 Works in limited scope
 Non-trivial to make it work right
 Risky (you may accidentally expose more than desired)
/user/{id}/posts?include=comments
SUMMARY
 not quite stateless
 not quite a standard
 strictly limited to HTTP request/response
 schema-less
 not self-descriptive
 hard to correlate entities from different
endpoints
 versioning
 under and overfetching
 Swagger
 HATEOAS
 JSON-Schema
 RAML
 RDSL
 ODATA
 JWT
 Introspected REST
 whatever else is trendy this week...
SOLUTIONS
?
GraphQL is a query language for APIs and a runtime for
fulfilling those queries with your existing data.
GraphQL provides a complete and understandable
description of the data in your API, gives clients the power
to ask for exactly what they need and nothing more, makes
it easier to evolve APIs over time, and enables powerful
developer tools.
It has specs...
... so it keeps clear
expectations.
IT'S A
STANDARD
WHO IS USING IT?
HOW DOES
IT LOOK
LIKE?
Query:
query {
article(id: ”1337”) {
id
title
author {
...fullName
}
created
comments {
author {
...fullName
}
created
}
}
}
fragment fullName on User {
firstName
lastName
}
Result:
{
"id": “1337”,
"title": "Horse steroids - guide for athletes",
"author": {
"firstName": "Andy",
"lastName": "Greenberg"
},
"created": "2015-05-22T14:56:29.000Z",
"comments": [
{
"author": {
"firstName": "Sam",
"lastName": "Gonagal"
},
"created": "2015-05-22T14:56:34.000Z"
},
{
"author": {
"firstName": "Chris",
"lastName": "McDonald"
},
"created": "2016-05-22T14:56:34.000Z"
}
]
}
CONSUMER
SIDE
 Query for readonly actions.
 Mutation for anything that affects the state.
 Subscription for continuous stream of data.
Ask for GraphQL schema using GraphQL
query language.
query AllTypesWithFields {
__schema {
types {
name
fields {
name
type {
name
}
}
}
}
}
INTROSPECTION API
DEMO
GRAPHQL
ON THE
CLIENT
SIDE
Relay
 originally
developed in
Facebook
 quite opinionated:
requires a separate
set of constraints
on top of your
GraphQL schema
 thightly integrated
with React stack
 fast!
Apollo
 easier to learn
 tons of plugins
 easy to integrate
with other
technologies ie.
Redux or Angular
APOLLO
const FeedWithData = graphql(gql`
{
feed (type: TOP, limit: 5) {
repository {
owner { login }
name
}
postedBy { login }
}
}
`)(Feed);
function Feed({ data }) {
return (
<View>
<Text style={styles.title}>GitHunt</Text>
{ data.feed.map((item) =>
<View style={styles.feedItem}>
<Text style={styles.entry}>
{item.repository.owner.login}/{item.repository.name}
</Text>
<Text>Posted by {item.postedBy.login}</Text>
</View>) }
</View>
);
}
TIME
TO
STOP
Let's speak about
downsides for a
while
HOW TO OPTIMIZE?
N+1
SELECTS
query CustomersAndTheirProducts {
customers(first: 20) {
firstName
lastName
orders {
totalPrice
orderLines {
quantity
product {
name
price
}
}
}
}
}
const resolvers = {
query: {
customers: ({first}) => {
return db.customers.take(first);
}
},
Customer: {
orders: (customer) => {
return db.orders
.where({customerId:
customer.id});
}
}
}
Client request: Server implementation (JS)
FSHARP.DATA.GRAPHQL
Client
Server
Query Variables
Schema Compilation
(Runtime)
Query Execution Plan Query Evaluation
HOPE FOR
THE
FUTURE
1. Move Schema “compilation” to compile
time
2. Execution plan caching and JIT
compilation
Expose query tree /
execution plan at
resolver level.
N+1 SELECTS
SOLUTION #1
Delay and batch resolver calls.
N+1 SELECTS
SOLUTION #2 const ordersLoader = new DataLoader((customerIds) =>
db.orders.whereIn(‘customerId’, customerIds));
const resolvers = {
query: {
customers: ({first}) => {
return db.customers.take(first);
}
},
Customer: {
orders: (customer) => {
return ordersLoader.load(customer.id);
}
}
}
What risks do they introduce?
1. DoS-ing the server.
2. Client needs to send a huge
query.
BIG QUERIES
QUERY
COMPLEXITY
ANALYSIS
Github example
https://developer.github.com/v4/guides/resource-limitations/
PERSISTED
QUERIES
Static / Dynamic
{
"documentId": 391958033,
"data": {
"hero": {
"name": "Han Solo",
"friends": [
{
"name": "Luke Skywalker"
},
{
"name": "Leia Organa"
},
{
"name": "R2-D2"
}
]
}
}
}
Sending all data at once can
take time…
HUGE REPLIES
DIRECTIVE:
@defer
Query:
query {
article(id: ”1337”) {
title
author {
firstName
}
comments @defer {
author {
firstName
}
created
}
}
}
Result (initial):
{
"data": {
"article": {
"title": "Horse steroids - guide for athletes",
"author": {
"firstName": "Andy"
},
"comments": null
}
}
}
Result (patch):
{
"path": ["article", "comments"],
"data": [
{
"author": {
"firstName": "Sam"
},
"created": "2015-05-22T14:56:34.000Z"
},
{
"author": {
"firstName": "Chris"
},
"created": "2016-05-22T14:56:34.000Z"
}
]
}
CAPABILITY-
ORIENTED
DOMAIN
DESIGN.
GRAPHQL
VS.
ODATA
ODATA Perfect use case
ODATA Perfect use case
▪ Data aggregation
▪ Data management: rich filtering, sorting and pagination.
▪ Part of existing REST model.
GRAPHQL Perfect use case (xD)
GRAPHQL Perfect use case
▪ Multilayered object tree domain model
▪ Low-bandwidth / high-latency networks (e.g. mobile)
▪ Public API for 3rd party consumers
SUMMARY
THANK YOU
GraphQL - an elegant weapon... for more civilized age

Weitere ähnliche Inhalte

Was ist angesagt?

Google apps script
Google apps scriptGoogle apps script
Google apps scriptSimon Su
 
Next-generation API Development with GraphQL and Prisma
Next-generation API Development with GraphQL and PrismaNext-generation API Development with GraphQL and Prisma
Next-generation API Development with GraphQL and PrismaNikolas Burk
 
Altitude San Francisco 2018: Logging at the Edge
Altitude San Francisco 2018: Logging at the Edge Altitude San Francisco 2018: Logging at the Edge
Altitude San Francisco 2018: Logging at the Edge Fastly
 
Google Cloud Dataflow meets TensorFlow
Google Cloud Dataflow meets TensorFlowGoogle Cloud Dataflow meets TensorFlow
Google Cloud Dataflow meets TensorFlowHayato Yoshikawa
 
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...MongoDB
 
KEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.jsKEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.jsJustin Beckwith
 
[Meetup] a successful migration from elastic search to clickhouse
[Meetup] a successful migration from elastic search to clickhouse[Meetup] a successful migration from elastic search to clickhouse
[Meetup] a successful migration from elastic search to clickhouseVianney FOUCAULT
 
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...BradNeuberg
 
Intro to Google Apps Script
Intro to Google Apps ScriptIntro to Google Apps Script
Intro to Google Apps Scriptmodmonstr
 
[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema
[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema
[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON SchemaMongoDB
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsMongoDB
 
Cloud TiDB deep dive
Cloud TiDB deep diveCloud TiDB deep dive
Cloud TiDB deep dive臣 成
 
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your DataMongoDB
 
Polyglot persistence with Spring Data
Polyglot persistence with Spring DataPolyglot persistence with Spring Data
Polyglot persistence with Spring DataCorneil du Plessis
 

Was ist angesagt? (16)

Google apps script
Google apps scriptGoogle apps script
Google apps script
 
Next-generation API Development with GraphQL and Prisma
Next-generation API Development with GraphQL and PrismaNext-generation API Development with GraphQL and Prisma
Next-generation API Development with GraphQL and Prisma
 
Altitude San Francisco 2018: Logging at the Edge
Altitude San Francisco 2018: Logging at the Edge Altitude San Francisco 2018: Logging at the Edge
Altitude San Francisco 2018: Logging at the Edge
 
Grails 101
Grails 101Grails 101
Grails 101
 
Google Cloud Dataflow
Google Cloud DataflowGoogle Cloud Dataflow
Google Cloud Dataflow
 
Google Cloud Dataflow meets TensorFlow
Google Cloud Dataflow meets TensorFlowGoogle Cloud Dataflow meets TensorFlow
Google Cloud Dataflow meets TensorFlow
 
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
 
KEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.jsKEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.js
 
[Meetup] a successful migration from elastic search to clickhouse
[Meetup] a successful migration from elastic search to clickhouse[Meetup] a successful migration from elastic search to clickhouse
[Meetup] a successful migration from elastic search to clickhouse
 
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
 
Intro to Google Apps Script
Intro to Google Apps ScriptIntro to Google Apps Script
Intro to Google Apps Script
 
[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema
[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema
[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
 
Cloud TiDB deep dive
Cloud TiDB deep diveCloud TiDB deep dive
Cloud TiDB deep dive
 
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
 
Polyglot persistence with Spring Data
Polyglot persistence with Spring DataPolyglot persistence with Spring Data
Polyglot persistence with Spring Data
 

Ähnlich wie GraphQL - an elegant weapon... for more civilized age

GraphQL the holy contract between client and server
GraphQL the holy contract between client and serverGraphQL the holy contract between client and server
GraphQL the holy contract between client and serverPavel Chertorogov
 
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, & TypeScriptMongoDB
 
GraphQL - when REST API is not enough - lessons learned
GraphQL - when REST API is not enough - lessons learnedGraphQL - when REST API is not enough - lessons learned
GraphQL - when REST API is not enough - lessons learnedMarcinStachniuk
 
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...François-Guillaume Ribreau
 
Connecting the Dots: Kong for GraphQL Endpoints
Connecting the Dots: Kong for GraphQL EndpointsConnecting the Dots: Kong for GraphQL Endpoints
Connecting the Dots: Kong for GraphQL EndpointsJulien Bataillé
 
GraphQL in an Age of REST
GraphQL in an Age of RESTGraphQL in an Age of REST
GraphQL in an Age of RESTYos Riady
 
Developing and Deploying Apps with the Postgres FDW
Developing and Deploying Apps with the Postgres FDWDeveloping and Deploying Apps with the Postgres FDW
Developing and Deploying Apps with the Postgres FDWJonathan Katz
 
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...apidays
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomyDongmin Yu
 
GraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learnedGraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learnedMarcinStachniuk
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기NAVER D2
 
Developing node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDBDeveloping node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDBRob Tweed
 
SETCON'18 - Ilya labacheuski - GraphQL adventures
SETCON'18 - Ilya labacheuski - GraphQL adventuresSETCON'18 - Ilya labacheuski - GraphQL adventures
SETCON'18 - Ilya labacheuski - GraphQL adventuresNadzeya Pus
 
Managing GraphQL servers with AWS Fargate & Prisma Cloud
Managing GraphQL servers  with AWS Fargate & Prisma CloudManaging GraphQL servers  with AWS Fargate & Prisma Cloud
Managing GraphQL servers with AWS Fargate & Prisma CloudNikolas Burk
 
20170624 GraphQL Presentation
20170624 GraphQL Presentation20170624 GraphQL Presentation
20170624 GraphQL PresentationMartin Heidegger
 
Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL Josh Price
 
How to Leverage APIs for SEO #TTTLive2019
How to Leverage APIs for SEO #TTTLive2019How to Leverage APIs for SEO #TTTLive2019
How to Leverage APIs for SEO #TTTLive2019Paul Shapiro
 
Dev sum - Beyond REST with GraphQL in .Net
Dev sum - Beyond REST with GraphQL in .NetDev sum - Beyond REST with GraphQL in .Net
Dev sum - Beyond REST with GraphQL in .NetIrina Scurtu
 

Ähnlich wie GraphQL - an elegant weapon... for more civilized age (20)

GraphQL the holy contract between client and server
GraphQL the holy contract between client and serverGraphQL the holy contract between client and server
GraphQL the holy contract between client and server
 
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
 
GraphQL - when REST API is not enough - lessons learned
GraphQL - when REST API is not enough - lessons learnedGraphQL - when REST API is not enough - lessons learned
GraphQL - when REST API is not enough - lessons learned
 
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Connecting the Dots: Kong for GraphQL Endpoints
Connecting the Dots: Kong for GraphQL EndpointsConnecting the Dots: Kong for GraphQL Endpoints
Connecting the Dots: Kong for GraphQL Endpoints
 
GraphQL in an Age of REST
GraphQL in an Age of RESTGraphQL in an Age of REST
GraphQL in an Age of REST
 
Developing and Deploying Apps with the Postgres FDW
Developing and Deploying Apps with the Postgres FDWDeveloping and Deploying Apps with the Postgres FDW
Developing and Deploying Apps with the Postgres FDW
 
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
GraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learnedGraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learned
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 
Developing node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDBDeveloping node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDB
 
SETCON'18 - Ilya labacheuski - GraphQL adventures
SETCON'18 - Ilya labacheuski - GraphQL adventuresSETCON'18 - Ilya labacheuski - GraphQL adventures
SETCON'18 - Ilya labacheuski - GraphQL adventures
 
Managing GraphQL servers with AWS Fargate & Prisma Cloud
Managing GraphQL servers  with AWS Fargate & Prisma CloudManaging GraphQL servers  with AWS Fargate & Prisma Cloud
Managing GraphQL servers with AWS Fargate & Prisma Cloud
 
20170624 GraphQL Presentation
20170624 GraphQL Presentation20170624 GraphQL Presentation
20170624 GraphQL Presentation
 
GWT Extreme!
GWT Extreme!GWT Extreme!
GWT Extreme!
 
Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL
 
How to Leverage APIs for SEO #TTTLive2019
How to Leverage APIs for SEO #TTTLive2019How to Leverage APIs for SEO #TTTLive2019
How to Leverage APIs for SEO #TTTLive2019
 
Dev sum - Beyond REST with GraphQL in .Net
Dev sum - Beyond REST with GraphQL in .NetDev sum - Beyond REST with GraphQL in .Net
Dev sum - Beyond REST with GraphQL in .Net
 

Mehr von Bartosz Sypytkowski

Postgres indexes: how to make them work for your application
Postgres indexes: how to make them work for your applicationPostgres indexes: how to make them work for your application
Postgres indexes: how to make them work for your applicationBartosz Sypytkowski
 
How do databases perform live backups and point-in-time recovery
How do databases perform live backups and point-in-time recoveryHow do databases perform live backups and point-in-time recovery
How do databases perform live backups and point-in-time recoveryBartosz Sypytkowski
 
Scaling connections in peer-to-peer applications
Scaling connections in peer-to-peer applicationsScaling connections in peer-to-peer applications
Scaling connections in peer-to-peer applicationsBartosz Sypytkowski
 
Rich collaborative data structures for everyone
Rich collaborative data structures for everyoneRich collaborative data structures for everyone
Rich collaborative data structures for everyoneBartosz Sypytkowski
 
Behind modern concurrency primitives
Behind modern concurrency primitivesBehind modern concurrency primitives
Behind modern concurrency primitivesBartosz Sypytkowski
 
Behind modern concurrency primitives
Behind modern concurrency primitivesBehind modern concurrency primitives
Behind modern concurrency primitivesBartosz Sypytkowski
 
Living in eventually consistent reality
Living in eventually consistent realityLiving in eventually consistent reality
Living in eventually consistent realityBartosz Sypytkowski
 
Virtual machines - how they work
Virtual machines - how they workVirtual machines - how they work
Virtual machines - how they workBartosz Sypytkowski
 
Akka.NET streams and reactive streams
Akka.NET streams and reactive streamsAkka.NET streams and reactive streams
Akka.NET streams and reactive streamsBartosz Sypytkowski
 

Mehr von Bartosz Sypytkowski (14)

Postgres indexes: how to make them work for your application
Postgres indexes: how to make them work for your applicationPostgres indexes: how to make them work for your application
Postgres indexes: how to make them work for your application
 
How do databases perform live backups and point-in-time recovery
How do databases perform live backups and point-in-time recoveryHow do databases perform live backups and point-in-time recovery
How do databases perform live backups and point-in-time recovery
 
Scaling connections in peer-to-peer applications
Scaling connections in peer-to-peer applicationsScaling connections in peer-to-peer applications
Scaling connections in peer-to-peer applications
 
Rich collaborative data structures for everyone
Rich collaborative data structures for everyoneRich collaborative data structures for everyone
Rich collaborative data structures for everyone
 
Postgres indexes
Postgres indexesPostgres indexes
Postgres indexes
 
Behind modern concurrency primitives
Behind modern concurrency primitivesBehind modern concurrency primitives
Behind modern concurrency primitives
 
Collaborative eventsourcing
Collaborative eventsourcingCollaborative eventsourcing
Collaborative eventsourcing
 
Behind modern concurrency primitives
Behind modern concurrency primitivesBehind modern concurrency primitives
Behind modern concurrency primitives
 
Living in eventually consistent reality
Living in eventually consistent realityLiving in eventually consistent reality
Living in eventually consistent reality
 
Virtual machines - how they work
Virtual machines - how they workVirtual machines - how they work
Virtual machines - how they work
 
Short story of time
Short story of timeShort story of time
Short story of time
 
Akka.NET streams and reactive streams
Akka.NET streams and reactive streamsAkka.NET streams and reactive streams
Akka.NET streams and reactive streams
 
Collaborative text editing
Collaborative text editingCollaborative text editing
Collaborative text editing
 
The last mile from db to disk
The last mile from db to diskThe last mile from db to disk
The last mile from db to disk
 

Kürzlich hochgeladen

%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 

Kürzlich hochgeladen (20)

%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 

GraphQL - an elegant weapon... for more civilized age

  • 1. AN ELEGANT WEAPON... FOR MORE CIVILIZED AGE
  • 2. INTRODUCTION Bartosz Sypytkowski ▪ @Horusiath ▪ b.sypytkowski@gmail.com ▪ bartoszsypytkowski.com
  • 3.  REST: what is it all about...  ... what problems does it have...  ... and how GraphQL aims to solve them...  ... at what cost...  ... what can we do with it now ...  ... and what could we hope for in the future. AGENDA
  • 4. what is it all about...  resources ≠ operations  CRUD over HTTP Methods  utilization of HTTP status codes  stateless
  • 5. GET /documents/{id} POST /documents/ PUT /documents/{id} PATCH /documents/{id} DELETE /documents/{id} RESOURCES, NOT OPERATIONS
  • 7. WEBSOCKETS What HTTP method will you use to update a resource over websockets?
  • 8.
  • 9. UNDER FETCHING async function getPostWithComments(postId) { var post = await http.get('/posts/{postId}'); /* GET /posts/4277 { "id": 4277, "authorId": 345, "title": "REST - why we cannot have nice things?", "content": "a very long text" } */ post.comments = await http.get('/posts/{postId}/comments'); /* GET /posts/4277/comments [] */ return post; }
  • 10. OVER FETCHING async function getPostTitle(postId) { var post = await http.get('/posts/{postId}'); /* GET /posts/4277 { "id": 4277, "authorId": 345, "title": "REST - why we cannot have nice things?", "content": "a very long text" } */ return post.title; }
  • 11. A (DOUBTFUL) SOLUTION  Works in limited scope  Non-trivial to make it work right  Risky (you may accidentally expose more than desired) /user/{id}/posts?include=comments
  • 12. SUMMARY  not quite stateless  not quite a standard  strictly limited to HTTP request/response  schema-less  not self-descriptive  hard to correlate entities from different endpoints  versioning  under and overfetching
  • 13.  Swagger  HATEOAS  JSON-Schema  RAML  RDSL  ODATA  JWT  Introspected REST  whatever else is trendy this week... SOLUTIONS ?
  • 14.
  • 15.
  • 16.
  • 17. GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.
  • 18. It has specs... ... so it keeps clear expectations. IT'S A STANDARD
  • 20. HOW DOES IT LOOK LIKE? Query: query { article(id: ”1337”) { id title author { ...fullName } created comments { author { ...fullName } created } } } fragment fullName on User { firstName lastName } Result: { "id": “1337”, "title": "Horse steroids - guide for athletes", "author": { "firstName": "Andy", "lastName": "Greenberg" }, "created": "2015-05-22T14:56:29.000Z", "comments": [ { "author": { "firstName": "Sam", "lastName": "Gonagal" }, "created": "2015-05-22T14:56:34.000Z" }, { "author": { "firstName": "Chris", "lastName": "McDonald" }, "created": "2016-05-22T14:56:34.000Z" } ] }
  • 21. CONSUMER SIDE  Query for readonly actions.  Mutation for anything that affects the state.  Subscription for continuous stream of data.
  • 22. Ask for GraphQL schema using GraphQL query language. query AllTypesWithFields { __schema { types { name fields { name type { name } } } } } INTROSPECTION API
  • 23. DEMO
  • 24. GRAPHQL ON THE CLIENT SIDE Relay  originally developed in Facebook  quite opinionated: requires a separate set of constraints on top of your GraphQL schema  thightly integrated with React stack  fast! Apollo  easier to learn  tons of plugins  easy to integrate with other technologies ie. Redux or Angular
  • 25. APOLLO const FeedWithData = graphql(gql` { feed (type: TOP, limit: 5) { repository { owner { login } name } postedBy { login } } } `)(Feed); function Feed({ data }) { return ( <View> <Text style={styles.title}>GitHunt</Text> { data.feed.map((item) => <View style={styles.feedItem}> <Text style={styles.entry}> {item.repository.owner.login}/{item.repository.name} </Text> <Text>Posted by {item.postedBy.login}</Text> </View>) } </View> ); }
  • 28. N+1 SELECTS query CustomersAndTheirProducts { customers(first: 20) { firstName lastName orders { totalPrice orderLines { quantity product { name price } } } } } const resolvers = { query: { customers: ({first}) => { return db.customers.take(first); } }, Customer: { orders: (customer) => { return db.orders .where({customerId: customer.id}); } } } Client request: Server implementation (JS)
  • 30. HOPE FOR THE FUTURE 1. Move Schema “compilation” to compile time 2. Execution plan caching and JIT compilation
  • 31. Expose query tree / execution plan at resolver level. N+1 SELECTS SOLUTION #1
  • 32. Delay and batch resolver calls. N+1 SELECTS SOLUTION #2 const ordersLoader = new DataLoader((customerIds) => db.orders.whereIn(‘customerId’, customerIds)); const resolvers = { query: { customers: ({first}) => { return db.customers.take(first); } }, Customer: { orders: (customer) => { return ordersLoader.load(customer.id); } } }
  • 33. What risks do they introduce? 1. DoS-ing the server. 2. Client needs to send a huge query. BIG QUERIES
  • 35. PERSISTED QUERIES Static / Dynamic { "documentId": 391958033, "data": { "hero": { "name": "Han Solo", "friends": [ { "name": "Luke Skywalker" }, { "name": "Leia Organa" }, { "name": "R2-D2" } ] } } }
  • 36. Sending all data at once can take time… HUGE REPLIES
  • 37. DIRECTIVE: @defer Query: query { article(id: ”1337”) { title author { firstName } comments @defer { author { firstName } created } } } Result (initial): { "data": { "article": { "title": "Horse steroids - guide for athletes", "author": { "firstName": "Andy" }, "comments": null } } } Result (patch): { "path": ["article", "comments"], "data": [ { "author": { "firstName": "Sam" }, "created": "2015-05-22T14:56:34.000Z" }, { "author": { "firstName": "Chris" }, "created": "2016-05-22T14:56:34.000Z" } ] }
  • 41. ODATA Perfect use case ▪ Data aggregation ▪ Data management: rich filtering, sorting and pagination. ▪ Part of existing REST model.
  • 42. GRAPHQL Perfect use case (xD)
  • 43. GRAPHQL Perfect use case ▪ Multilayered object tree domain model ▪ Low-bandwidth / high-latency networks (e.g. mobile) ▪ Public API for 3rd party consumers

Hinweis der Redaktion

  1. I think that to understand GraphQL, the best way is to start from REST. Therefore we'll target some of the issues of REST and how GraphQL addresses them. However keep in mind: there's no silver bullet. For this reason, we also should understand the tradeoffs, that have been made, so in the future, you'll be ready to make concious decisions wheater to use it or not.
  2. I theory, term REST has been created as part of the PhD thesis back in 2000. Somehow it happened to be used as an idea architecture pattern for modern day distributed web services. Why? It described few key properties, that are very appealing to us, developers. 1. It standarizes semantics of doing most common entity collection operations. 2. It's stateless by default, which is makes scalling a lot easier. 3. It's well established in HTTP, which nowadays is the most common communication protocol.
  3. There's only one problem: how do you enforce this behavior? Calling developers of other endpoint idiots won't make the problem disapear. What if someone will use totally different convention?
  4. Another problem is that the standard has some undefined behaviors in it. Example can be this Stack Overflow question. If you read about it, there is around dozen of proposed status codes. The worst part: many of them actually have sense.
  5. Another problem, is that REST is clearly related to HTTP request/response protocol. Which begins to be a problem in modern highly responsive systems. Not only because we can no longer rely on HTTP methods or status codes, but also because conceptually WS fits more message- and operation-based communication model than resource-based.
  6. While GraphQL is a query language, its created to be an application-level query language as opposed to a database-level query languages like SQL. That doesn't mean, databases cannot expose their API as GraphQL endpoints. In fact some of them like [ArangoDB](https://www.arangodb.com/2016/02/using-graphql-nosql-database-arangodb/) to exactly that, while other like Postgres make it possible by using plugins on top. Usually this may be a valid option for document or graph databases, because of its construction.
  7. I don't know how about you, but I like to know that actual enpoint I have is constrained by the set of explicit rules rather than phase of the moon and a tempter of its developer. If some of you feel, that these constrains block your freedom of expression, then you probably started building your own protocols already.
  8. What's worth to notice here: The output data format is actually an object tree. It doesn't has to be JSON however it's fully JSON compatible. This is quite different from i.e. SQL, where you need additional mapping layer for your data tables - I'm talking about ORMs here. We already can see, that while query format may resemble JSON, it's not actually a JSON. Syntax is fully fledged query language. We can define parameters, as well as so called fragments: a reusable pieces of data, which allow us to avoid code duplication (again in much nicer way than i.e. SQL). Errors are part of message payload, rather than HTTP status code. This comes from a simple reason - GraphQL is not bound to HTTP protocol, it's fully agnostic. This means that (depending on the implementation) you can test entire GraphQL server fully in memory, without spinning any web host.
  9. We don't need 4 or more different HTTP verbs. GraphQL specifies 2 major ones: queries for readonly requests, and mutations for all others. The major difference is processing model: since queries don't alter state, their execution can be easily parallelized, while mutation must be executed sequentially in case of interdependent operations being executed. Subscriptions were not part of an original standard when it appeared, however over time they were specified and added by most of the popular implementations.
  10. In result of this approach, usually all you need to know to get full knowledge of API is to have URL for its GraphQL endpoint. This also gives an immense power for tooling.
  11. Before we continue, let me introduce you a little to how the F# implementation of GraphQL server works. It’s split in 3 phases: Compilation phase, which happens when you’ve specified full domain of your GraphQL schema. At this point we already can optimize some cases. When a user request arrives it consists of 2 things: GraphQL query and (optionally) set of variables used by this query. First we parse GraphQL query into abstract syntax tree and spread it by inlinening all of the fragments. Then we combine that input with the type system and resolvers described on the server side. This gives us full knowledge about, how to execute your request. Additionally this information can be passed to your resolvers, so they can be used by you to further optimizations. Last we apply incoming variables to the execution plan to produce the results.
  12. While it’s not a big problem in dynamic languages, which rely on their JIT optimizations, statically typed languages could take advantage of generating optimized GraphQL server code at compile time. We do that in F#, however it’s done in limited scope at runtime, which also slows server startup (making it less useful i.e. for Serverless). This compile time optimizations are already possible is gengql (Go implementation). They should be possible in C# by using Roslyn CodeGen, and I hope that when eventually TypeProviders over types will arrive to F#, we’ll be able to do the same. There are several advantages of separating execution plan from actual query evaluation: We can provide execution plan to you, when your logic is triggered, so you can make your code smater by leveraging the full knowledge about executed query. You can decide to cache that execution plan, so that queries, which are executed often, won’t need full evaluation on every call. In the future, we could make further optimization by implementing runtime compilation of execution plan, making it basically a single compiled function. At this point GraphQL requests could be potentially as fast as the web service actions your write by hand.
  13. REST APIs are literally like giving your business domain to consumer in a little puzzle pieces.