GraphQL? REST API?
Or maybe you can have both!
Roy Mor
@RoyMorTech
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
GraphQL? REST API?
Or maybe you can have both!
Roy Mor
@RoyMorTech
Have your cake and eat it too?
Roy Mor
Tech Lead at Sisense
linkedin.com/in/roy-mor/
@RoyMorTech
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
Choosing an internal API paradigm
for your tech stack:
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
Schema describes the
shape and relationships
of the data
Client queries use the
types defined in the
schema
GraphQL API responses
are regular JSON – just
like REST responses
• Avoids under-fetching: single round trip (instead of multiple requests in REST)
• Avoids over-fetching: client specifies exactly the fields it needs
• Increased velocity for our development teams
• Once the schema is set – frontend and backend teams can work independently
• Clear communication, less meetings, schema is single-source-of-truth, changes are easy
• Better developer experience for front-end devs:
• No more post-processing on API responses
• ”Free” (built-in) validation and auto-documentation – due to GraphQL type system
• Better UI performance: reduced payloads and roundtrips
API as data query language
• Schema based
• Strongly typed
• Self documenting & built-in input validation
• Client centric: client specifies exactly what data it needs
• Better developer experience, faster development cycles
• Better performance: smaller payloads & fewer roundtrips
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
Got API?
O
GraphQL API!
…but the world still wants a REST API!
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
REST APIs
• The “de facto standard” for companies deploying APIs and developer platforms
• Proven for decades in large scale
• For user: simple to use, uniform interface, doesn’t require special libraries, common knowledge
• Leverages HTTP semantics, conventions and logic
O
(Yonatan Maman)
• We have an existing internal GraphQL API
• We need to expose an external REST API with the same functionality
Offer REST & GraphQL concurrently, running side by side
Problem Statement
1. Develop REST API manually from scratch?
2. Manually wrap GraphQL API with REST?
Our options
It’s just not cost-effective to develop, test and maintain two code
paths with the same functionality, and keep them in parity over time.
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
GraphQL2REST is a Node.js library that reads your GraphQL schema and
automatically generates an Express router with fully RESTful HTTP
routes —a full-fledged REST API.
• Creates REST endpoints based on GraphQL schema and a manifest file that you edit
• Full customization: your REST API could be very different than your GraphQL layer
github.com/sisense/graphql2rest
graphql2rest on npm
We open sourced it:
We automatically generated a truly RESTful API
without writing a single line of API code
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
Pre processing step: generateGqlQueryFiles()
• One-time only step; can be run at “build time”, or by script
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
”Fully exploded” GraphQL
client queries – saved as files
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
ç
Manifest describes all REST
endpoints, customizations
and mapping to GraphQL
operations
ç
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
At Runtime:
At Runtime:
At Runtime:
At Runtime:
At Runtime:
At Runtime:
At Runtime:
200 OKAt Runtime:
GraphQL2REST: manifest.json
• Describes all REST endpoints and mapping rules to GraphQL operations
In REST HTTP: GET /tweets/1234 (200 OK)
GraphQL: getTweetById(id: 1234)
GraphQL2REST: manifest.json
• Describes all REST endpoints and mapping rules to GraphQL operations
In REST HTTP: GET /tweets/1234 (200 OK)
 HTTP route path
 HTTP method
GraphQL: getTweetById(id: 1234)
 GraphQL operation to map to
GraphQL2REST: manifest.json
 GraphQL operation name
 Rename parameters
 Customize status code
 Allow flat REST request body
 Omit fields from REST response
