SlideShare a Scribd company logo
A practical guide to
API Management for GraphQL
June 30, 2020
Hello!
Bhathiya Jayasekara
Senior Technical Lead, WSO2
bhathiya@wso2.com
● Introduction to GraphQL
● REST vs GraphQL
● Exposing GraphQL services as Managed APIs
⦿ Authentication
⦿ Authorization
⦿ Rate-Limiting
⦿ Analytics
● API Management for GraphQL demo
What’s covered?
3
What’s GraphQL?
● A query language for your APIs.
● Gives what you request, nothing more and nothing less.
● Ability to make API calls more efficient, flexible, and developer-friendly.
● GraphQL specification is an SDL (Schema Definition Language).
● Created by Facebook in 2012 and released for open-source in 2015.
● Served over HTTP via a single endpoint.
● Specification - https://spec.graphql.org/June2018/
● Reference Implementation - https://github.com/graphql/graphql-js
● Implementations in many languages - https://graphql.org/code/
GraphQL
5
Example: Product-Management Service
6
Retailer
Id: ID
Name: String
Customer
Id: ID
Name: String
Product
Id: ID
Name: String
Category: enum (
CLOTHING
FOOTWEAR
COSMETICS
)
1
r
1 m
n n
● Defines the capabilities of an API
● All the types are exposed in an API, written
down in a language called GraphQL Schema
Definition Language
● Contract between the server and the client.
Once it is defined, both sides are aware of
the data structure
● Query, Mutation, and Subscription root types
7
Type System
8
GraphQL Query
9
GraphQL Mutation
10
GraphQL Subscription
● GraphQL subscriptions allow you to be notified in real-time of changes to your
data.
● Usually implemented with WebSockets or similar technologies.
● Eg: In the Product-Management service, a retailer will be notified whenever a
new Customer node is created.
REST vs GraphQL
REST API Call 1
Fetch a list of all products.
GET /products
12
Example: The retailer wants to know the list of customers who ordered a
particular product.
REST API Call 2
Fetch the list of customer IDs of a
particular product.
GET /products/{id}/customers
13
REST API Call 3...n
Fetch particular customer details by
sending their IDs one by one.
For (each customer) {
GET /products/{id}/customers/{id}
}
GraphQL API Call
Returns the details of a list of
customers of a particular product with
just a single query.
14
● Pros
⦿ No more over-fetching or under-fetching
⦿ Single API call data fetching
⦿ High performance in data fetching networks
⦿ Versionless API evolution
● Cons
⦿ Not good for complex queries
- Slow down performance and kill the efficiency of applications
⦿ No support for HTTP caching
⦿ Overkill for smaller apps
⦿ No support for file uploads
GraphQL: Pros and Cons - Compared to REST
15
API Management for GraphQL
● Authentication
● Role based access control (Authorization)
● Rate limit API traffic
● Detect and block malicious content
● Analytics
Why API Management?
17
Authentication
● APIs are mostly exposed to external users.
● Security plays a major role at this point as it is crucial to ensure that the users
who access the API operations are authentic.
● However, there can be certain API functionalities they are exposed to the
public, giving access to anyone without needing to authenticate with the
system.
Authentication
19
Solution:
REST
GET /products
- Authentication OFF
GET /products/{id}/customers
- Authentication ON
GraphQL
?
20
Example requirement:
1. Allow getting product list without a token
2. Don’t allow getting customers of a product without a token
{
product(id: "2") {
id
name
}
}
- The `product` operation is allowed
without a token
Authentication: GraphQL
21
{
product(id: "2") {
id
name
customer {
name
id
}
}
}
- The `customer` operation is NOT allowed
without a token
Authorization
● Certain API functionalities may need to be accessed by only a subset of users
in the user base.
● For such functionalities, only the authorized parties should have access.
● Typically done with OAuth2 scopes.
Authorization
23
Solution:
REST
● POST /products
- Retailer scope attached
● Decided based on the URL
GraphQL
● Mutation operation “addProduct”
- Retailer scope attached
● Decided based on the payload
24
Example requirement:
1. Don’t allow adding products for non-retailers
2. Allow adding products only for retailers
Rate limiting
● There is only a certain amount of load the API backends can handle at a given
time.
● Can be a part of business plans related to API monetization too.
Rate Limiting
26
REST
● Usually, applied in the form of
TPS/TPM etc.
● Different resources typically have
different rate limit policies.
GraphQL
● TPS/TPM form is not adequate.
● Should be decided based on the
payload too.
● Need more dimensions for the limits
- Query Depth Analysis
- Query Complexity Analysis
● Query depth can be infinite and cyclic.
● Too expensive for the backend
servers.
● Solution: Depth Limit
GraphQL: Query Depth Analysis
27
● Query depth limit may not be
adequate
● The cost of fetching nodes at
different levels can be different
● Solution: Complexity Limit
GraphQL: Query Complexity Analysis
28
● No standard way to calculate
● Different groups follow different approaches
GraphQL: Query Complexity Calculation
29
Example rule 1
● No arguments => multiply by 1
Example rule 2
● Multiply by argument value
Analytics
● Helps you understand how your APIs are being used.
● Business analytics and operational analytics
● REST APIs Analytics at resource level
● GraphQL Analytics at operation level
Analytics
31
Demo
Question Time!
33
wso2.com
Thanks!

