SlideShare a Scribd company logo
1 of 12
GraphQL- Best
practices
wednesday.is
Presented by:Anurag Rathod
2
Content
What we’ll be covering
What is GraphQL
Why we need to adhere to best practices
Importance of Schema design
Security and Versioning
Documentation
3
What is GraphQL
The what and the why?
GraphQLis a query language and runtime forAPIs (Application Programming Interfaces)
that was developed by Facebook in 2012 and later open-sourced in 2015. It provides a
more efficient, flexible, and powerful way to interact withAPIs compared to traditional
REST(Representational StateTransfer)APIs.
Instead of having multiple endpoints for different types of data, a GraphQLAPI exposes a
single endpoint where clients can send queries that specify the shape and structure of the
response they expect.This query is essentially a JSON object describing the data
requirements.
4
REST vs GraphQL
In traditional RESTAPIs, the client typically has to make multiple requests to different
endpoints to gather all the required data.
GraphQLaddresses these issues by allowing the client to specify exactly what data it
needs and in what format.
5
Issues with RESTAPIs
Addressing bottlenecks
In REST, endpoints often return fixed data structures, which can result in clients receiving
more data than needed (over-fetching) or making multiple requests to different endpoints
to gather required data (under-fetching).This leads to increased latency and inefficient use
of network resources.
In RESTAPIs, when changes are made to the data structure or behaviour of an endpoint,
it often requires creating a new version of theAPI to avoid breaking existing clients.This
can lead to maintenance challenges and confusion for bothAPI providers and consumers.
GraphQLsolves this by allowing clients to request only the specific fields they need,
eliminating over-fetching and under-fetching. Clients define their data requirements in
the query, ensuring that they receive precisely the data they expect, without
unnecessary additional information. GraphQLreduces versioning challenges by
introducing a strongly-typed schema.The schema serves as a contract between the
client and the server, defining the types of data that can be queried and the relationships
between them.
6
How to make the most out of GraphQL
What are the different practices that can give you superpowers
Following best practices when working with GraphQLis crucial to ensure the efficiency,
maintainability, and scalability of yourAPI and the applications that interact with it. Here are
some reasons why adhering to best practices is important
• Efficiency
• Data Security
• Scalability
• Developer Collaboration
• Future-proofing
7
Importance of Schema Design
How you should design your schema and why doing it right matters
The schema acts as a contract between the client and the server, defining the types of
data that can be queried, the relationships between them, and the operations that can
be performed. It matters because a well-designed schema ensures clarity, efficiency,
and flexibility in yourAPI.
• Use clear and meaningful type names
• Hierarchical Structure
• Use Interfaces and Union for Polymorphic types
• Use @deprecated directive
• Add support for pagination and filtering
8
Importance of meaningful errors
Why you should care about the error messages as much as the returned data
Meaningful error messages provide clear insights into what went wrong, making it
easier for developers to identify and fix issues in their queries or mutations.
• PromotesAdoption
• Encourages Proper Usage
• Supports Client-Side Development
• Saves NetworkTraffic
9
Some other best practices
What can help you make the most of your GraphQLAPIs
Caching and Performance
Utilize caching mechanisms likeApollo Client's cache or Dataloader caching.These
mechanisms store frequently accessed data in memory, reducing the need for repeated
database queries. Implement server-side caching with tools like Redis for queries that
are common and resource-intensive. Minimize the data returned in each request to
reduce payload size and improve performance, especially for mobile clients.
Security
Protect sensitive data with authentication and authorization mechanisms. Ensure that
only authorized users can access certain queries and mutations. Implement field-level
permissions to restrict access to specific fields based on the user's role or permissions.
Be cautious with the introspection query, which can expose your schema structure;
disable it in production to mitigate potential security risks.
10
Some other best practices
What can help you make the most of your GraphQLAPIs
Versioning
Plan for schema changes and versioning to prevent breaking changes for clients.
GraphQLschemas can evolve over time, and it's important to provide backward
compatibility for existing clients. Use features like unions and interfaces to maintain
compatibility even as you introduce new types. Provide clear deprecation notices for
fields or types that will be removed in the future.
Tooling
Leverage tools likeApollo Server, GraphQLYoga, or Express GraphQLfor setting up
your GraphQLserver.These tools simplify server creation and provide useful features
out of the box. Use GraphQLtools like GraphiQLor GraphQLPlayground for query
exploration and debugging. Incorporate linting and code generators to maintain code
quality, consistency, and to automate repetitive tasks.
11
Key Takeaways
What we learned
What is GraphQL
Bottlenecks with RESTAPIs
Best practices when using GraphQL
Thank you
for your time
wednesday.is

