SlideShare une entreprise Scribd logo
1  sur  76
Télécharger pour lire hors ligne
APIs The New Way
Volodymyr Tsukur
API,
Volodymyr Tsukur
not DB!
Volodymyr Tsukur
Lead Engineer,
Guild Master @
Partner @
EASYHUNT
Program Committee @
JEEConf, XP Days
flushdia vtsukur
Lithuania
Ukraine
Kyiv
Dnipro
Vilnius
Локации Wix Engineering
Israel
Tel Aviv
Be’er Sheva
~ 110M+ users*
~ 700 engineers
~ 1800 employees
~ 500 microservices
title
price
images
description
info
...
{
}
GET /products/:id
imagesimages(1)
priceprice
titletitle
[
]
description
GET /products
...
info
{
}
10%!
OVER-fetching
01
GET /carts/:id
items [
{
product
quantity
total
}
{
}
]
subTotal
GET /carts/1
GET /products/59eb838e3f
GET /products/59eb88c400
GET /products/59eb838e40
- UNDER-fetching
- extra requests
02
GET /carts/1?projection=with-products
...
GET /carts/1?projection=summary
GET /carts/1?projection=
GET /carts/1?projection=
GET /carts/1?projection=with-products
- no unified & widely adopted
standard :( *
- harder to collaborate :(
03
How to @deprecate and
phase out outdated stuff?
04
2012
2015
“... is a query language for APIs and a runtime for
fulfilling those queries with your existing data”
type User {
name: String
friends: [User]
city: City
}
type City {
name: String
population: Int
citizens: [User]
}
1. Define schema
{
user(name: String): User
...
}
2. Ask for data
user(name: String): User
2. Ask for data
{
user(name: “Vanya Unicorn”) {
friends {
name
}
city {
name
population
}
}
}
3. Get it!
{
user(name: “Vanya Unicorn”) {
friends {
name
}
city {
name
population
}
}
}
{
“data”: {
“user”: {
“friends”: [
{ “name”: “Lena” },
{ “name”: “Stas” }
]
“city”: {
“name”: “Kyiv”,
“population”: 2928087
}
}
}
}
only necessary data
{
“data”: {
“user”: {
“friends”: [
{ “name”: “Lena” },
{ “name”: “Stas” }
]
“city”: {
“name”: “Kyiv”,
“population”: 2928087
}
}
}
}
{
user(name: “Vanya Unicorn”) {
friends {
name
}
city {
name
population
}
}
}
in one request *
{
“data”: {
“user”: {
“friends”: [
{ “name”: “Lena” },
{ “name”: “Stas” }
]
“city”: {
“name”: “Kyiv”,
“population”: 2928087
}
}
}
}
{
user(name: “Vanya Unicorn”) {
friends {
name
}
city {
name
population
}
}
}
HTTP POST
let us see how it works!
WYSIWYG
efficient fetching
easier to develop
analytics
any data source and transport
graphql-java
HTTP
Cart Service
Product Service
let us rock and roll!
running query
{
cart(id: 1) {
items {
product {
title
price
images(limit: 1)
sku
}
quantity
total
}
subTotal
}
}
1)
{
cart(id: 1) {
items {
product {
title
price
images(limit: 1)
sku
}
quantity
total
}
subTotal
}
}
2) SELECT ... FROM Cart
INNER JOIN Item ...
{
cart(id: 1) {
items {
product {
title
price
images(limit: 1)
sku
}
quantity
total
}
subTotal
}
}
3)
+ n x
product {
title
price
images(limit: 1)
sku
}
product {
title
price
images(limit: 1)
sku
}
GET /products/1
GET /products/2
GET /products/3
e x p e c t a t i o n s
R
e
a
l
i
t
y
{
cart(id: 1) {
items {
product {
title
price
images(limit: 1)
sku
}
quantity
total
}
subTotal
}
}
+
GET /products?ids=1,2,3
@Batched
let’s fix it!
Security
{
user(name: “Vanya Unicorn”) {
friends {
name
friends {
name
friends {
name
friends {
name
...
}
}
}
}
}
}
limit query depth
limit query complexity
let us defend!
throttling / rate limiting
set timeouts
pagination
schema {
query: Query
}
schema {
query: Query,
mutation: Mutation
}
type Mutation {
addProductToCart(cart: ID!,
product: ID!,
count: Int = 1): Cart
}
let us mutate!
+
+
I want it !!!
but let us see the BAD parts
caching
security
error handling
arbitrary resources / file uploads
operation idempotency?
operation naming
hypermedia
Java ecosystem
Alternatives
https://philsturgeon.uk/api/2017/01/24/graphql-vs-rest-overview/
https://blog.runscope.com/posts/you-might-not-need-graphql
NO !!!
but it shines
as an
integrated
solution
schema {
query: Query,
mutation: Mutation,
subscription: Subscription
}
type Subscription {
productAdded(cart: ID!): Cart
}
subscription {
productAdded(cart: 123) {
items {
product ...
}
subTotal
}
}
{
“data”: {
“productAdded”: {
“items”: [
{ “product”: ... },
{ “product”: ... },
{ “product”: ... },
{ “product”: ... }
]
“subTotal”: 289.33
}
}
}
://
{
“data”: {
“productAdded”: {
“items”: [
{ “product”: ... },
{ “product”: ... },
{ “product”: ... },
{ “product”: ... }
]
“subTotal”: 289.33
}
}
}
subscription {
productAdded(cart: 123) {
items {
product ...
}
subTotal
}
}
://
https://github.com/vtsukur/graphql-java-store
sample, not
production
ready code!
Questions?
volodymyrt@wix.com
flushdia vtsukur