More Related Content

PDF
[WSO2 API Day Toronto 2019] Cloud-native Integration for the Enterprise
PDF
Rate Limiting GQLs Using Depth and Complexity Analysis
PDF
[Workshop] API Management in Microservices Architecture
PDF
How to design a good REST API: Tools, techniques and best practices
PDF
API Management 101: The New API Experience with WSO2
PDF
[WSO2 Integration Summit Stuttgart 2019] Decentralizing APIs for Agile Busine...
PDF
[WSO2 Summit EMEA 2020] Building an Interactive API Marketplace
PDF
Leveraging Async APIs to deliver cross domain agile collaboration
[WSO2 API Day Toronto 2019] Cloud-native Integration for the Enterprise
Rate Limiting GQLs Using Depth and Complexity Analysis
[Workshop] API Management in Microservices Architecture
How to design a good REST API: Tools, techniques and best practices
API Management 101: The New API Experience with WSO2
[WSO2 Integration Summit Stuttgart 2019] Decentralizing APIs for Agile Busine...
[WSO2 Summit EMEA 2020] Building an Interactive API Marketplace
Leveraging Async APIs to deliver cross domain agile collaboration

What's hot (20)

PDF
apidays LIVE Paris 2021 - Building an Accessible API Spec with Traditional En...
PDF
Cloud Native API Management : Microservices to APIs in Kubernetes
PDF
WSO2 Product Release Webinar - WSO2 API Manager 1.9
PDF
[apidays LIVE HONK KONG] - OAS to Managed API in Seconds
PPTX
WSO2 Product Release Webinar - WSO2 App Factory 2.1
PDF
API Driven Applications - An ecosystem architecture
PDF
apidays LIVE Paris 2021 - OpenAPI Generator - The Babel Fish of the API World...
PDF
Reducing DevOps Burden with Git-based CI/CD Pipelines for APIs
PDF
[WSO2 Integration Summit London 2019] An API-enabled Journey Towards Empoweri...
PDF
[WSO2 Integration Summit San Francisco 2019] Cloud-native Integration for the...
PDF
[WSO2 Summit Americas 2020] APIs: The Products of the 21st Century.pdf
PDF
WSO2 User Group Bangalore Meetup
PDF
[WSO2 Integration Summit Stuttgart 2019] Role of Integration in an API Driven...
PDF
[WSO2 Summit Americas 2020] Automating an Integrated API Supply Chain Using a...
PDF
Presentation at the 2016 Linux Foundation Collab Summit
PDF
[WSO2 Summit EMEA 2020] Accelerate and Secure Services Integration with WSO2 ...
PDF
[apidays Live Australia] - Quantum Duality of “API as a business and a techno...
PDF
API Management for GraphQL
PDF
Explore the Latest on WSO2 Identity Server 5.11
PDF
[WSO2 Summit APAC 2020} Creating Smart Endpoints Using Integration Microservices
apidays LIVE Paris 2021 - Building an Accessible API Spec with Traditional En...
Cloud Native API Management : Microservices to APIs in Kubernetes
WSO2 Product Release Webinar - WSO2 API Manager 1.9
[apidays LIVE HONK KONG] - OAS to Managed API in Seconds
WSO2 Product Release Webinar - WSO2 App Factory 2.1
API Driven Applications - An ecosystem architecture
apidays LIVE Paris 2021 - OpenAPI Generator - The Babel Fish of the API World...
Reducing DevOps Burden with Git-based CI/CD Pipelines for APIs
[WSO2 Integration Summit London 2019] An API-enabled Journey Towards Empoweri...
[WSO2 Integration Summit San Francisco 2019] Cloud-native Integration for the...
[WSO2 Summit Americas 2020] APIs: The Products of the 21st Century.pdf
WSO2 User Group Bangalore Meetup
[WSO2 Integration Summit Stuttgart 2019] Role of Integration in an API Driven...
[WSO2 Summit Americas 2020] Automating an Integrated API Supply Chain Using a...
Presentation at the 2016 Linux Foundation Collab Summit
[WSO2 Summit EMEA 2020] Accelerate and Secure Services Integration with WSO2 ...
[apidays Live Australia] - Quantum Duality of “API as a business and a techno...
API Management for GraphQL
Explore the Latest on WSO2 Identity Server 5.11
[WSO2 Summit APAC 2020} Creating Smart Endpoints Using Integration Microservices
Ad