More Related Content

Similar to What is GraphQL: Best Practices

Introduction to Testing GraphQL Presentation
Introduction to Testing GraphQL PresentationIntroduction to Testing GraphQL Presentation
Introduction to Testing GraphQL PresentationKnoldus Inc.
 
Testing Graph QL Presentation (Test Automation)
Testing Graph QL Presentation (Test Automation)Testing Graph QL Presentation (Test Automation)
Testing Graph QL Presentation (Test Automation)Knoldus Inc.
 
Introduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptxIntroduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptxKnoldus Inc.
 
GraphQL API Gateway and microservices
GraphQL API Gateway and microservicesGraphQL API Gateway and microservices
GraphQL API Gateway and microservicesMohammed Shaban
 
Thiruvananthapuram Anypoint DataGraph 2 Sept.pdf
Thiruvananthapuram Anypoint DataGraph 2 Sept.pdfThiruvananthapuram Anypoint DataGraph 2 Sept.pdf
Thiruvananthapuram Anypoint DataGraph 2 Sept.pdfVikalp Bhalia
 
Whither the Hadoop Developer Experience, June Hadoop Meetup, Nitin Motgi
Whither the Hadoop Developer Experience, June Hadoop Meetup, Nitin MotgiWhither the Hadoop Developer Experience, June Hadoop Meetup, Nitin Motgi
Whither the Hadoop Developer Experience, June Hadoop Meetup, Nitin MotgiFelicia Haggarty
 
GraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits togetherGraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits togetherSashko Stubailo
 
Neo4j GraphDay Seattle- Sept19- in the enterprise
Neo4j GraphDay Seattle- Sept19-  in the enterpriseNeo4j GraphDay Seattle- Sept19-  in the enterprise
Neo4j GraphDay Seattle- Sept19- in the enterpriseNeo4j
 
Democratization of Data @Indix
Democratization of Data @IndixDemocratization of Data @Indix
Democratization of Data @IndixManoj Mahalingam
 
apidays LIVE Paris - GraphQL meshes by Jens Neuse
apidays LIVE Paris - GraphQL meshes by Jens Neuseapidays LIVE Paris - GraphQL meshes by Jens Neuse
apidays LIVE Paris - GraphQL meshes by Jens Neuseapidays
 
OOW 2012: Integrate Cloud Applications with Oracle SOA Suite
OOW 2012: Integrate Cloud Applications with Oracle SOA SuiteOOW 2012: Integrate Cloud Applications with Oracle SOA Suite
OOW 2012: Integrate Cloud Applications with Oracle SOA SuiteRajesh Raheja
 
Data Services and the Modern Data Ecosystem (ASEAN)
Data Services and the Modern Data Ecosystem (ASEAN)Data Services and the Modern Data Ecosystem (ASEAN)
Data Services and the Modern Data Ecosystem (ASEAN)Denodo
 
The 15 ITIL Steps to DBaaS in the Cloud
The 15 ITIL Steps to DBaaS in the CloudThe 15 ITIL Steps to DBaaS in the Cloud
The 15 ITIL Steps to DBaaS in the CloudJoaquin Marques
 
