SlideShare una empresa de Scribd logo
1 de 28
GraphQL-ify your APIs
Soham Dasgupta
Soham Dasgupta
• Father, Husband and Football lover
• Capgemini Netherlands
• Oracle ACE
• Tech Enthusiast/Programmer/Architect
• Speaker & Blogger
• Twitter : @iamsoham
• LinkedIn: dasguptasoham
• Github: sohamda
• Medium: @iam.soham
Who am I?
What’s in store today
GraphQL
What
Queries & Mutation
Schemas & Types
Show me some code
graphql-java
graphql-java-kickstart
graphql-dgs-framework
What’s better
Implementation easiness – code,
generation, error handling, testing,
clients
N+1 problem
Memory footprint
GraphQL is a query language for your API, and a
server-side runtime for executing queries.
Backed by your existing code and data.
It was designed by Facebook to get around
common constraints in fetching data via REST.
It was open sourced by Facebook in 2015.
Nothing to do with Graph DB.
Not a replacement of REST.
Not going to magically solve every API design
issues.
What’s GraphQL
Schema Query Results
Schema , Query & Results
GraphQL provides description of the data in your API, gives clients the power to ask for exactly
what they need.
https://landscape.graphql.org/card-mode?category=graph-ql-adopter&grouping=category&style=borderless
Who is using it ?
GraphQL vs REST API vs SOAP
https://trends.google.com/trends/explore?date=today%205-y&q=%2Fg%2F11cn3w0w9t,REST%20API,%2Fm%2F077dn
Hierarchical & Aggregator Strongly Typed
Validation & Type check
out-of-the-box
API evolution without
versioning
GraphQL
Characteristics
Query & Mutation
• Ask what you need.
• Expand the same
query.
• Send arguments.
• Use Aliases, Fragment
Schemas & Types
• GraphQL schema language -
allows us to talk about
GraphQL schemas in a
language-agnostic way.
• Scalar : Int, String, Boolean, ID,
Float
• Lists & Non-Null
• Union, Interfaces, Input Types
N+1 queries Caching complexity
Community presence File Upload
GraphQL
Maturity
Show me some code
graphql-java
graphql-java-kickstart
graphql-dgs-framework
https://github.com/sohamda/serivce-repository-swagger
graphql-java https://www.graphql-java.com/documentation/v17/
https://github.com/graphql-java - Version 17.3 : Last updated on Sep’21
https://github.com/graphql-java/graphql-java-spring
https://github.com/sohamda/graphql-java
graphql-java- kickstart https://graphql-java-kickstart.com/
https://github.com/graphql-java-kickstart
Version 12 : Last updated on Sep’21
https://github.com/sohamda/graphql-java-kickstart
dgs-framework
https://netflix.github.io/dgs/
https://github.com/Netflix/dgs-framework
Version 4.9.2 : Last updated on Oct’21
https://github.com/sohamda/graphql-dgs-netflix
What’s better
Implementation easiness – code, generation, error
handling, testing, clients
N+1 problem
Memory footprint
DataFetchers
graphql-java
Piece of code that fetches the data
graphql-java-kickstart dgs
1. Define a @Component which
defines datafetching methods.
2. Register them in while
building/parsing the schema
1. Define @Component which
implements
GraphQLQueryResolver.
2. For field-level define a
@Component which
implements
GraphQLResolver<T>.
1. Define a @DgsComponent.
2. Map the schema operations
with @DgsData
DataLoaders
graphql-java
Piece of code that is responsible for N+1 query issue
graphql-java-kickstart dgs
1. Define a BatchLoader which
return s a CompletableFuture.
2. Define a DataLoaderRegistry
@Bean which registers the
Loader.
3. Define a DataFetcher using
that Loader.
1. Define @Component which
defines a loader and adds it to
the registry.
2. Define a @Component which
implements
GraphQLServletContextBuild
er and associate the registry.
1. Define a @DgsDataLoader.
2. Map the schema operations
with @DgsData
Mutations
graphql-java
Piece of code that persist the data
graphql-java-kickstart dgs
1. Define a @Component which
defines datafetching methods.
2. Register them in while
building/parsing the schema
• Define @Component which
implements
GraphQLMutationResolver.
1. Define a @DgsComponent.
2. Map the schema operations
with @DgsData
Error Handling
graphql-java
Piece of code that handles exceptions/errors
graphql-java-kickstart dgs
Implement GraphQLError 1. Enable ExceptionHandler
property and handle
them in a Spring way.
2. Implement
GraphQLErrorHandler
and manage the errors in
overridden method.
Define a @Component which
implements
DataFetcherExceptionHandle
r
Client
graphql-java
How to call a GraphQL API
graphql-java-kickstart dgs
1. No defined way.
2. Needs text templates to
generate requests.
1. Gives a Webclient library.
2. Needs text templates to
generate requests.
1. GraphQLClient uses String as
query which is same as the
previous two.
2. Code generation using
Gradle/Maven. This is the type-
safe option.
Testing
graphql-java
How to test your code
graphql-java-kickstart dgs
1. No defined way.
2. Only can test the service-repo
layer.
1. No defined way.
2. Only can test the service-repo
layer.
1. Code generation using Gradle.
This is the type-safe option.
2. Use the generated classes to
build request and test using
DgsAutoConfiguration class.
graphql-java graphql-java-kickstart dgs
1. No defined way. 1. No defined way. 1. Code generation using
Gradle/Maven.
Code Generation
Runtime memory & Image Size
Final Words
graphql-java graphql-java-kickstart dgs-framework
• Is there since long, so evolved
and matured.
• A lot of Boilerplate code just
to write a simple API.
• Need extra library to work in
Springboot. With other Java
• Not a easy way to Unit Test
everything you write.
• No Clients avaiable. Need to
use text templates to create
queries.
• Looks very matured but
missing extended
documentation.
• Still a bit of Boilerplate code.
• Directly usable within
Springboot. Although other
modules available to work on
Java only environments.
• Not a easy way to UT
everything you write.
• Basic Client avaiable.
• Not sure about maturity, but
Netflix is behind this, so faith
is there.
• No Boilerplate code.
• Directly usable within
Springboot.
• You can UT everything you
write.
• Client avaiable.
• Code generation using
Gradle/Maven.
https://medium.com/springboot-chronicles/graphql-in-springboot-a-comparative-study-
among-the-libraries-and-their-implementation-know-how-b0e8d544f2fc
This presentation contains information that may be privileged or confidential and
is the property of the Capgemini Group.
Copyright © 2021 Capgemini. All rights reserved.
Capgemini is a global leader in partnering with companies to transform and manage their
business by harnessing the power of technology. The Group is guided everyday by its
purpose of unleashing human energy through technology for an inclusive and sustainable
future. It is a responsible and diverse organization of 270,000 team members in nearly 50
countries. With its strong 50 year heritage and deep industry expertise, Capgemini is
trusted by its clients to address the entire breadth of their business needs, from strategy
and design to operations, fuelled by the fast evolving and innovative world of cloud, data,
AI, connectivity, software, digital engineering and platforms. The Group reported in 2020
global revenues of €16 billion.
About Capgemini
Get the Future You Want | www.capgemini.com