Similar to API Management for GraphQL (20)

PDF
Deploying GraphQL Services as Managed APIs
PDF
APIdays Paris 2018 - Secure & Manage APIs with GraphQL, Ozair Sheikh, Directo...
PDF
Exposing GraphQLs as Managed APIs
PPTX
APIdays Helsinki 2019 - Beyond REST: GraphQL API Management with Amit Acharya...
PDF
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
PDF
APIdays Helsinki 2019 - GraphQL API Management with Amit P. Acharya, IBM
PDF
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
PDF
Intro to GraphQL
PDF
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
PDF
APIdays Paris 2019 - Public GraphQL APIs by Tobias Meixner, BRIKL BV
DOCX
GraphQL Advanced Concepts A Comprehensive Guide.docx
PDF
Graphql
PDF
Introduction to GraphQL
PDF
Are you ready to adopt GraphQL?
PDF
GraphQL - A query language to empower your API consumers (NDC Sydney 2017)
DOCX
How to Deploy a GraphQL API A Comprehensive Guide.docx
PPTX
apidays Munich 2025 - GraphQL 101: I won't REST, until you GraphQL, Surbhi Si...
PPTX
GraphQL.pptx
PPTX
GraphQL.pptx
PDF
apidays LIVE Paris - GraphQL meshes by Jens Neuse
Deploying GraphQL Services as Managed APIs
APIdays Paris 2018 - Secure & Manage APIs with GraphQL, Ozair Sheikh, Directo...
Exposing GraphQLs as Managed APIs
APIdays Helsinki 2019 - Beyond REST: GraphQL API Management with Amit Acharya...
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
APIdays Helsinki 2019 - GraphQL API Management with Amit P. Acharya, IBM
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
Intro to GraphQL
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
APIdays Paris 2019 - Public GraphQL APIs by Tobias Meixner, BRIKL BV
GraphQL Advanced Concepts A Comprehensive Guide.docx
Graphql
Introduction to GraphQL
Are you ready to adopt GraphQL?
GraphQL - A query language to empower your API consumers (NDC Sydney 2017)
How to Deploy a GraphQL API A Comprehensive Guide.docx
apidays Munich 2025 - GraphQL 101: I won't REST, until you GraphQL, Surbhi Si...
GraphQL.pptx
GraphQL.pptx
apidays LIVE Paris - GraphQL meshes by Jens Neuse
Ad

More from WSO2 (20)