Confluent Partner Tech Talk with Reply
Confluent Partner Tech Talk with ReplyConfluent Partner Tech Talk with Reply
Confluent Partner Tech Talk with Replyconfluent
 
Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...
Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...
Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...ssuser5583681
 
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceLuca Mattia Ferrari
 
Roadmap for Enterprise Graph Strategy
Roadmap for Enterprise Graph StrategyRoadmap for Enterprise Graph Strategy
Roadmap for Enterprise Graph StrategyNeo4j
 
Your Roadmap for An Enterprise Graph Strategy
Your Roadmap for An Enterprise Graph StrategyYour Roadmap for An Enterprise Graph Strategy
Your Roadmap for An Enterprise Graph StrategyNeo4j
 

Similar to What is GraphQL: Best Practices (20)

codersera_com (1).pdf
codersera_com (1).pdfcodersera_com (1).pdf
codersera_com (1).pdf
 
Introduction to Testing GraphQL Presentation
Introduction to Testing GraphQL PresentationIntroduction to Testing GraphQL Presentation
Introduction to Testing GraphQL Presentation
 
Testing Graph QL Presentation (Test Automation)
Testing Graph QL Presentation (Test Automation)Testing Graph QL Presentation (Test Automation)
Testing Graph QL Presentation (Test Automation)
 
Introduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptxIntroduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptx
 
GraphQL API Gateway and microservices
GraphQL API Gateway and microservicesGraphQL API Gateway and microservices
GraphQL API Gateway and microservices
 
Thiruvananthapuram Anypoint DataGraph 2 Sept.pdf
Thiruvananthapuram Anypoint DataGraph 2 Sept.pdfThiruvananthapuram Anypoint DataGraph 2 Sept.pdf
Thiruvananthapuram Anypoint DataGraph 2 Sept.pdf
 
Whither the Hadoop Developer Experience, June Hadoop Meetup, Nitin Motgi
Whither the Hadoop Developer Experience, June Hadoop Meetup, Nitin MotgiWhither the Hadoop Developer Experience, June Hadoop Meetup, Nitin Motgi
Whither the Hadoop Developer Experience, June Hadoop Meetup, Nitin Motgi
 
GraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits togetherGraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits together
 
Neo4j GraphDay Seattle- Sept19- in the enterprise
Neo4j GraphDay Seattle- Sept19-  in the enterpriseNeo4j GraphDay Seattle- Sept19-  in the enterprise
Neo4j GraphDay Seattle- Sept19- in the enterprise
 
Democratization of Data @Indix
Democratization of Data @IndixDemocratization of Data @Indix
Democratization of Data @Indix
 
apidays LIVE Paris - GraphQL meshes by Jens Neuse
apidays LIVE Paris - GraphQL meshes by Jens Neuseapidays LIVE Paris - GraphQL meshes by Jens Neuse
apidays LIVE Paris - GraphQL meshes by Jens Neuse
 
OOW 2012: Integrate Cloud Applications with Oracle SOA Suite
OOW 2012: Integrate Cloud Applications with Oracle SOA SuiteOOW 2012: Integrate Cloud Applications with Oracle SOA Suite
OOW 2012: Integrate Cloud Applications with Oracle SOA Suite
 
Data Services and the Modern Data Ecosystem (ASEAN)
Data Services and the Modern Data Ecosystem (ASEAN)Data Services and the Modern Data Ecosystem (ASEAN)
Data Services and the Modern Data Ecosystem (ASEAN)
 
About CDAP
About CDAPAbout CDAP
About CDAP
 
The 15 ITIL Steps to DBaaS in the Cloud
The 15 ITIL Steps to DBaaS in the CloudThe 15 ITIL Steps to DBaaS in the Cloud
The 15 ITIL Steps to DBaaS in the Cloud
 