Más contenido relacionado

La actualidad más candente

Gradle(the innovation continues)
Gradle(the innovation continues)Gradle(the innovation continues)
Gradle(the innovation continues)
Sejong Park
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
Sashko Stubailo
 
Enterprise Architectures with Ruby (and Rails)
Enterprise Architectures with Ruby (and Rails)Enterprise Architectures with Ruby (and Rails)
Enterprise Architectures with Ruby (and Rails)
Konstantin Gredeskoul
 

La actualidad más candente (20)

Azure DevOps for the Data Professional
Azure DevOps for the Data ProfessionalAzure DevOps for the Data Professional
Azure DevOps for the Data Professional
 
Building the Web with Gradle
Building the Web with GradleBuilding the Web with Gradle
Building the Web with Gradle
 
Making Angular2 lean and Fast
Making Angular2 lean and FastMaking Angular2 lean and Fast
Making Angular2 lean and Fast
 
London React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor CharyparLondon React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor Charypar
 
Boost your APIs with GraphQL 1.0
Boost your APIs with GraphQL 1.0Boost your APIs with GraphQL 1.0
Boost your APIs with GraphQL 1.0
 
Boost your API with GraphQL
Boost your API with GraphQLBoost your API with GraphQL
Boost your API with GraphQL
 
Kafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open Web
Kafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open WebKafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open Web
Kafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open Web
 
