SlideShare ist ein Scribd-Unternehmen logo
1 von 59
Downloaden Sie, um offline zu lesen
Andreas Marek
Rossen Stoyanchev
Spring GraphQL
Copyright © 2021 VMware, Inc. or its affiliates.
Who are we
Andreas Marek
● GraphQL Java creator and maintainer
● GraphQL contributor and Technical Steering
Committee member
● Spring GraphQL co-creator
● Working at Atlassian, Sydney
● @andimarek on twitter and github
Rossen Stoyanchev
● Spring Framework committer - Spring MVC,
WebFlux, web messaging, RSocket
● RSocket Java committer
● Spring GraphQL co-creator
● Working at VMware, Cambridge, UK
● @rstoya05 on twitter
Cover w/ Image
Agenda
● What is GraphQL?
● GraphQL Java
● Spring GraphQL
What is GraphQL?
What is GraphQL?
GraphQL is a technology for client server data exchange
● A clients wants to access data on a server (across a network)
● Originally developed by Facebook for their iOS app in 2012
● Open sourced in 2015, governed by a non profit foundation today
● Two pillars: statically typed API + query language
● Sweet spots are Single Page Apps and native clients
● An alternative to REST(ish) APIs
● My favourite argument for GraphQL: the developer experience
GraphiQL demo
GraphQL Java
Data Fetching Layer
HTTP
Web iOS Android
Cache Microservices DB
The two pillars of GraphQL
GraphQL Schema
● Describes your API
● Defined on the server
● Based on a simple static types system
● Schema Definition Language (SDL) is used to
describe a Schema
GraphQL Query Language
● Custom query language
● Clients define the query based on their needs
● Every field needs to be requested explicitly
GraphQL Schema
Example
GraphQL Query
Example
The GraphQL ecosystem
GraphQL ecosystem is based on a specification
● The GraphQL specification defines how GraphQL queries should be executed
● It defines the GraphQL schema + query language
● First there was the spec + reference implementation in JS (GraphQL.JS)
● Next it was implemented in every major language
GraphQL Java
GraphQL Java
GraphQL Java is the GraphQL implementation for Java
● It is an implementation for the server side GraphQL execution (also called execution
engine)
● Started mid 2015
● Pure engine: no HTTP or IO. No high level abstracts.
● Used word wide and empowers a whole ecosystem of libraries build on top
● https://graphql-java.com/
How to think in GraphQL Java
Schema first and DataFetchers
● Start designing by putting the Schema first
● Use case and client oriented
● Define the schema in SDL (textual format, preferred) or programmatically
● Schema is made out of types with fields
● Fundamental rule: every field has a DataFetcher associated with
● DataFetcher fetches the data for one field
● If you don’t specify a DataFetcher a default DataFetcher is provided
PropertyDataFetcher
PropertyDataFetcher
DataFetcher
Calling the employee service
DataFetcher
Calling the department service
DataFetcher
Calling the employee service
1 Query.allEmployees
2a Employee.id
2b Employee.name
2c Employee.department
3a Department.name
3b Department.employees
4 Employee.id
Request Execution: DataFetchers sequence
From GraphQL Java to Spring GraphQL
Spring GraphQL is the missing gap in the developer story
● GraphQL Java is “limited” on purpose
● GraphQL Java lets you do everything, but not everything is as simple and convenient
as possible
● The Spring and GraphQL Java teams came together to fix that
● Spring GraphQL is focused on comprehensive and first level support
● It aims to be a fundamental building block build directly on GraphQL Java
Spring GraphQL
Transport ?
GraphQL Java
Engine
Data Fetchers
Database Message
Broker
Microservice
GraphQL Java
GraphQL Java
HTTP,
WebSocket
GraphQL Java
Engine
Data Fetchers
Database Message
Broker
Microservice
Spring MVC
Spring WebFlux
HTTP,
WebSocket
GraphQL Java
Engine
Data Fetchers
Database Message
Broker
Microservice
Initialization
Context propagation
Security
Exception resolution
Spring MVC
Spring WebFlux
GraphQL Java
Engine
Data Fetchers
Database Message
Broker
Microservice
@Controller
Querydsl
HTTP,
WebSocket
Spring MVC
Spring WebFlux
Initialization
Context propagation
Security
Exception resolution
GraphQL Java
Engine
Data Fetchers
Database Message
Broker
Microservice
HTTP,
WebSocket
Testing
@Controller
Querydsl repositories
Spring MVC
Spring WebFlux
Initialization
Context propagation
Security
Exception resolution
GraphQL Java
Engine
Data Fetchers
Database Message
Broker
Microservice
Boot Starter
Testing
@Controller
Querydsl repositories
Spring MVC
Spring WebFlux
Initialization
Context propagation
Security
Exception resolution
HTTP,
WebSocket
Customize ExecutionInput
Inspect ExecutionResult
Web Transports
WebMvc + WebFlux
Functional HTTP
Handlers
WebSocket
Handlers
WebInterceptor WebInterceptor GraphQlService graphql.GraphQL
Functional HTTP
Handlers
WebSocket
Handlers
WebInterceptor WebInterceptor GraphQlService graphql.GraphQL
Reactor API
Async Execution
Mono from CompletableFuture
Web Transports
WebMvc + WebFlux
GraphQL Java
Engine
Data
Fetchers
Service Service Service
HTTP, WebSocket
Handlers
Spring Security
Filter Chain
@PreAuthorize
@Secured
Security
Security and Context Propagation
Spring MVC
ThreadLocal context propagation from
Servlet container thread
Need to register ThreadLocalAccessor
Built-in accessor for Spring Security context
Spring WebFlux
Reactor context propagation from web layer
Spring Security context propagated
GraphQL Java
Engine
Data
Fetchers
Service Service Service
HTTP, WebSocket
Handlers
Spring Security
Filter Chain
@PreAuthorize
@Secured
Security
Context Propagation
Data Layer
The DataFetcher Contract
DataFetcher<T>
DataFetcher<T>
DataFetcher<T>
DataFetcher Wiring to Schema Fields
type: Query, field: allEmployees
type = Department, field = employees
type = Mutation, field = updateSalary
Exception Handling
GraphQL Java allows registering a single DataFetcherExceptionHandler
Spring GraphQL enables a DataFetcherExceptionResolver chain
DataFetcherExceptionResolver
ExceptionResolversExceptionHandler
DataFetcherExceptionResolver
DataFetcherExceptionResolver
Querydsl
Typesafe way to express queries in Java that works across multiple data stores
Spring Data has support for Querydsl
Spring GraphQL and Querydsl
QuerydslDataFetcher
Adapts a Spring Data repository to DataFetcher
Translates GraphQL query parameters to Querydsl Predicate
Adapt the Repository to
a DataFetcher
Match based on query return type for
top-level queries
Automatic Registration
More on Querydsl
Customize how GraphQL request parameters are mapped to Querydsl Predicate
Transform the resulting Objects via interface and DTO projections
GraphQlTester
Workflow for testing GraphQL
Automatic checks to verify no errors in response
Use JsonPath to specify data to inspect
Data decoding
WebGraphQlTester
Extension for GraphQL tests over web transports
Specify HTTP specific inputs
Uses WebTestClient
Spring Boot Starter
Dependencies
Autoconfig
Properties
Metrics
GraphiQL UI and Schema pages
Spring Boot Starter
Currently In Spring GraphQL repository, group id ‘org.springframework.experimental’
Due to move to Spring Boot, after version 2.6 is released
Collaboration with Netflix DGS
Optional, alternative starter to run DGS on the spring-graphql core
DGS programming model + spring-graphql WebMvc / WebFlux foundation
spring-graphql starter to become the main starter eventually
Netflix DGS Features
Annotation based registration of data fetchers, data loaders, scalars, etc.
Code generation for GraphQL Schema -> Java/Kotlin
GraphQL client for Java/Kotlin
Federation
Roadmap Timeline
M3: mid-October
Starter integrated into Spring Boot, after 2.6 release
RC phase: early 2022
GA: May 2022 with Spring Boot 2.7
Roadmap Features
Evolve controller programming model, #63 (batch loaders), #110 (bean validation)
Automated registration of Spring Data repositories, #99
Query by Example (QBE) support as an alternative to Querydsl, #115
GraphQL client, #10
More...
Roadmap Features
Your feedback
Thank you
Andreas Marek @andimarek
Rossen Stoyanchev @rstoya05
© 2021 Spring. A VMware-backed project.