Confluent Partner Tech Talk with Reply
Confluent Partner Tech Talk with ReplyConfluent Partner Tech Talk with Reply
Confluent Partner Tech Talk with Reply
 
Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...
Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...
Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...
 
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performance
 
Roadmap for Enterprise Graph Strategy
Roadmap for Enterprise Graph StrategyRoadmap for Enterprise Graph Strategy
Roadmap for Enterprise Graph Strategy
 
Your Roadmap for An Enterprise Graph Strategy
Your Roadmap for An Enterprise Graph StrategyYour Roadmap for An Enterprise Graph Strategy
Your Roadmap for An Enterprise Graph Strategy
 

More from Wednesday Solutions

Master iOS Performance Optimization with Instruments
Master iOS Performance Optimization with InstrumentsMaster iOS Performance Optimization with Instruments
Master iOS Performance Optimization with InstrumentsWednesday Solutions
 
What is React Concurrent Mode: A Walkthrough
What is React Concurrent Mode: A WalkthroughWhat is React Concurrent Mode: A Walkthrough
What is React Concurrent Mode: A WalkthroughWednesday Solutions
 
Memory Management in Go: Stack, Heap & Garbage Collector
Memory Management in Go: Stack, Heap & Garbage CollectorMemory Management in Go: Stack, Heap & Garbage Collector
Memory Management in Go: Stack, Heap & Garbage CollectorWednesday Solutions
 
Create Basic 3D Scenes Using Three.js
Create Basic 3D Scenes Using Three.jsCreate Basic 3D Scenes Using Three.js
Create Basic 3D Scenes Using Three.jsWednesday Solutions
 
What is Temporal: Workflow & Cluster
What is Temporal: Workflow & ClusterWhat is Temporal: Workflow & Cluster
What is Temporal: Workflow & ClusterWednesday Solutions
 

More from Wednesday Solutions (8)

Error Handling in Express
Error Handling in ExpressError Handling in Express
Error Handling in Express
 
Master iOS Performance Optimization with Instruments
Master iOS Performance Optimization with InstrumentsMaster iOS Performance Optimization with Instruments
Master iOS Performance Optimization with Instruments
 
What is React Concurrent Mode: A Walkthrough
What is React Concurrent Mode: A WalkthroughWhat is React Concurrent Mode: A Walkthrough
What is React Concurrent Mode: A Walkthrough
 
Memory Management in Go: Stack, Heap & Garbage Collector
Memory Management in Go: Stack, Heap & Garbage CollectorMemory Management in Go: Stack, Heap & Garbage Collector
Memory Management in Go: Stack, Heap & Garbage Collector
 
Create Basic 3D Scenes Using Three.js
Create Basic 3D Scenes Using Three.jsCreate Basic 3D Scenes Using Three.js
Create Basic 3D Scenes Using Three.js
 
A Guide to Figma for Developers
A Guide to Figma for DevelopersA Guide to Figma for Developers
A Guide to Figma for Developers
 
What is Temporal: Workflow & Cluster
What is Temporal: Workflow & ClusterWhat is Temporal: Workflow & Cluster
What is Temporal: Workflow & Cluster
 
Vector Embedding using AI
Vector Embedding using AIVector Embedding using AI
Vector Embedding using AI
 

Recently uploaded