PDF
Demystifying CMS-0057-F - Compliance Made Seamless with WSO2
PDF
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
PDF
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
PDF
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
PDF
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
PDF
Platformless Modernization with Choreo.pdf
PDF
Application Modernization with Choreo for the BFSI Sector
PDF
Choreo - The AI-Native Internal Developer Platform as a Service: Overview
PDF
[Roundtable] Choreo - The AI-Native Internal Developer Platform as a Service
PPTX
WSO2Con 2025 - Building AI Applications in the Enterprise (Part 1)
PPTX
WSO2Con 2025 - Building Secure Business Customer and Partner Experience (B2B)...
PPTX
WSO2Con 2025 - Building Secure Customer Experience Apps
PPTX
WSO2Con 2025 - AI-Driven API Design, Development, and Consumption with Enhanc...
PPTX
WSO2Con 2025 - AI-Driven API Design, Development, and Consumption with Enhanc...
PPTX
WSO2Con 2025 - Unified Management of Ingress and Egress Across Multiple API G...
PPTX
WSO2Con 2025 - How an Internal Developer Platform Lets Developers Focus on Code
PPTX
WSO2Con 2025 - Architecting Cloud-Native Applications
PDF
Mastering Intelligent Digital Experiences with Platformless Modernization
PDF
Accelerate Enterprise Software Engineering with Platformless
PDF
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
Demystifying CMS-0057-F - Compliance Made Seamless with WSO2
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Platformless Modernization with Choreo.pdf
Application Modernization with Choreo for the BFSI Sector
Choreo - The AI-Native Internal Developer Platform as a Service: Overview
[Roundtable] Choreo - The AI-Native Internal Developer Platform as a Service
WSO2Con 2025 - Building AI Applications in the Enterprise (Part 1)
WSO2Con 2025 - Building Secure Business Customer and Partner Experience (B2B)...
WSO2Con 2025 - Building Secure Customer Experience Apps
WSO2Con 2025 - AI-Driven API Design, Development, and Consumption with Enhanc...
WSO2Con 2025 - AI-Driven API Design, Development, and Consumption with Enhanc...
WSO2Con 2025 - Unified Management of Ingress and Egress Across Multiple API G...
WSO2Con 2025 - How an Internal Developer Platform Lets Developers Focus on Code
WSO2Con 2025 - Architecting Cloud-Native Applications
Mastering Intelligent Digital Experiences with Platformless Modernization
Accelerate Enterprise Software Engineering with Platformless
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation

Recently uploaded (20)

PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Cloud computing and distributed systems.
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Big Data Technologies - Introduction.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Electronic commerce courselecture one. Pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPT
Teaching material agriculture food technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Machine learning based COVID-19 study performance prediction
Spectroscopy.pptx food analysis technology
Cloud computing and distributed systems.
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Reach Out and Touch Someone: Haptics and Empathic Computing
Review of recent advances in non-invasive hemoglobin estimation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectral efficient network and resource selection model in 5G networks
sap open course for s4hana steps from ECC to s4
Digital-Transformation-Roadmap-for-Companies.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Big Data Technologies - Introduction.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Electronic commerce courselecture one. Pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Understanding_Digital_Forensics_Presentation.pptx
Teaching material agriculture food technology