Weitere ähnliche Inhalte

Was ist angesagt?

REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQLSquareboat
 
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...luisw19
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQLvaluebound
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQLAppier
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsSashko Stubailo
 
Building Modern APIs with GraphQL
Building Modern APIs with GraphQLBuilding Modern APIs with GraphQL
Building Modern APIs with GraphQLAmazon Web Services
 
Spring Boot 3 And Beyond
Spring Boot 3 And BeyondSpring Boot 3 And Beyond
Spring Boot 3 And BeyondVMware Tanzu
 
GraalVM: Run Programs Faster Everywhere
GraalVM: Run Programs Faster EverywhereGraalVM: Run Programs Faster Everywhere
GraalVM: Run Programs Faster EverywhereJ On The Beach
 
Spring Native and Spring AOT
Spring Native and Spring AOTSpring Native and Spring AOT
Spring Native and Spring AOTVMware Tanzu
 
GraphQL Data Loaders - How to feed your GraphQL API with data the smart way
GraphQL Data Loaders - How to feed your GraphQL API with data the smart wayGraphQL Data Loaders - How to feed your GraphQL API with data the smart way
GraphQL Data Loaders - How to feed your GraphQL API with data the smart wayMirumee Software
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action Alex Movila
 

Was ist angesagt? (20)

REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQL
 
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
Intro to GraphQL
 Intro to GraphQL Intro to GraphQL
Intro to GraphQL
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQL
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer tools
 
Building Modern APIs with GraphQL
Building Modern APIs with GraphQLBuilding Modern APIs with GraphQL
Building Modern APIs with GraphQL
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
Graphql
GraphqlGraphql
Graphql
 
Spring Boot 3 And Beyond
Spring Boot 3 And BeyondSpring Boot 3 And Beyond
Spring Boot 3 And Beyond
 
Spring boot
Spring bootSpring boot
Spring boot
 
GraalVM: Run Programs Faster Everywhere
GraalVM: Run Programs Faster EverywhereGraalVM: Run Programs Faster Everywhere
GraalVM: Run Programs Faster Everywhere
 
Spring Native and Spring AOT
Spring Native and Spring AOTSpring Native and Spring AOT
Spring Native and Spring AOT
 
GraphQL Data Loaders - How to feed your GraphQL API with data the smart way
GraphQL Data Loaders - How to feed your GraphQL API with data the smart wayGraphQL Data Loaders - How to feed your GraphQL API with data the smart way
GraphQL Data Loaders - How to feed your GraphQL API with data the smart way
 
GraalVM
GraalVMGraalVM
GraalVM
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 

Ähnlich wie Spring GraphQL

GraphQL-ify your APIs - Devoxx UK 2021
 GraphQL-ify your APIs - Devoxx UK 2021 GraphQL-ify your APIs - Devoxx UK 2021
GraphQL-ify your APIs - Devoxx UK 2021Soham Dasgupta
 
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
 
GraphQL_devoxx_2023.pptx
GraphQL_devoxx_2023.pptxGraphQL_devoxx_2023.pptx
GraphQL_devoxx_2023.pptxSoham Dasgupta
 
Create GraphQL server with apolloJS
Create GraphQL server with apolloJSCreate GraphQL server with apolloJS
Create GraphQL server with apolloJSJonathan Jalouzot
 
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.0Otávio Santana
 