Contenu connexe

Tendances

GPars howto - when to use which concurrency abstraction
GPars howto - when to use which concurrency abstractionGPars howto - when to use which concurrency abstraction
GPars howto - when to use which concurrency abstraction
Vaclav Pech
 
D3 Basic Tutorial
D3 Basic TutorialD3 Basic Tutorial
D3 Basic Tutorial
Tao Jiang
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVM
Vaclav Pech
 

Tendances (19)

Eclipse Modeling Guided Tour - EcoreTools
Eclipse Modeling Guided Tour - EcoreToolsEclipse Modeling Guided Tour - EcoreTools
Eclipse Modeling Guided Tour - EcoreTools
 
D3.js workshop
D3.js workshopD3.js workshop
D3.js workshop
 
Introduction to d3js (and SVG)
Introduction to d3js (and SVG)Introduction to d3js (and SVG)
Introduction to d3js (and SVG)
 
コードで学ぶドメイン駆動設計入門
コードで学ぶドメイン駆動設計入門コードで学ぶドメイン駆動設計入門
コードで学ぶドメイン駆動設計入門
 
Pick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruitPick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruit
 
Fun with D3.js: Data Visualization Eye Candy with Streaming JSON
Fun with D3.js: Data Visualization Eye Candy with Streaming JSONFun with D3.js: Data Visualization Eye Candy with Streaming JSON
Fun with D3.js: Data Visualization Eye Candy with Streaming JSON
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tips
 
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
 
Real-time collaboration in distributed systems for JavaScript developers. 
Real-time collaboration in distributed systems for JavaScript developers. Real-time collaboration in distributed systems for JavaScript developers. 
Real-time collaboration in distributed systems for JavaScript developers. 
 
Functional Javascript, CVjs
Functional Javascript, CVjsFunctional Javascript, CVjs
Functional Javascript, CVjs
 
Kotlin Mullets
Kotlin MulletsKotlin Mullets
Kotlin Mullets
 
GPars howto - when to use which concurrency abstraction
GPars howto - when to use which concurrency abstractionGPars howto - when to use which concurrency abstraction
GPars howto - when to use which concurrency abstraction
 
CS101- Introduction to Computing- Lecture 41
CS101- Introduction to Computing- Lecture 41CS101- Introduction to Computing- Lecture 41
CS101- Introduction to Computing- Lecture 41
 
D3 Basic Tutorial
D3 Basic TutorialD3 Basic Tutorial
D3 Basic Tutorial
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVM
 
Learn D3.js in 90 minutes
Learn D3.js in 90 minutesLearn D3.js in 90 minutes
Learn D3.js in 90 minutes
 
App bot
App botApp bot
App bot
 
Viewpic
ViewpicViewpic
Viewpic
 
Thunderstruck
ThunderstruckThunderstruck
Thunderstruck
 

Similaire à GraphQL - APIs The New Way

Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Roel Hartman
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
Chris Alfano
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
FIWARE
 

Similaire à GraphQL - APIs The New Way (20)

Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
 