(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...ranjana rawat
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 

Recently uploaded (20)

(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 

What is GraphQL: Best Practices

  • 2. 2 Content What we’ll be covering What is GraphQL Why we need to adhere to best practices Importance of Schema design Security and Versioning Documentation
  • 3. 3 What is GraphQL The what and the why? GraphQLis a query language and runtime forAPIs (Application Programming Interfaces) that was developed by Facebook in 2012 and later open-sourced in 2015. It provides a more efficient, flexible, and powerful way to interact withAPIs compared to traditional REST(Representational StateTransfer)APIs. Instead of having multiple endpoints for different types of data, a GraphQLAPI exposes a single endpoint where clients can send queries that specify the shape and structure of the response they expect.This query is essentially a JSON object describing the data requirements.
  • 4. 4 REST vs GraphQL In traditional RESTAPIs, the client typically has to make multiple requests to different endpoints to gather all the required data. GraphQLaddresses these issues by allowing the client to specify exactly what data it needs and in what format.
  • 5. 5 Issues with RESTAPIs Addressing bottlenecks In REST, endpoints often return fixed data structures, which can result in clients receiving more data than needed (over-fetching) or making multiple requests to different endpoints to gather required data (under-fetching).This leads to increased latency and inefficient use of network resources. In RESTAPIs, when changes are made to the data structure or behaviour of an endpoint, it often requires creating a new version of theAPI to avoid breaking existing clients.This can lead to maintenance challenges and confusion for bothAPI providers and consumers. GraphQLsolves this by allowing clients to request only the specific fields they need, eliminating over-fetching and under-fetching. Clients define their data requirements in the query, ensuring that they receive precisely the data they expect, without unnecessary additional information. GraphQLreduces versioning challenges by introducing a strongly-typed schema.The schema serves as a contract between the client and the server, defining the types of data that can be queried and the relationships between them.
  • 6. 6 How to make the most out of GraphQL What are the different practices that can give you superpowers Following best practices when working with GraphQLis crucial to ensure the efficiency, maintainability, and scalability of yourAPI and the applications that interact with it. Here are some reasons why adhering to best practices is important • Efficiency • Data Security • Scalability • Developer Collaboration • Future-proofing
  • 7. 7 Importance of Schema Design How you should design your schema and why doing it right matters The schema acts as a contract between the client and the server, defining the types of data that can be queried, the relationships between them, and the operations that can be performed. It matters because a well-designed schema ensures clarity, efficiency, and flexibility in yourAPI. • Use clear and meaningful type names • Hierarchical Structure • Use Interfaces and Union for Polymorphic types • Use @deprecated directive • Add support for pagination and filtering
  • 8. 8 Importance of meaningful errors Why you should care about the error messages as much as the returned data Meaningful error messages provide clear insights into what went wrong, making it easier for developers to identify and fix issues in their queries or mutations. • PromotesAdoption • Encourages Proper Usage • Supports Client-Side Development • Saves NetworkTraffic
  • 9. 9 Some other best practices What can help you make the most of your GraphQLAPIs Caching and Performance Utilize caching mechanisms likeApollo Client's cache or Dataloader caching.These mechanisms store frequently accessed data in memory, reducing the need for repeated database queries. Implement server-side caching with tools like Redis for queries that are common and resource-intensive. Minimize the data returned in each request to reduce payload size and improve performance, especially for mobile clients. Security Protect sensitive data with authentication and authorization mechanisms. Ensure that only authorized users can access certain queries and mutations. Implement field-level permissions to restrict access to specific fields based on the user's role or permissions. Be cautious with the introspection query, which can expose your schema structure; disable it in production to mitigate potential security risks.
  • 10. 10 Some other best practices What can help you make the most of your GraphQLAPIs Versioning Plan for schema changes and versioning to prevent breaking changes for clients. GraphQLschemas can evolve over time, and it's important to provide backward compatibility for existing clients. Use features like unions and interfaces to maintain compatibility even as you introduce new types. Provide clear deprecation notices for fields or types that will be removed in the future. Tooling Leverage tools likeApollo Server, GraphQLYoga, or Express GraphQLfor setting up your GraphQLserver.These tools simplify server creation and provide useful features out of the box. Use GraphQLtools like GraphiQLor GraphQLPlayground for query exploration and debugging. Incorporate linting and code generators to maintain code quality, consistency, and to automate repetitive tasks.
  • 11. 11 Key Takeaways What we learned What is GraphQL Bottlenecks with RESTAPIs Best practices when using GraphQL
  • 12. Thank you for your time wednesday.is