SlideShare a Scribd company logo
Migration
microservices to
GraphQL
API
function getUser(name: string): User {
return db.getUserByName(name);
}
Typed request argumentes
Type of response
RPC (1960s, CORBA, XML, JSON, Thrift)
SOAP (WSDL, XML)
REST (HTTP)
REST
+ People got sick of SOAP
+ HTTP 1/1
+ Extra simplicity = fast development
+ Good for CRUD
Resources
POST /users
{name: "Homer"}
OPTIONS /users
Access-Control-Request-Method:POST
Resources
GET /users?name=??
GET /users?name=Homer,Marge
GET /users?name=..&limit&offcet
GET /users?name&limit&token
• 1 nesting level
• Characters escaping
• 2048 characters
Resources
PUT/PATCH /users/1
{name: "Homer2"}
{
"name": "Homer",
"children": [
{
"name": "Bart",
},
{
"name": "Lisa"
}
]
}
Backend
app.post((req, res) => {
const user = getUser(req.headers.user_id);
const user = getUser(req.query.user_id);
const user = getUser(req.path.user_id);
const user = getUser(req.body.user);
});
function getUser(name: string): User {
return db.getUserByName(name);
}
Typed request argumentes
Type of response
We are at wrong level 
of abstraction
GraphQL
• Get what you really need
• Client specific
• Transport agnostic
• Rich type system
• A lot of web features
REST GraphQL
Auto
documented
+/-
Swagger,
ApiDoc,
Blueprint
+
Easy to use +/- +
Easy to
develop
- +
Flexible - +
Powerful - +
But REST is still an
industry standart
const QueryType = new GraphQLObjectType({
name: 'DataQuery',
fields: () => ({
post: {
type: PostType,
args: {
id: {
name: 'id',
type: GraphQLInt
},
journal: {
name: 'journal',
description: 'The journal slug',
type: GraphQLString
},
post: {
name: 'post',
description: 'The post slug',
type: GraphQLString
}
},
resolve: (user, {id, journal, post}) => {
return Post.authorise(user, {id, journal, post})
.then(post => post && post.toJSON());
}
}
})
Migration microservices to GraphQL
• JSON Schema
• Good specification
• Bad ecosystem
"/users/findByName": {
"get": {
"description": "Multiple status values can be provided with
comma separated strings",
"operationId": "findUsersByStatus",
"produces": ["application/xml", "application/json"],
"parameters": [{
"name": "name",
"in": "query",
"description": "User name",
"required": true,
"type": "array",
"items": {"type": "string"},
}],
"responses": {
"200": {
"description": "successful operation",
"schema": {"type": "array", "items": {"$ref":
"#/definitions/User"}}
}, "400": {"description": "Invalid status value"}
},
"security": [{"store_auth": ["read:users"]}]
Building types
new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: () => ({
get_user_id: {
type: UserType,
args: {
id: {
name: 'id',
type: GraphQLInt
}
},
resolve: (id) => buildRequestWithSwagger()
}
})
})
});
GET /user/123
Swagger parameters
Mutations
x-mutation
POST/PUT/DELETE
Gateway
GQL request
Adapter
ms1
ms2
REST request
GQL/REST
GQL/REST
function getUser(name: string): User {
return db.getUserByName(name);
}
Frontend
Smart caching:
GET /users
GET /user/123
Helpful tools and debugging
(Client knows about our schema and types
Get only data that you need
Frontend
• Cursor connections
• Subscriptions
• Batching
• Defered delivering
• Fragments composition
Precautions
No GraphQL types namespaces
campaigns_get_campaigns_shop_shop_id_products_id
No validation for input types
lokka
React
Apollo
Vanila
Thanks
github.com/yarax/typelint
twiitter.com/raxpost
yarax.ru

More Related Content

PDF
FIFA fails, Guy Kawasaki and real estate in SF - find out about all three by ...
PDF
Latinoware
PDF
Building a Gigaword Corpus (PyCon 2017)
PDF
Data Intelligence 2017 - Building a Gigaword Corpus
PDF
Dealing with Azure Cosmos DB
PDF
Work with V8 memory leaks
PDF
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
PDF
GraphQL
FIFA fails, Guy Kawasaki and real estate in SF - find out about all three by ...
Latinoware
Building a Gigaword Corpus (PyCon 2017)
Data Intelligence 2017 - Building a Gigaword Corpus
Dealing with Azure Cosmos DB
Work with V8 memory leaks
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
GraphQL

Viewers also liked (20)

PDF
GraphQL: The Missing Link Between Frontend and Backend Devs
PDF
GraphQL vs REST
PDF
GraphQL: Enabling a new generation of API developer tools
PDF
GraphQL Story: Intro To GraphQL
PDF
GraphQL IndyJS April 2016
PDF
Zensations Drupal 8 GraphQL Presentation 2015
PPTX
Taking Control of your Data with GraphQL
PPTX
Relay: Seamless Syncing for React (VanJS)
PPTX
GraphQL Relay Introduction
PDF
Introduction to GraphQL at API days
PPTX
An Introduction To CQRS
PDF
Why UI developers love GraphQL
PDF
Better APIs with GraphQL
PDF
CQRS & event sourcing in the wild
PDF
GraphQL in an Age of REST
PDF
Swift + GraphQL
PDF
Microservices Practitioner Summit Jan '15 - Scaling Uber from 1 to 100s of Se...
PPTX
CQRS recipes or how to cook your architecture
PDF
Building and deploying microservices with event sourcing, CQRS and Docker (Ha...
GraphQL: The Missing Link Between Frontend and Backend Devs
GraphQL vs REST
GraphQL: Enabling a new generation of API developer tools
GraphQL Story: Intro To GraphQL
GraphQL IndyJS April 2016
Zensations Drupal 8 GraphQL Presentation 2015
Taking Control of your Data with GraphQL
Relay: Seamless Syncing for React (VanJS)
GraphQL Relay Introduction
Introduction to GraphQL at API days
An Introduction To CQRS
Why UI developers love GraphQL
Better APIs with GraphQL
CQRS & event sourcing in the wild
GraphQL in an Age of REST
Swift + GraphQL
Microservices Practitioner Summit Jan '15 - Scaling Uber from 1 to 100s of Se...
CQRS recipes or how to cook your architecture
Building and deploying microservices with event sourcing, CQRS and Docker (Ha...
Ad

Similar to Migration microservices to GraphQL (20)

PPTX
Android and REST
ODP
Services Stanford 2012
PDF
node.js practical guide to serverside javascript
PDF
Retrofit Android by Chris Ollenburg
PPTX
2017 02-07 - elastic & spark. building a search geo locator
PPTX
2017 02-07 - elastic & spark. building a search geo locator
PPTX
Golang slidesaudrey
PDF
Api's and ember js
PPTX
Restful webservices
PDF
CDI, Seam & RESTEasy: You haven't seen REST yet!
PDF
async/await in Swift
PDF
Server Side Swift with Swag
PPTX
PPTX
Rest with Java EE 6 , Security , Backbone.js
PDF
JAX-RS JavaOne Hyderabad, India 2011
PDF
Javaone 2010
PDF
From Node to Go
PDF
Creating an Uber Clone - Part XII.pdf
PPTX
Building Restful Web Services with Java
PDF
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
Android and REST
Services Stanford 2012
node.js practical guide to serverside javascript
Retrofit Android by Chris Ollenburg
2017 02-07 - elastic & spark. building a search geo locator
2017 02-07 - elastic & spark. building a search geo locator
Golang slidesaudrey
Api's and ember js
Restful webservices
CDI, Seam & RESTEasy: You haven't seen REST yet!
async/await in Swift
Server Side Swift with Swag
Rest with Java EE 6 , Security , Backbone.js
JAX-RS JavaOne Hyderabad, India 2011
Javaone 2010
From Node to Go
Creating an Uber Clone - Part XII.pdf
Building Restful Web Services with Java
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
Ad

Recently uploaded (20)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
cuic standard and advanced reporting.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation theory and applications.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
A Presentation on Artificial Intelligence
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Electronic commerce courselecture one. Pdf
PDF
A comparative analysis of optical character recognition models for extracting...
20250228 LYD VKU AI Blended-Learning.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Machine learning based COVID-19 study performance prediction
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
cuic standard and advanced reporting.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
gpt5_lecture_notes_comprehensive_20250812015547.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Dropbox Q2 2025 Financial Results & Investor Presentation
MYSQL Presentation for SQL database connectivity
Encapsulation theory and applications.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
MIND Revenue Release Quarter 2 2025 Press Release
A Presentation on Artificial Intelligence
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Electronic commerce courselecture one. Pdf
A comparative analysis of optical character recognition models for extracting...

Migration microservices to GraphQL