PATCH /users/1234 | body = {"name": "Joe", "birthday": "1990-1-15"}
202 Accepted
Mutation updateUserData(userOid: UUID!, newData: userDataInput!): User
Exposes two public functions:
• generateGqlQueryFiles() - schema pre-processing
• init() - generate Express router at runtime
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
Demo Time!
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor
End Demo
GraphQL2REST
o Works with any type of GraphQL server (local, remote, apollo-link, fetch….)
o Customize (almost) everything
o Response format
o Error format
o Status codes (for errors too)
o Parameter names and mappings
o Map a single REST endpoint to multiple GraphQL operations
o Hide fields
o Built-in filter for client
o And more….
We automatically generated a truly RESTful API
without writing a single line of API code
Should you choose GraphQL or REST
for your public API?
Why choose GraphQL for your INTERNAL API?
• Increased velocity for development teams
• Once the schema is set – frontend and backend teams can work independently
• Clear communication, less meetings, schema is single-source-of-truth, changes are easy
• Better developer experience for front-end devs:
• No more post-processing on API responses
• ”Free” (built-in) validation and auto-documentation
• Better UI performance: reduced payloads and roundtrips, easier for multi-client
Why not GraphQL?
• Doesn’t shine in ALL use cases
• Caching is not straightforward (HTTP POST) – requires extra libraries
• Error handling – errors are ambiguous (compare to REST)
• File upload is not straightforward
• Solution: base64? Extra libraries?
• Security: exposed to DOS attacks because the client has the control
• Solution: maximal query nesting level, timeouts, rate limits… needs configuration
• Schema is public, so no “internal”, “hidden”, “private” endpoints for sensitive queries
• No conventions like in REST – it’s on US to implement or use extra libraries
Everything has a proper solution! Just not out-of-the-box
There’s a strong case for using GraphQL as an internal API.
Is the world ready for GraphQL Public APIs?
(what is the difference anyway…)
GraphQL Public APIs
GraphQL Public APIs
Effects of going for GraphQL Public API
• “Since our application engineers are using the same GraphQL
platform that we’re making available to our integrators, this provides
us with the opportunity to ship UI features in conjunction
with API access.
Using GraphQL on the frontend and backend eliminates the gap
between what we release and what you can consume.” –
GitHub
Possible Issues with Public GraphQL API
“GraphQL is client-centric, not server-driven”:
• GraphQL moves too much of the burden to the user of the API
• “Query building is tedious”, “frustration”, “unnecessarily complex compared to good ol’ REST”
• Large learning curve for teams/people who might not be interested in using GraphQL
• The internal team would have a vested interest in introspecting the API but an external
developer might not.
• Top client-side performance requires using external libraries
• Is this an error or not? ”Lost exceptions”, partial errors, monitoring becomes not
straightforward
• Using REST = familiar framework = minimize ”business risk” (De-risking)
Public APIs: GraphQL vs REST – any conclusion?
• GraphQL is a great technology, but not a silver bullet
• Good tech reasons to choose GraphQL, but also other considerations:
• Market penetration
• Public API user preferences, habits, needs, skills
• Take a leap of faith like GitHub?
• Gather information, survery our customers / developers?
We automatically generated a truly RESTful API
without writing a single line of API code
github.com/sisense/graphql2rest
npm: graphql2rest
Roy Mor
roy.mor@sisense.com
linkedin.com/in/roy-mor/
RoyMorTech
Thank You!
Roy Mor (roy.mor@sisense.com)
Thank You!
Q&A
Roy Mor (roy.mor@sisense.com)
https://www.linkedin.com/in/roy-mor/
https://github.com/sisense

More Related Content

PPTX
apidays LIVE Australia 2020 - Productising your Microservices as API Products...
PPTX
apidays LIVE Australia 2020 - Leveraging DevOps to visualize your digital eco...
PDF
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
PDF
apidays LIVE Hong Kong 2021 - Multi-Protocol APIs at Scale in Adidas by Jesus...
PPTX
Tools and techniques for APIs
PDF
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
PDF
apidays LIVE Paris - GraphQL meshes by Jens Neuse
PDF
Build pipelines with TeamCity and Kotlin DSL
apidays LIVE Australia 2020 - Productising your Microservices as API Products...
apidays LIVE Australia 2020 - Leveraging DevOps to visualize your digital eco...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Hong Kong 2021 - Multi-Protocol APIs at Scale in Adidas by Jesus...
Tools and techniques for APIs
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Paris - GraphQL meshes by Jens Neuse
Build pipelines with TeamCity and Kotlin DSL