HTML5 and Other Modern Browser Game Tech
HTML5 and Other Modern Browser Game TechHTML5 and Other Modern Browser Game Tech
HTML5 and Other Modern Browser Game Tech
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
Map Reduce: Which Way To Go?
Map Reduce: Which Way To Go?Map Reduce: Which Way To Go?
Map Reduce: Which Way To Go?
 
Big Data Tools in AWS
Big Data Tools in AWSBig Data Tools in AWS
Big Data Tools in AWS
 
Reactive Type-safe WebComponents
Reactive Type-safe WebComponentsReactive Type-safe WebComponents
Reactive Type-safe WebComponents
 
e-suap - client technologies- english version
e-suap - client technologies- english versione-suap - client technologies- english version
e-suap - client technologies- english version
 
OpenStack API's and WSGI
OpenStack API's and WSGIOpenStack API's and WSGI
OpenStack API's and WSGI
 
Open Source Ajax Solution @OSDC.tw 2009
Open Source Ajax  Solution @OSDC.tw 2009Open Source Ajax  Solution @OSDC.tw 2009
Open Source Ajax Solution @OSDC.tw 2009
 
Qt Workshop
Qt WorkshopQt Workshop
Qt Workshop
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
 
Google Web Toolkit
Google Web ToolkitGoogle Web Toolkit
Google Web Toolkit
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
2013 - Nate Abele: HTTP ALL THE THINGS: Simplificando aplicaciones respetando...
2013 - Nate Abele: HTTP ALL THE THINGS: Simplificando aplicaciones respetando...2013 - Nate Abele: HTTP ALL THE THINGS: Simplificando aplicaciones respetando...
2013 - Nate Abele: HTTP ALL THE THINGS: Simplificando aplicaciones respetando...
 
Sql Portfolio
Sql PortfolioSql Portfolio
Sql Portfolio
 
Reactive Type safe Webcomponents with skateJS
Reactive Type safe Webcomponents with skateJSReactive Type safe Webcomponents with skateJS
Reactive Type safe Webcomponents with skateJS
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
 
He stopped using for/while loops, you won't believe what happened next!
He stopped using for/while loops, you won't believe what happened next!He stopped using for/while loops, you won't believe what happened next!
He stopped using for/while loops, you won't believe what happened next!
 

Plus de Vladimir Tsukur

Abstraction Classes in Software Design
Abstraction Classes in Software DesignAbstraction Classes in Software Design
Abstraction Classes in Software Design
Vladimir Tsukur
 
Acceptance Testing of Web UI
Acceptance Testing of Web UIAcceptance Testing of Web UI
Acceptance Testing of Web UI
Vladimir Tsukur
 
REpresentational State Transfer
REpresentational State TransferREpresentational State Transfer
REpresentational State Transfer
Vladimir Tsukur
 

Plus de Vladimir Tsukur (11)

Hypermedia APIs and HATEOAS / Wix Engineering
Hypermedia APIs and HATEOAS / Wix EngineeringHypermedia APIs and HATEOAS / Wix Engineering
Hypermedia APIs and HATEOAS / Wix Engineering
 
Hypermedia APIs and HATEOAS
Hypermedia APIs and HATEOASHypermedia APIs and HATEOAS
Hypermedia APIs and HATEOAS
 
Hot and spicy Java with Lombok. Live!
Hot and spicy Java with Lombok. Live!Hot and spicy Java with Lombok. Live!
Hot and spicy Java with Lombok. Live!
 
Building Awesome API with Spring
Building Awesome API with SpringBuilding Awesome API with Spring
Building Awesome API with Spring
 
From CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with SpringFrom CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with Spring
 
Together Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with HypermediaTogether Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with Hypermedia
 
Take a REST!
Take a REST!Take a REST!
Take a REST!
 
Law of Demeter & Objective Sense of Style
Law of Demeter & Objective Sense of StyleLaw of Demeter & Objective Sense of Style
Law of Demeter & Objective Sense of Style
 
Abstraction Classes in Software Design
Abstraction Classes in Software DesignAbstraction Classes in Software Design
Abstraction Classes in Software Design
 
Acceptance Testing of Web UI
Acceptance Testing of Web UIAcceptance Testing of Web UI
Acceptance Testing of Web UI
 
REpresentational State Transfer
REpresentational State TransferREpresentational State Transfer
REpresentational State Transfer
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

GraphQL - APIs The New Way