GraphQL-ify your API - JFall 2022
GraphQL-ify your API - JFall 2022GraphQL-ify your API - JFall 2022
GraphQL-ify your API - JFall 2022Soham Dasgupta
 
Kotlin REST & GraphQL API
Kotlin REST & GraphQL APIKotlin REST & GraphQL API
Kotlin REST & GraphQL APISean O'Brien
 
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 performanceRed Hat
 
GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018Sashko Stubailo
 
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 togetherReact Conf Brasil
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL StackSashko Stubailo
 
Spring Update | July 2023
Spring Update | July 2023Spring Update | July 2023
Spring Update | July 2023VMware Tanzu
 
Graph ql subscriptions on the jvm
Graph ql subscriptions on the jvmGraph ql subscriptions on the jvm
Graph ql subscriptions on the jvmGerard Klijs
 
wepik-enhancing-web-development-with-nodejs-graphql-a-practical-guide-2024041...
wepik-enhancing-web-development-with-nodejs-graphql-a-practical-guide-2024041...wepik-enhancing-web-development-with-nodejs-graphql-a-practical-guide-2024041...
wepik-enhancing-web-development-with-nodejs-graphql-a-practical-guide-2024041...AllstuffRj
 
Confoo - Javascript Server Side : How to start
Confoo - Javascript Server Side : How to startConfoo - Javascript Server Side : How to start
Confoo - Javascript Server Side : How to startQuentin Adam
 
GraphQL API Crafts presentation
GraphQL API Crafts presentationGraphQL API Crafts presentation
GraphQL API Crafts presentationSudheer J
 

Ähnlich wie Spring GraphQL (20)

GraphQL-ify your APIs - Devoxx UK 2021
 GraphQL-ify your APIs - Devoxx UK 2021 GraphQL-ify your APIs - Devoxx UK 2021
GraphQL-ify your APIs - Devoxx UK 2021
 
GraphQL-ify your APIs
GraphQL-ify your APIsGraphQL-ify your APIs
GraphQL-ify your APIs
 
Boost your API with GraphQL
Boost your API with GraphQLBoost your API with GraphQL
Boost your API with GraphQL
 
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
 
GraphQL_devoxx_2023.pptx
GraphQL_devoxx_2023.pptxGraphQL_devoxx_2023.pptx
GraphQL_devoxx_2023.pptx
 
Create GraphQL server with apolloJS
Create GraphQL server with apolloJSCreate GraphQL server with apolloJS
Create GraphQL server with apolloJS
 
GraphQL-ify your APIs
GraphQL-ify your APIsGraphQL-ify your APIs
GraphQL-ify your APIs
 
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 APIs with GraphQL
Boost your APIs with GraphQLBoost your APIs with GraphQL
Boost your APIs with GraphQL
 
GraphQL-ify your API - JFall 2022
GraphQL-ify your API - JFall 2022GraphQL-ify your API - JFall 2022
GraphQL-ify your API - JFall 2022
 
Kotlin REST & GraphQL API
Kotlin REST & GraphQL APIKotlin REST & GraphQL API
Kotlin REST & GraphQL API
 
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
 
GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018
 
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
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
 
Spring Update | July 2023
Spring Update | July 2023Spring Update | July 2023
Spring Update | July 2023
 
Graph ql subscriptions on the jvm
Graph ql subscriptions on the jvmGraph ql subscriptions on the jvm
Graph ql subscriptions on the jvm
 
wepik-enhancing-web-development-with-nodejs-graphql-a-practical-guide-2024041...
wepik-enhancing-web-development-with-nodejs-graphql-a-practical-guide-2024041...wepik-enhancing-web-development-with-nodejs-graphql-a-practical-guide-2024041...
wepik-enhancing-web-development-with-nodejs-graphql-a-practical-guide-2024041...
 