Neo4J and Grails
Neo4J and GrailsNeo4J and Grails
Neo4J and Grails
 
Introduction to Grails
Introduction to GrailsIntroduction to Grails
Introduction to Grails
 
Gradle build capabilities
Gradle build capabilities Gradle build capabilities
Gradle build capabilities
 
Gradle(the innovation continues)
Gradle(the innovation continues)Gradle(the innovation continues)
Gradle(the innovation continues)
 
Angular vs React - Devoxx BE 2017
Angular vs React - Devoxx BE 2017Angular vs React - Devoxx BE 2017
Angular vs React - Devoxx BE 2017
 
What's new in Gradle 4.0
What's new in Gradle 4.0What's new in Gradle 4.0
What's new in Gradle 4.0
 
Gradle
GradleGradle
Gradle
 
Enterprise graph applications
Enterprise graph applicationsEnterprise graph applications
Enterprise graph applications
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
 
Continuous integration and delivery for java based web applications
Continuous integration and delivery for java based web applicationsContinuous integration and delivery for java based web applications
Continuous integration and delivery for java based web applications
 
Gradle by Example
Gradle by ExampleGradle by Example
Gradle by Example
 
The Graph-Native Advantage
The Graph-Native AdvantageThe Graph-Native Advantage
The Graph-Native Advantage
 
Enterprise Architectures with Ruby (and Rails)
Enterprise Architectures with Ruby (and Rails)Enterprise Architectures with Ruby (and Rails)
Enterprise Architectures with Ruby (and Rails)
 

Similar a GraphQL-ify your APIs - Devoxx UK 2021

Similar a GraphQL-ify your APIs - Devoxx UK 2021 (20)

GraphQL_devoxx_2023.pptx
GraphQL_devoxx_2023.pptxGraphQL_devoxx_2023.pptx
GraphQL_devoxx_2023.pptx
 
GraphQL-ify your API - JFall 2022
GraphQL-ify your API - JFall 2022GraphQL-ify your API - JFall 2022
GraphQL-ify your API - JFall 2022
 
GraphQL-ify your APIs
GraphQL-ify your APIsGraphQL-ify your APIs
GraphQL-ify your APIs
 
GraphQL.net
GraphQL.netGraphQL.net
GraphQL.net
 
Spring GraphQL
Spring GraphQLSpring GraphQL
Spring GraphQL
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentation
 
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architecture
 
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
 
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything togetherSashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
 
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
 
GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018
 
Implementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPCImplementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPC
 
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
 
Boost your APIs with GraphQL
Boost your APIs with GraphQLBoost your APIs with GraphQL
Boost your APIs with GraphQL
 
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
 
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)
 
Create GraphQL server with apolloJS
Create GraphQL server with apolloJSCreate GraphQL server with apolloJS
Create GraphQL server with apolloJS
 
React and GraphQL at Stripe
React and GraphQL at StripeReact and GraphQL at Stripe
React and GraphQL at Stripe
 
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
 

Más de Soham Dasgupta

Más de Soham Dasgupta (6)

Are you testing your unit tests?
Are you testing your unit tests?Are you testing your unit tests?
Are you testing your unit tests?
 