What's hot (20)

PDF
GraphQL: The Missing Link Between Frontend and Backend Devs
PDF
API Centric Development in PHP
PPTX
WSO2 Product Release Webinar - WSO2 App Factory 2.1
PDF
apidays LIVE Paris - Augmenting a Legacy REST API with GraphQL by Clément Vil...
PDF
Tools for designing and building great APIs
PDF
Scaling Your Team With GraphQL: Why Relationships Matter
PDF
Why your APIs should fly first class
PPTX
Running the-next-generation-of-cloud-native-applications-using-open-applicati...
PDF
REST vs. GraphQL: Critical Look
PDF
APIdays Helsinki 2019 - The Future of the Dynamic Application Server, NGINX U...
PDF
apidays LIVE Paris - The Rise of GraphQL for database APIs by Karthic Rao
PDF
Itb 2021 - Bulding Quick APIs by Gavin Pickin
PDF
Introduction to GraphQL
PDF
apidays LIVE Paris - GraphQL: the AppSec perspective by Vladimir de Turckheim
PDF
INTERFACE by apidays_Vulcain: beat GraphQL with HTTP/2+ by Kevin Dunglas
PPTX
apidays LIVE Paris 2021 - Inside API delivery Pipeline, the checklist! - Fran...
PDF
A Hitchhiker's Guide to Cloud-Native API Gateways
PPTX
Continuous Integration and Delivery at Shapeways (Matt Boyle)
PDF
OpenAPI Spec at Google (Open API Initiative Meetup on 2016-09-15)
PPTX
Into to GraphQL
GraphQL: The Missing Link Between Frontend and Backend Devs
API Centric Development in PHP
WSO2 Product Release Webinar - WSO2 App Factory 2.1
apidays LIVE Paris - Augmenting a Legacy REST API with GraphQL by Clément Vil...
Tools for designing and building great APIs
Scaling Your Team With GraphQL: Why Relationships Matter
Why your APIs should fly first class
Running the-next-generation-of-cloud-native-applications-using-open-applicati...
REST vs. GraphQL: Critical Look
APIdays Helsinki 2019 - The Future of the Dynamic Application Server, NGINX U...
apidays LIVE Paris - The Rise of GraphQL for database APIs by Karthic Rao
Itb 2021 - Bulding Quick APIs by Gavin Pickin
Introduction to GraphQL
apidays LIVE Paris - GraphQL: the AppSec perspective by Vladimir de Turckheim
INTERFACE by apidays_Vulcain: beat GraphQL with HTTP/2+ by Kevin Dunglas
apidays LIVE Paris 2021 - Inside API delivery Pipeline, the checklist! - Fran...
A Hitchhiker's Guide to Cloud-Native API Gateways
Continuous Integration and Delivery at Shapeways (Matt Boyle)
OpenAPI Spec at Google (Open API Initiative Meetup on 2016-09-15)
Into to GraphQL
Ad

Similar to apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor (20)

PPTX
GraphQL.pptx
PPTX
GraphQL.pptx
PDF
codersera_com (1).pdf
PDF
Graphql
PDF
Modern APIs with GraphQL
PPTX
REST API vs. GraphQL: Which Should You Pick for Your Project?
PPTX
The API Journey: from REST to GraphQL
PPTX
Introduction to Graph QL
PDF
GraphQL over REST at Reactathon 2018
PDF
Boost your APIs with GraphQL
PDF
GraphQL in an Age of REST
PDF
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
PDF
PDF
All you need to know about GraphQL.pdf
PPTX
apidays Munich 2025 - GraphQL 101: I won't REST, until you GraphQL, Surbhi Si...
PPTX
APIdays Helsinki 2019 - Beyond REST: GraphQL API Management with Amit Acharya...
PDF
GraphQL for Native Apps
PDF
DEVOXX UK 2018 - GraphQL as an alternative approach to REST
PPTX
Introduction to GraphQL
PDF
GraphQL- Presentation
GraphQL.pptx
GraphQL.pptx
codersera_com (1).pdf
Graphql
Modern APIs with GraphQL
REST API vs. GraphQL: Which Should You Pick for Your Project?
The API Journey: from REST to GraphQL
Introduction to Graph QL
GraphQL over REST at Reactathon 2018
Boost your APIs with GraphQL
GraphQL in an Age of REST
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
All you need to know about GraphQL.pdf
apidays Munich 2025 - GraphQL 101: I won't REST, until you GraphQL, Surbhi Si...
APIdays Helsinki 2019 - Beyond REST: GraphQL API Management with Amit Acharya...
GraphQL for Native Apps
DEVOXX UK 2018 - GraphQL as an alternative approach to REST
Introduction to GraphQL
GraphQL- Presentation
Ad