Confoo - Javascript Server Side : How to start
Confoo - Javascript Server Side : How to startConfoo - Javascript Server Side : How to start
Confoo - Javascript Server Side : How to start
 
GraphQL API Crafts presentation
GraphQL API Crafts presentationGraphQL API Crafts presentation
GraphQL API Crafts presentation
 

Mehr von VMware Tanzu

What AI Means For Your Product Strategy And What To Do About It
What AI Means For Your Product Strategy And What To Do About ItWhat AI Means For Your Product Strategy And What To Do About It
What AI Means For Your Product Strategy And What To Do About ItVMware Tanzu
 
Make the Right Thing the Obvious Thing at Cardinal Health 2023
Make the Right Thing the Obvious Thing at Cardinal Health 2023Make the Right Thing the Obvious Thing at Cardinal Health 2023
Make the Right Thing the Obvious Thing at Cardinal Health 2023VMware Tanzu
 
Enhancing DevEx and Simplifying Operations at Scale
Enhancing DevEx and Simplifying Operations at ScaleEnhancing DevEx and Simplifying Operations at Scale
Enhancing DevEx and Simplifying Operations at ScaleVMware Tanzu
 
Platforms, Platform Engineering, & Platform as a Product
Platforms, Platform Engineering, & Platform as a ProductPlatforms, Platform Engineering, & Platform as a Product
Platforms, Platform Engineering, & Platform as a ProductVMware Tanzu
 
Building Cloud Ready Apps
Building Cloud Ready AppsBuilding Cloud Ready Apps
Building Cloud Ready AppsVMware Tanzu
 
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdfSpring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdfVMware Tanzu
 
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023VMware Tanzu
 
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023VMware Tanzu
 
tanzu_developer_connect.pptx
tanzu_developer_connect.pptxtanzu_developer_connect.pptx
tanzu_developer_connect.pptxVMware Tanzu
 
Tanzu Virtual Developer Connect Workshop - French
Tanzu Virtual Developer Connect Workshop - FrenchTanzu Virtual Developer Connect Workshop - French
Tanzu Virtual Developer Connect Workshop - FrenchVMware Tanzu
 
Tanzu Developer Connect Workshop - English
Tanzu Developer Connect Workshop - EnglishTanzu Developer Connect Workshop - English
Tanzu Developer Connect Workshop - EnglishVMware Tanzu
 
Virtual Developer Connect Workshop - English
Virtual Developer Connect Workshop - EnglishVirtual Developer Connect Workshop - English
Virtual Developer Connect Workshop - EnglishVMware Tanzu
 
Tanzu Developer Connect - French
Tanzu Developer Connect - FrenchTanzu Developer Connect - French
Tanzu Developer Connect - FrenchVMware Tanzu
 
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023VMware Tanzu
 
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring BootSpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring BootVMware Tanzu
 
SpringOne Tour: The Influential Software Engineer
SpringOne Tour: The Influential Software EngineerSpringOne Tour: The Influential Software Engineer
SpringOne Tour: The Influential Software EngineerVMware Tanzu
 
SpringOne Tour: Domain-Driven Design: Theory vs Practice
SpringOne Tour: Domain-Driven Design: Theory vs PracticeSpringOne Tour: Domain-Driven Design: Theory vs Practice
SpringOne Tour: Domain-Driven Design: Theory vs PracticeVMware Tanzu
 
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
SpringOne Tour: Spring Recipes: A Collection of Common-Sense SolutionsSpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
SpringOne Tour: Spring Recipes: A Collection of Common-Sense SolutionsVMware Tanzu
 
SpringOne Tour: Doing Progressive Delivery with your Team
SpringOne Tour: Doing Progressive Delivery with your TeamSpringOne Tour: Doing Progressive Delivery with your Team
SpringOne Tour: Doing Progressive Delivery with your TeamVMware Tanzu
 