Spring Native : Why not YET!
Spring Native : Why not YET!Spring Native : Why not YET!
Spring Native : Why not YET!
 
OneBot: A Comprehensive Case Study on Enterprise Digital Assistants
OneBot: A Comprehensive Case Study on Enterprise Digital AssistantsOneBot: A Comprehensive Case Study on Enterprise Digital Assistants
OneBot: A Comprehensive Case Study on Enterprise Digital Assistants
 
No-Java Enterprise Applications: It’s All About JavaScript [DEV5107]
No-Java Enterprise Applications: It’s All About JavaScript [DEV5107]No-Java Enterprise Applications: It’s All About JavaScript [DEV5107]
No-Java Enterprise Applications: It’s All About JavaScript [DEV5107]
 
Javascript for Enterprise Application
Javascript for Enterprise ApplicationJavascript for Enterprise Application
Javascript for Enterprise Application
 
How the Dutch Police became “Chatbot” interactive
How the Dutch Police became “Chatbot” interactiveHow the Dutch Police became “Chatbot” interactive
How the Dutch Police became “Chatbot” interactive
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

GraphQL-ify your APIs - Devoxx UK 2021

  • 2. Soham Dasgupta • Father, Husband and Football lover • Capgemini Netherlands • Oracle ACE • Tech Enthusiast/Programmer/Architect • Speaker & Blogger • Twitter : @iamsoham • LinkedIn: dasguptasoham • Github: sohamda • Medium: @iam.soham Who am I?
  • 3. What’s in store today GraphQL What Queries & Mutation Schemas & Types Show me some code graphql-java graphql-java-kickstart graphql-dgs-framework What’s better Implementation easiness – code, generation, error handling, testing, clients N+1 problem Memory footprint
  • 4. GraphQL is a query language for your API, and a server-side runtime for executing queries. Backed by your existing code and data. It was designed by Facebook to get around common constraints in fetching data via REST. It was open sourced by Facebook in 2015. Nothing to do with Graph DB. Not a replacement of REST. Not going to magically solve every API design issues. What’s GraphQL
  • 5. Schema Query Results Schema , Query & Results GraphQL provides description of the data in your API, gives clients the power to ask for exactly what they need.
  • 7. GraphQL vs REST API vs SOAP https://trends.google.com/trends/explore?date=today%205-y&q=%2Fg%2F11cn3w0w9t,REST%20API,%2Fm%2F077dn
  • 8. Hierarchical & Aggregator Strongly Typed Validation & Type check out-of-the-box API evolution without versioning GraphQL Characteristics
  • 9. Query & Mutation • Ask what you need. • Expand the same query. • Send arguments. • Use Aliases, Fragment Schemas & Types • GraphQL schema language - allows us to talk about GraphQL schemas in a language-agnostic way. • Scalar : Int, String, Boolean, ID, Float • Lists & Non-Null • Union, Interfaces, Input Types
  • 10. N+1 queries Caching complexity Community presence File Upload GraphQL Maturity
  • 11. Show me some code graphql-java graphql-java-kickstart graphql-dgs-framework
  • 13. graphql-java https://www.graphql-java.com/documentation/v17/ https://github.com/graphql-java - Version 17.3 : Last updated on Sep’21 https://github.com/graphql-java/graphql-java-spring
  • 19. What’s better Implementation easiness – code, generation, error handling, testing, clients N+1 problem Memory footprint
  • 20. DataFetchers graphql-java Piece of code that fetches the data graphql-java-kickstart dgs 1. Define a @Component which defines datafetching methods. 2. Register them in while building/parsing the schema 1. Define @Component which implements GraphQLQueryResolver. 2. For field-level define a @Component which implements GraphQLResolver<T>. 1. Define a @DgsComponent. 2. Map the schema operations with @DgsData
  • 21. DataLoaders graphql-java Piece of code that is responsible for N+1 query issue graphql-java-kickstart dgs 1. Define a BatchLoader which return s a CompletableFuture. 2. Define a DataLoaderRegistry @Bean which registers the Loader. 3. Define a DataFetcher using that Loader. 1. Define @Component which defines a loader and adds it to the registry. 2. Define a @Component which implements GraphQLServletContextBuild er and associate the registry. 1. Define a @DgsDataLoader. 2. Map the schema operations with @DgsData
  • 22. Mutations graphql-java Piece of code that persist the data graphql-java-kickstart dgs 1. Define a @Component which defines datafetching methods. 2. Register them in while building/parsing the schema • Define @Component which implements GraphQLMutationResolver. 1. Define a @DgsComponent. 2. Map the schema operations with @DgsData
  • 23. Error Handling graphql-java Piece of code that handles exceptions/errors graphql-java-kickstart dgs Implement GraphQLError 1. Enable ExceptionHandler property and handle them in a Spring way. 2. Implement GraphQLErrorHandler and manage the errors in overridden method. Define a @Component which implements DataFetcherExceptionHandle r
  • 24. Client graphql-java How to call a GraphQL API graphql-java-kickstart dgs 1. No defined way. 2. Needs text templates to generate requests. 1. Gives a Webclient library. 2. Needs text templates to generate requests. 1. GraphQLClient uses String as query which is same as the previous two. 2. Code generation using Gradle/Maven. This is the type- safe option.
  • 25. Testing graphql-java How to test your code graphql-java-kickstart dgs 1. No defined way. 2. Only can test the service-repo layer. 1. No defined way. 2. Only can test the service-repo layer. 1. Code generation using Gradle. This is the type-safe option. 2. Use the generated classes to build request and test using DgsAutoConfiguration class. graphql-java graphql-java-kickstart dgs 1. No defined way. 1. No defined way. 1. Code generation using Gradle/Maven. Code Generation
  • 26. Runtime memory & Image Size
  • 27. Final Words graphql-java graphql-java-kickstart dgs-framework • Is there since long, so evolved and matured. • A lot of Boilerplate code just to write a simple API. • Need extra library to work in Springboot. With other Java • Not a easy way to Unit Test everything you write. • No Clients avaiable. Need to use text templates to create queries. • Looks very matured but missing extended documentation. • Still a bit of Boilerplate code. • Directly usable within Springboot. Although other modules available to work on Java only environments. • Not a easy way to UT everything you write. • Basic Client avaiable. • Not sure about maturity, but Netflix is behind this, so faith is there. • No Boilerplate code. • Directly usable within Springboot. • You can UT everything you write. • Client avaiable. • Code generation using Gradle/Maven. https://medium.com/springboot-chronicles/graphql-in-springboot-a-comparative-study- among-the-libraries-and-their-implementation-know-how-b0e8d544f2fc
  • 28. This presentation contains information that may be privileged or confidential and is the property of the Capgemini Group. Copyright © 2021 Capgemini. All rights reserved. Capgemini is a global leader in partnering with companies to transform and manage their business by harnessing the power of technology. The Group is guided everyday by its purpose of unleashing human energy through technology for an inclusive and sustainable future. It is a responsible and diverse organization of 270,000 team members in nearly 50 countries. With its strong 50 year heritage and deep industry expertise, Capgemini is trusted by its clients to address the entire breadth of their business needs, from strategy and design to operations, fuelled by the fast evolving and innovative world of cloud, data, AI, connectivity, software, digital engineering and platforms. The Group reported in 2020 global revenues of €16 billion. About Capgemini Get the Future You Want | www.capgemini.com

Notas del editor

  1. Who coded graphQL
  2. Some people call them resolvers as well.
  3. Or MapLoader. : is
  4. Some people call them resolvers as well.
  5. Or MapLoader. : is
  6. Or MapLoader. : is
  7. Or MapLoader. : is
  8. Or MapLoader. : is
  9. Or MapLoader. : is