More from apidays (20)

PDF
apidays Munich 2025 - The Physics of Requirement Sciences Through Application...
PDF
apidays Munich 2025 - Developer Portals, API Catalogs, and Marketplaces, Miri...
PDF
apidays Munich 2025 - Making Sense of AI-Ready APIs in a Buzzword World, Andr...
PDF
apidays Munich 2025 - Integrate Your APIs into the New AI Marketplace, Senthi...
PDF
apidays Munich 2025 - The Double Life of the API Product Manager, Emmanuel Pa...
PDF
apidays Munich 2025 - Let’s build, debug and test a magic MCP server in Postm...
PDF
apidays Munich 2025 - The life-changing magic of great API docs, Jens Fischer...
PDF
apidays Munich 2025 - Automating Operations Without Reinventing the Wheel, Ma...
PDF
apidays Munich 2025 - Geospatial Artificial Intelligence (GeoAI) with OGC API...
PPTX
apidays Munich 2025 - Effectively incorporating API Security into the overall...
PPTX
apidays Munich 2025 - Federated API Management and Governance, Vince Baker (D...
PPTX
apidays Munich 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (Aavista Oy)
PPTX
apidays Munich 2025 - Streamline & Secure LLM Traffic with APISIX AI Gateway ...
PPTX
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
PPTX
apidays Munich 2025 - Building an AWS Serverless Application with Terraform, ...
PDF
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
PDF
apidays Helsinki & North 2025 - Monetizing AI APIs: The New API Economy, Alla...
PDF
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
PDF
apidays Helsinki & North 2025 - APIs in the healthcare sector: hospitals inte...
PDF
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays Munich 2025 - The Physics of Requirement Sciences Through Application...
apidays Munich 2025 - Developer Portals, API Catalogs, and Marketplaces, Miri...
apidays Munich 2025 - Making Sense of AI-Ready APIs in a Buzzword World, Andr...
apidays Munich 2025 - Integrate Your APIs into the New AI Marketplace, Senthi...
apidays Munich 2025 - The Double Life of the API Product Manager, Emmanuel Pa...
apidays Munich 2025 - Let’s build, debug and test a magic MCP server in Postm...
apidays Munich 2025 - The life-changing magic of great API docs, Jens Fischer...
apidays Munich 2025 - Automating Operations Without Reinventing the Wheel, Ma...
apidays Munich 2025 - Geospatial Artificial Intelligence (GeoAI) with OGC API...
apidays Munich 2025 - Effectively incorporating API Security into the overall...
apidays Munich 2025 - Federated API Management and Governance, Vince Baker (D...
apidays Munich 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (Aavista Oy)
apidays Munich 2025 - Streamline & Secure LLM Traffic with APISIX AI Gateway ...
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays Munich 2025 - Building an AWS Serverless Application with Terraform, ...
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
apidays Helsinki & North 2025 - Monetizing AI APIs: The New API Economy, Alla...
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
apidays Helsinki & North 2025 - APIs in the healthcare sector: hospitals inte...
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...

Recently uploaded (20)

PDF
Aug23rd - Mulesoft Community Workshop - Hyd, India.pdf
PDF
4 layer Arch & Reference Arch of IoT.pdf
PPTX
Internet of Everything -Basic concepts details
PPTX
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
PDF
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
PDF
SaaS reusability assessment using machine learning techniques
PDF
NewMind AI Weekly Chronicles – August ’25 Week IV
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
Statistics on Ai - sourced from AIPRM.pdf
PDF
Improvisation in detection of pomegranate leaf disease using transfer learni...
PDF
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
PDF
Enhancing plagiarism detection using data pre-processing and machine learning...
PDF
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
PDF
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
PDF
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
DOCX
Basics of Cloud Computing - Cloud Ecosystem
PDF
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PPTX
future_of_ai_comprehensive_20250822032121.pptx
PDF
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
Aug23rd - Mulesoft Community Workshop - Hyd, India.pdf
4 layer Arch & Reference Arch of IoT.pdf
Internet of Everything -Basic concepts details
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
SaaS reusability assessment using machine learning techniques
NewMind AI Weekly Chronicles – August ’25 Week IV
sbt 2.0: go big (Scala Days 2025 edition)
Statistics on Ai - sourced from AIPRM.pdf
Improvisation in detection of pomegranate leaf disease using transfer learni...
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
Enhancing plagiarism detection using data pre-processing and machine learning...
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
Basics of Cloud Computing - Cloud Ecosystem
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
Convolutional neural network based encoder-decoder for efficient real-time ob...
future_of_ai_comprehensive_20250822032121.pptx
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf

apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? Why not have both! by Roy Mor

  • 1. GraphQL? REST API? Or maybe you can have both! Roy Mor @RoyMorTech
  • 3. GraphQL? REST API? Or maybe you can have both! Roy Mor @RoyMorTech
  • 4. Have your cake and eat it too?
  • 5. Roy Mor Tech Lead at Sisense linkedin.com/in/roy-mor/ @RoyMorTech
  • 14. Choosing an internal API paradigm for your tech stack:
  • 17. Schema describes the shape and relationships of the data Client queries use the types defined in the schema GraphQL API responses are regular JSON – just like REST responses
  • 18. • Avoids under-fetching: single round trip (instead of multiple requests in REST) • Avoids over-fetching: client specifies exactly the fields it needs
  • 19. • Increased velocity for our development teams • Once the schema is set – frontend and backend teams can work independently • Clear communication, less meetings, schema is single-source-of-truth, changes are easy • Better developer experience for front-end devs: • No more post-processing on API responses • ”Free” (built-in) validation and auto-documentation – due to GraphQL type system • Better UI performance: reduced payloads and roundtrips
  • 20. API as data query language • Schema based • Strongly typed • Self documenting & built-in input validation • Client centric: client specifies exactly what data it needs • Better developer experience, faster development cycles • Better performance: smaller payloads & fewer roundtrips
  • 24. …but the world still wants a REST API!
  • 26. REST APIs • The “de facto standard” for companies deploying APIs and developer platforms • Proven for decades in large scale • For user: simple to use, uniform interface, doesn’t require special libraries, common knowledge • Leverages HTTP semantics, conventions and logic
  • 28. • We have an existing internal GraphQL API • We need to expose an external REST API with the same functionality Offer REST & GraphQL concurrently, running side by side Problem Statement
  • 29. 1. Develop REST API manually from scratch? 2. Manually wrap GraphQL API with REST? Our options It’s just not cost-effective to develop, test and maintain two code paths with the same functionality, and keep them in parity over time.
  • 32. GraphQL2REST is a Node.js library that reads your GraphQL schema and automatically generates an Express router with fully RESTful HTTP routes —a full-fledged REST API.
  • 33. • Creates REST endpoints based on GraphQL schema and a manifest file that you edit • Full customization: your REST API could be very different than your GraphQL layer
  • 35. We automatically generated a truly RESTful API without writing a single line of API code
  • 38. Pre processing step: generateGqlQueryFiles() • One-time only step; can be run at “build time”, or by script
  • 40. ”Fully exploded” GraphQL client queries – saved as files
  • 42. ç
  • 43. Manifest describes all REST endpoints, customizations and mapping to GraphQL operations ç
  • 53. GraphQL2REST: manifest.json • Describes all REST endpoints and mapping rules to GraphQL operations In REST HTTP: GET /tweets/1234 (200 OK) GraphQL: getTweetById(id: 1234)
  • 54. GraphQL2REST: manifest.json • Describes all REST endpoints and mapping rules to GraphQL operations In REST HTTP: GET /tweets/1234 (200 OK)  HTTP route path  HTTP method GraphQL: getTweetById(id: 1234)  GraphQL operation to map to
  • 55. GraphQL2REST: manifest.json  GraphQL operation name  Rename parameters  Customize status code  Allow flat REST request body  Omit fields from REST response PATCH /users/1234 | body = {"name": "Joe", "birthday": "1990-1-15"} 202 Accepted Mutation updateUserData(userOid: UUID!, newData: userDataInput!): User
  • 56. Exposes two public functions: • generateGqlQueryFiles() - schema pre-processing • init() - generate Express router at runtime
  • 61. GraphQL2REST o Works with any type of GraphQL server (local, remote, apollo-link, fetch….) o Customize (almost) everything o Response format o Error format o Status codes (for errors too) o Parameter names and mappings o Map a single REST endpoint to multiple GraphQL operations o Hide fields o Built-in filter for client o And more….
  • 62. We automatically generated a truly RESTful API without writing a single line of API code
  • 63. Should you choose GraphQL or REST for your public API?
  • 64. Why choose GraphQL for your INTERNAL API? • Increased velocity for development teams • Once the schema is set – frontend and backend teams can work independently • Clear communication, less meetings, schema is single-source-of-truth, changes are easy • Better developer experience for front-end devs: • No more post-processing on API responses • ”Free” (built-in) validation and auto-documentation • Better UI performance: reduced payloads and roundtrips, easier for multi-client
  • 65. Why not GraphQL? • Doesn’t shine in ALL use cases • Caching is not straightforward (HTTP POST) – requires extra libraries • Error handling – errors are ambiguous (compare to REST) • File upload is not straightforward • Solution: base64? Extra libraries? • Security: exposed to DOS attacks because the client has the control • Solution: maximal query nesting level, timeouts, rate limits… needs configuration • Schema is public, so no “internal”, “hidden”, “private” endpoints for sensitive queries • No conventions like in REST – it’s on US to implement or use extra libraries Everything has a proper solution! Just not out-of-the-box
  • 66. There’s a strong case for using GraphQL as an internal API. Is the world ready for GraphQL Public APIs? (what is the difference anyway…)
  • 69. Effects of going for GraphQL Public API • “Since our application engineers are using the same GraphQL platform that we’re making available to our integrators, this provides us with the opportunity to ship UI features in conjunction with API access. Using GraphQL on the frontend and backend eliminates the gap between what we release and what you can consume.” – GitHub
  • 70. Possible Issues with Public GraphQL API “GraphQL is client-centric, not server-driven”: • GraphQL moves too much of the burden to the user of the API • “Query building is tedious”, “frustration”, “unnecessarily complex compared to good ol’ REST” • Large learning curve for teams/people who might not be interested in using GraphQL • The internal team would have a vested interest in introspecting the API but an external developer might not. • Top client-side performance requires using external libraries • Is this an error or not? ”Lost exceptions”, partial errors, monitoring becomes not straightforward • Using REST = familiar framework = minimize ”business risk” (De-risking)
  • 71. Public APIs: GraphQL vs REST – any conclusion? • GraphQL is a great technology, but not a silver bullet • Good tech reasons to choose GraphQL, but also other considerations: • Market penetration • Public API user preferences, habits, needs, skills • Take a leap of faith like GitHub? • Gather information, survery our customers / developers?
  • 72. We automatically generated a truly RESTful API without writing a single line of API code