SpringOne Tour: Make the Right Thing the Obvious Thing: The Journey to Intern...
SpringOne Tour: Make the Right Thing the Obvious Thing: The Journey to Intern...SpringOne Tour: Make the Right Thing the Obvious Thing: The Journey to Intern...
SpringOne Tour: Make the Right Thing the Obvious Thing: The Journey to Intern...VMware Tanzu
 

Mehr von VMware Tanzu (20)

What AI Means For Your Product Strategy And What To Do About It
What AI Means For Your Product Strategy And What To Do About ItWhat AI Means For Your Product Strategy And What To Do About It
What AI Means For Your Product Strategy And What To Do About It
 
Make the Right Thing the Obvious Thing at Cardinal Health 2023
Make the Right Thing the Obvious Thing at Cardinal Health 2023Make the Right Thing the Obvious Thing at Cardinal Health 2023
Make the Right Thing the Obvious Thing at Cardinal Health 2023
 
Enhancing DevEx and Simplifying Operations at Scale
Enhancing DevEx and Simplifying Operations at ScaleEnhancing DevEx and Simplifying Operations at Scale
Enhancing DevEx and Simplifying Operations at Scale
 
Platforms, Platform Engineering, & Platform as a Product
Platforms, Platform Engineering, & Platform as a ProductPlatforms, Platform Engineering, & Platform as a Product
Platforms, Platform Engineering, & Platform as a Product
 
Building Cloud Ready Apps
Building Cloud Ready AppsBuilding Cloud Ready Apps
Building Cloud Ready Apps
 
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdfSpring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
 
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
 
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
 
tanzu_developer_connect.pptx
tanzu_developer_connect.pptxtanzu_developer_connect.pptx
tanzu_developer_connect.pptx
 
Tanzu Virtual Developer Connect Workshop - French
Tanzu Virtual Developer Connect Workshop - FrenchTanzu Virtual Developer Connect Workshop - French
Tanzu Virtual Developer Connect Workshop - French
 
Tanzu Developer Connect Workshop - English
Tanzu Developer Connect Workshop - EnglishTanzu Developer Connect Workshop - English
Tanzu Developer Connect Workshop - English
 
Virtual Developer Connect Workshop - English
Virtual Developer Connect Workshop - EnglishVirtual Developer Connect Workshop - English
Virtual Developer Connect Workshop - English
 
Tanzu Developer Connect - French
Tanzu Developer Connect - FrenchTanzu Developer Connect - French
Tanzu Developer Connect - French
 
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
 
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring BootSpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
 
SpringOne Tour: The Influential Software Engineer
SpringOne Tour: The Influential Software EngineerSpringOne Tour: The Influential Software Engineer
SpringOne Tour: The Influential Software Engineer
 
SpringOne Tour: Domain-Driven Design: Theory vs Practice
SpringOne Tour: Domain-Driven Design: Theory vs PracticeSpringOne Tour: Domain-Driven Design: Theory vs Practice
SpringOne Tour: Domain-Driven Design: Theory vs Practice
 
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
SpringOne Tour: Spring Recipes: A Collection of Common-Sense SolutionsSpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
 
SpringOne Tour: Doing Progressive Delivery with your Team
SpringOne Tour: Doing Progressive Delivery with your TeamSpringOne Tour: Doing Progressive Delivery with your Team
SpringOne Tour: Doing Progressive Delivery with your Team
 
SpringOne Tour: Make the Right Thing the Obvious Thing: The Journey to Intern...
SpringOne Tour: Make the Right Thing the Obvious Thing: The Journey to Intern...SpringOne Tour: Make the Right Thing the Obvious Thing: The Journey to Intern...
SpringOne Tour: Make the Right Thing the Obvious Thing: The Journey to Intern...
 

Kürzlich hochgeladen

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durbanmasabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationShrmpro
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Kürzlich hochgeladen (20)

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