API Management for GraphQL

  • 1. A practical guide to API Management for GraphQL June 30, 2020
  • 2. Hello! Bhathiya Jayasekara Senior Technical Lead, WSO2 bhathiya@wso2.com
  • 3. ● Introduction to GraphQL ● REST vs GraphQL ● Exposing GraphQL services as Managed APIs ⦿ Authentication ⦿ Authorization ⦿ Rate-Limiting ⦿ Analytics ● API Management for GraphQL demo What’s covered? 3
  • 5. ● A query language for your APIs. ● Gives what you request, nothing more and nothing less. ● Ability to make API calls more efficient, flexible, and developer-friendly. ● GraphQL specification is an SDL (Schema Definition Language). ● Created by Facebook in 2012 and released for open-source in 2015. ● Served over HTTP via a single endpoint. ● Specification - https://spec.graphql.org/June2018/ ● Reference Implementation - https://github.com/graphql/graphql-js ● Implementations in many languages - https://graphql.org/code/ GraphQL 5
  • 6. Example: Product-Management Service 6 Retailer Id: ID Name: String Customer Id: ID Name: String Product Id: ID Name: String Category: enum ( CLOTHING FOOTWEAR COSMETICS ) 1 r 1 m n n
  • 7. ● Defines the capabilities of an API ● All the types are exposed in an API, written down in a language called GraphQL Schema Definition Language ● Contract between the server and the client. Once it is defined, both sides are aware of the data structure ● Query, Mutation, and Subscription root types 7 Type System
  • 10. 10 GraphQL Subscription ● GraphQL subscriptions allow you to be notified in real-time of changes to your data. ● Usually implemented with WebSockets or similar technologies. ● Eg: In the Product-Management service, a retailer will be notified whenever a new Customer node is created.
  • 12. REST API Call 1 Fetch a list of all products. GET /products 12 Example: The retailer wants to know the list of customers who ordered a particular product.
  • 13. REST API Call 2 Fetch the list of customer IDs of a particular product. GET /products/{id}/customers 13 REST API Call 3...n Fetch particular customer details by sending their IDs one by one. For (each customer) { GET /products/{id}/customers/{id} }
  • 14. GraphQL API Call Returns the details of a list of customers of a particular product with just a single query. 14
  • 15. ● Pros ⦿ No more over-fetching or under-fetching ⦿ Single API call data fetching ⦿ High performance in data fetching networks ⦿ Versionless API evolution ● Cons ⦿ Not good for complex queries - Slow down performance and kill the efficiency of applications ⦿ No support for HTTP caching ⦿ Overkill for smaller apps ⦿ No support for file uploads GraphQL: Pros and Cons - Compared to REST 15
  • 17. ● Authentication ● Role based access control (Authorization) ● Rate limit API traffic ● Detect and block malicious content ● Analytics Why API Management? 17
  • 19. ● APIs are mostly exposed to external users. ● Security plays a major role at this point as it is crucial to ensure that the users who access the API operations are authentic. ● However, there can be certain API functionalities they are exposed to the public, giving access to anyone without needing to authenticate with the system. Authentication 19
  • 20. Solution: REST GET /products - Authentication OFF GET /products/{id}/customers - Authentication ON GraphQL ? 20 Example requirement: 1. Allow getting product list without a token 2. Don’t allow getting customers of a product without a token
  • 21. { product(id: "2") { id name } } - The `product` operation is allowed without a token Authentication: GraphQL 21 { product(id: "2") { id name customer { name id } } } - The `customer` operation is NOT allowed without a token
  • 23. ● Certain API functionalities may need to be accessed by only a subset of users in the user base. ● For such functionalities, only the authorized parties should have access. ● Typically done with OAuth2 scopes. Authorization 23
  • 24. Solution: REST ● POST /products - Retailer scope attached ● Decided based on the URL GraphQL ● Mutation operation “addProduct” - Retailer scope attached ● Decided based on the payload 24 Example requirement: 1. Don’t allow adding products for non-retailers 2. Allow adding products only for retailers
  • 26. ● There is only a certain amount of load the API backends can handle at a given time. ● Can be a part of business plans related to API monetization too. Rate Limiting 26 REST ● Usually, applied in the form of TPS/TPM etc. ● Different resources typically have different rate limit policies. GraphQL ● TPS/TPM form is not adequate. ● Should be decided based on the payload too. ● Need more dimensions for the limits - Query Depth Analysis - Query Complexity Analysis
  • 27. ● Query depth can be infinite and cyclic. ● Too expensive for the backend servers. ● Solution: Depth Limit GraphQL: Query Depth Analysis 27
  • 28. ● Query depth limit may not be adequate ● The cost of fetching nodes at different levels can be different ● Solution: Complexity Limit GraphQL: Query Complexity Analysis 28
  • 29. ● No standard way to calculate ● Different groups follow different approaches GraphQL: Query Complexity Calculation 29 Example rule 1 ● No arguments => multiply by 1 Example rule 2 ● Multiply by argument value
  • 31. ● Helps you understand how your APIs are being used. ● Business analytics and operational analytics ● REST APIs Analytics at resource level ● GraphQL Analytics at operation level Analytics 31
  • 32. Demo