Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query...
Transcript of Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query...
![Page 1: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/1.jpg)
![Page 2: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/2.jpg)
![Page 3: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/3.jpg)
Designing Future APIs for Modern Microservices World
April 23, 2019
![Page 4: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/4.jpg)
A Tale of Apollo, GraphQL, React & Spring boot
3
![Page 5: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/5.jpg)
AGENDA
4
• What is GraphQL ? • How does it compare with REST? What? • Efficiency • Type Safety • Tooling Why? • How GraphQL is used in Microservices?
• API Gateway • Event Based System • Serverless GraphQL
How?
![Page 6: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/6.jpg)
What is GraphQL?
• GraphQL is a query language for API’s • It provides server side runtime to execute type queries • Uses existing codebase used for REST • Request (GraphQL document) -> JSON Response
GraphQL was developed internally by Facebook in 2012 before being publicly released in 2015
5
![Page 7: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/7.jpg)
6
Client GQL Server
Data Access Layer
Business Layer Data Source
GraphQL Document
JSON Response
GraphQL Server exposes “one API to rule them all”
![Page 8: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/8.jpg)
Demo
7
![Page 9: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/9.jpg)
What is GraphQL ?
8
Query Language for API’s
Query Executor on Schema
For Frontend Developers
For Backend Developers
![Page 10: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/10.jpg)
GraphQL Vs REST
9
![Page 11: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/11.jpg)
GraphQL vs REST
10
REST GraphQL Why
Shared Definition No Yes Schema Specification in GraphQL
Conceptual Model Resources
Graphs Objects and Fields are presented in form of Graphs
Type Safety Weak Strong Strongly typed inputs and outputs
Introspection No Yes Introspect schema while writing query
Real Time No Yes Subscription provide real time data
![Page 12: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/12.jpg)
Challenges with Modern API’s
• EFFICIENCY
• PREDICTABILITY
• VERSIONING
• SECURITY
• DOCUMENTATION
• TOOLING
• CACHING
• .. MANY MORE
11
![Page 13: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/13.jpg)
Why GraphQL?
12
• EFFICIENCY
• Avoid overfetching and underfetching
• Clients to declare all the data they need in a single network request
• Reduces the need of client side joins, error handling and retry logic
• TYPE SAFETY
• Predictability
• TOOLING & DOCUMENTATION
• GraphiQL provides documentation via introspection query
• IDE integrates via GraphQL language service
![Page 14: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/14.jpg)
GraphQL in Microservices
API Gateway
13
![Page 15: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/15.jpg)
GraphQL in Microservices
Microservices
14
• Core Idea – Iterate on your part without blocking others
• Write different backbend's and features in different technologies
• Own your own data and enable more vertically integrated teams • Independently version the backend's to avoid monolithic release
process
![Page 16: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/16.jpg)
API Gateway
15
Messaging
Account Management Session
Web App Native App Other Service
REST REST REST
API Gateway
One centralized schema containing all REST details of underlying microservices
![Page 17: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/17.jpg)
API Gateway
16 Messaging
Account Management Session
Web App Native App Other Service
REST REST REST
API Gateway
One parent schema for all the underlying schema
![Page 18: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/18.jpg)
Schema Stitching
Schema stitching is the process of creating a single GraphQL schema from multiple underlying GraphQL APIs.
17
![Page 19: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/19.jpg)
GraphQL in Microservices
Schema stitching is the process of creating a single GraphQL schema from multiple underlying GraphQL APIs.
18
![Page 20: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/20.jpg)
GraphQL in Microservices (Event Driven)
Event System
Account Management Session
Login Messages Create
Messaging Alarm
Login
Subscriptions in GraphQL are being used to create event driven system architecture
![Page 21: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/21.jpg)
What makes Serverless and GraphQL a great fit?
20
![Page 22: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/22.jpg)
Serverless GraphQL
I have this code which I want to run
Just make it run and scale
1. No server management
2. Pay-per-execution (never pay for idle)
3. Auto-scale (scale based on demand)
4. Function as a unit of application logic
What is Serverless?
21
![Page 23: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/23.jpg)
22
Resources
• How To GraphQL - https://www.howtographql.com/
• Server – Server communication - https://medium.com/open-graphql/graphql-bindings-for-service-to-
service-communication-d1e89df66ecd
• Schema Stitching - https://blog.hasura.io/the-ultimate-guide-to-schema-stitching-in-graphql-
f30178ac0072/
• Serverless GraphQL
• https://acloud.guru/learn/serverless-with-graphql
• https://blog.pusher.com/graphql-api-serverless/
![Page 24: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/24.jpg)
Q&A
23
![Page 25: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/25.jpg)
![Page 26: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/26.jpg)
thank you
copyright publicis sapient | confidential
![Page 27: Designing Future APIs for Modern - DeveloperMarch€¦ · What is GraphQL? • GraphQL is a query language for API’s • It provides server side runtime to execute . type. queries](https://reader034.fdocuments.in/reader034/viewer/2022042300/5eca7ceecb1e5a2e1e634040/html5/thumbnails/27.jpg)