Spring GraphQL

  • 1. Andreas Marek Rossen Stoyanchev Spring GraphQL Copyright © 2021 VMware, Inc. or its affiliates.
  • 2. Who are we Andreas Marek ● GraphQL Java creator and maintainer ● GraphQL contributor and Technical Steering Committee member ● Spring GraphQL co-creator ● Working at Atlassian, Sydney ● @andimarek on twitter and github Rossen Stoyanchev ● Spring Framework committer - Spring MVC, WebFlux, web messaging, RSocket ● RSocket Java committer ● Spring GraphQL co-creator ● Working at VMware, Cambridge, UK ● @rstoya05 on twitter
  • 3. Cover w/ Image Agenda ● What is GraphQL? ● GraphQL Java ● Spring GraphQL
  • 5. What is GraphQL? GraphQL is a technology for client server data exchange ● A clients wants to access data on a server (across a network) ● Originally developed by Facebook for their iOS app in 2012 ● Open sourced in 2015, governed by a non profit foundation today ● Two pillars: statically typed API + query language ● Sweet spots are Single Page Apps and native clients ● An alternative to REST(ish) APIs ● My favourite argument for GraphQL: the developer experience
  • 7. GraphQL Java Data Fetching Layer HTTP Web iOS Android Cache Microservices DB
  • 8. The two pillars of GraphQL GraphQL Schema ● Describes your API ● Defined on the server ● Based on a simple static types system ● Schema Definition Language (SDL) is used to describe a Schema GraphQL Query Language ● Custom query language ● Clients define the query based on their needs ● Every field needs to be requested explicitly
  • 10.
  • 12. The GraphQL ecosystem GraphQL ecosystem is based on a specification ● The GraphQL specification defines how GraphQL queries should be executed ● It defines the GraphQL schema + query language ● First there was the spec + reference implementation in JS (GraphQL.JS) ● Next it was implemented in every major language
  • 14. GraphQL Java GraphQL Java is the GraphQL implementation for Java ● It is an implementation for the server side GraphQL execution (also called execution engine) ● Started mid 2015 ● Pure engine: no HTTP or IO. No high level abstracts. ● Used word wide and empowers a whole ecosystem of libraries build on top ● https://graphql-java.com/
  • 15. How to think in GraphQL Java Schema first and DataFetchers ● Start designing by putting the Schema first ● Use case and client oriented ● Define the schema in SDL (textual format, preferred) or programmatically ● Schema is made out of types with fields ● Fundamental rule: every field has a DataFetcher associated with ● DataFetcher fetches the data for one field ● If you don’t specify a DataFetcher a default DataFetcher is provided
  • 16.
  • 17. PropertyDataFetcher PropertyDataFetcher DataFetcher Calling the employee service DataFetcher Calling the department service DataFetcher Calling the employee service
  • 18. 1 Query.allEmployees 2a Employee.id 2b Employee.name 2c Employee.department 3a Department.name 3b Department.employees 4 Employee.id Request Execution: DataFetchers sequence
  • 19. From GraphQL Java to Spring GraphQL Spring GraphQL is the missing gap in the developer story ● GraphQL Java is “limited” on purpose ● GraphQL Java lets you do everything, but not everything is as simple and convenient as possible ● The Spring and GraphQL Java teams came together to fix that ● Spring GraphQL is focused on comprehensive and first level support ● It aims to be a fundamental building block build directly on GraphQL Java
  • 21. Transport ? GraphQL Java Engine Data Fetchers Database Message Broker Microservice GraphQL Java
  • 22. GraphQL Java HTTP, WebSocket GraphQL Java Engine Data Fetchers Database Message Broker Microservice Spring MVC Spring WebFlux
  • 23. HTTP, WebSocket GraphQL Java Engine Data Fetchers Database Message Broker Microservice Initialization Context propagation Security Exception resolution Spring MVC Spring WebFlux
  • 24. GraphQL Java Engine Data Fetchers Database Message Broker Microservice @Controller Querydsl HTTP, WebSocket Spring MVC Spring WebFlux Initialization Context propagation Security Exception resolution
  • 25. GraphQL Java Engine Data Fetchers Database Message Broker Microservice HTTP, WebSocket Testing @Controller Querydsl repositories Spring MVC Spring WebFlux Initialization Context propagation Security Exception resolution
  • 26. GraphQL Java Engine Data Fetchers Database Message Broker Microservice Boot Starter Testing @Controller Querydsl repositories Spring MVC Spring WebFlux Initialization Context propagation Security Exception resolution HTTP, WebSocket
  • 27. Customize ExecutionInput Inspect ExecutionResult Web Transports WebMvc + WebFlux Functional HTTP Handlers WebSocket Handlers WebInterceptor WebInterceptor GraphQlService graphql.GraphQL
  • 28. Functional HTTP Handlers WebSocket Handlers WebInterceptor WebInterceptor GraphQlService graphql.GraphQL Reactor API Async Execution Mono from CompletableFuture Web Transports WebMvc + WebFlux
  • 29.
  • 30. GraphQL Java Engine Data Fetchers Service Service Service HTTP, WebSocket Handlers Spring Security Filter Chain @PreAuthorize @Secured Security
  • 31. Security and Context Propagation Spring MVC ThreadLocal context propagation from Servlet container thread Need to register ThreadLocalAccessor Built-in accessor for Spring Security context Spring WebFlux Reactor context propagation from web layer Spring Security context propagated
  • 32. GraphQL Java Engine Data Fetchers Service Service Service HTTP, WebSocket Handlers Spring Security Filter Chain @PreAuthorize @Secured Security Context Propagation
  • 36.
  • 37.
  • 38.
  • 39. type: Query, field: allEmployees
  • 40. type = Department, field = employees
  • 41. type = Mutation, field = updateSalary
  • 42. Exception Handling GraphQL Java allows registering a single DataFetcherExceptionHandler Spring GraphQL enables a DataFetcherExceptionResolver chain DataFetcherExceptionResolver ExceptionResolversExceptionHandler DataFetcherExceptionResolver DataFetcherExceptionResolver
  • 43.
  • 44. Querydsl Typesafe way to express queries in Java that works across multiple data stores Spring Data has support for Querydsl
  • 45. Spring GraphQL and Querydsl QuerydslDataFetcher Adapts a Spring Data repository to DataFetcher Translates GraphQL query parameters to Querydsl Predicate
  • 46. Adapt the Repository to a DataFetcher
  • 47. Match based on query return type for top-level queries Automatic Registration
  • 48. More on Querydsl Customize how GraphQL request parameters are mapped to Querydsl Predicate Transform the resulting Objects via interface and DTO projections
  • 49. GraphQlTester Workflow for testing GraphQL Automatic checks to verify no errors in response Use JsonPath to specify data to inspect Data decoding
  • 50. WebGraphQlTester Extension for GraphQL tests over web transports Specify HTTP specific inputs Uses WebTestClient
  • 51.
  • 53. Spring Boot Starter Currently In Spring GraphQL repository, group id ‘org.springframework.experimental’ Due to move to Spring Boot, after version 2.6 is released
  • 54. Collaboration with Netflix DGS Optional, alternative starter to run DGS on the spring-graphql core DGS programming model + spring-graphql WebMvc / WebFlux foundation spring-graphql starter to become the main starter eventually
  • 55. Netflix DGS Features Annotation based registration of data fetchers, data loaders, scalars, etc. Code generation for GraphQL Schema -> Java/Kotlin GraphQL client for Java/Kotlin Federation
  • 56. Roadmap Timeline M3: mid-October Starter integrated into Spring Boot, after 2.6 release RC phase: early 2022 GA: May 2022 with Spring Boot 2.7
  • 57. Roadmap Features Evolve controller programming model, #63 (batch loaders), #110 (bean validation) Automated registration of Spring Data repositories, #99 Query by Example (QBE) support as an alternative to Querydsl, #115 GraphQL client, #10 More...
  • 59. Thank you Andreas Marek @andimarek Rossen Stoyanchev @rstoya05 © 2021 Spring. A VMware-backed project.