SlideShare a Scribd company logo
1 of 29
Download to read offline
GraphQL with Spring Boot
18.11.2017
Krzysztof Pawłowski
krzysztof.pawlowski@merapar.com | krzychpawlowski
About me
• Senior Java Developer @ Merapar Technologies
• Coder, Lecturer (PJATK), Java Trainer (iSA)
• 7+ years of experience in Java Development
• using GraphQL for a year now
• E-mail: krzysztof.pawlowski@merapar.com
• Twitter: krzychpawlowski
REST not so restful?
GET /author/:id
<<class>>

Author
Long id
String name
String email
String bio
List<BlogEntry>

blogEntries
<<class>>

BlogEntry
Long id
String title
List<Comment> comments
<<class>>

Comment
Long id
String author
String comment
REST not so restful?
GET /author/:id
<<class>>

Author
Long id
String name
String email
String bio
List<BlogEntry>

blogEntries
<<class>>

BlogEntry
Long id
String title
List<Comment> comments
<<class>>

Comment
Long id
String author
String comment
{

id: 1,

name: “Krzysztof”,

email:”k@example.com“,

bio: “java dev”,
blogEntriesIds: [1, 2]

}
REST not so restful?
GET /author/:id
GET /author/:id/blogEntry/:id
<<class>>

Author
Long id
String name
String email
String bio
List<BlogEntry>

blogEntries
<<class>>

BlogEntry
Long id
String title
List<Comment> comments
<<class>>

Comment
Long id
String author
String comment
REST not so restful?
GET /author/:id
GET /author/:id/blogEntry/:id
<<class>>

Author
Long id
String name
String email
String bio
List<BlogEntry>

blogEntries
<<class>>

BlogEntry
Long id
String title
List<Comment> comments
<<class>>

Comment
Long id
String author
String comment
{

id: 1,
title: “GraphQL”,

authorId: 1,
commentsIds: [1, 2]

}
REST not so restful?
GET /author/:id/blogEntry/:id/comments
GET /author/:id
GET /author/:id/blogEntry/:id
<<class>>

Author
Long id
String name
String email
String bio
List<BlogEntry>

blogEntries
<<class>>

BlogEntry
Long id
String title
List<Comment> comments
<<class>>

Comment
Long id
String author
String comment
REST not so restful?
GET /author/:id/blogEntry/:id/comments
GET /author/:id
GET /author/:id/blogEntry/:id
<<class>>

Author
Long id
String name
String email
String bio
List<BlogEntry>

blogEntries
<<class>>

BlogEntry
Long id
String title
List<Comment> comments
<<class>>

Comment
Long id
String author
String comment
{

id: 1,

author: “anonymous”,

comment: “super!”

}
While in GraphQL…
authors(filter : {id : 1 }) {

name

blogEntry {

title

comment {

comment

}

}

}
<<class>>

Author
Long id
String name
String email
String bio
List<BlogEntry>

blogEntries
<<class>>

BlogEntry
Long id
String title
List<Comment> comments
<<class>>

Comment
Long id
String author
String comment
What is GraphQL?
“GraphQL is a query language for APIs and a runtime for fulfilling those
queries with your existing data.”
— http://graphql.org
What is GraphQL?
“GraphQL is a query language for APIs and a runtime for fulfilling those
queries with your existing data.”
— http://graphql.org
Declarative

Ask for what you need,
get exactly that
What is GraphQL?
“GraphQL is a query language for APIs and a runtime for fulfilling those
queries with your existing data.”
— http://graphql.org
Declarative

Ask for what you need,
get exactly that
Compositional

Get many resources
in a single request
What is GraphQL?
“GraphQL is a query language for APIs and a runtime for fulfilling those
queries with your existing data.”
— http://graphql.org
Declarative

Ask for what you need,
get exactly that
Compositional

Get many resources
in a single request
Strongly Typed

Describe what’s
possible
with a type system
GraphQL query
authors {
# queries can have comments!
name
email
blogEntries {
title
}
}
GraphQL query
authors {
# queries can have comments!
name
email
blogEntries {
title
}
}
{
"data": {
"authors": [
{
"name": "author 1",
"email": "Python dev",
"blogEntries": [
{
"title": "blog entry 1"
},
{
"title": "blog entry 3"
}
]
},
{
"name": "author 2",
"email": "Java dev",
"blogEntries": [
{
"title": "blog entry 2"
},
{
"title": "blog entry 4"
}
]
}
]
}
GraphQL query - filter
authors(filter : {id : 1 }) {
name
email
blogEntries {
title
}
}
GraphQL query - filter
authors(filter : {id : 1 }) {
name
email
blogEntries {
title
}
}
{
"data": {
"authors": [
{
"name": "author 1",
"email": "Python dev",
"blogEntries": [
{
"title": "blog entry 1"
},
{
"title": "blog entry 3"
}
]
}
]
}
}
GraphQL mutation
mutation addAuthorMutation($authorInfo: addAuthorInput!) {
addAuthor(input : $authorInfo) {
id
name
bio
email
}
}
{
"authorInfo": {
"id": 1,
“name" : "Krzysztof Pawlowski",
"bio" : "java dev",
"email" : "krzysztof.pawlowski@merapar.com"
}
GraphQL mutation
mutation addAuthorMutation($authorInfo: addAuthorInput!) {
addAuthor(input : $authorInfo) {
id
name
bio
email
}
}
{
"authorInfo": {
"id": 1,
“name" : "Krzysztof Pawlowski",
"bio" : "java dev",
"email" : "krzysztof.pawlowski@merapar.com"
}
{
"data": {
"addAuthor": {
"id": 1,
"name": "Krzysztof Pawlowski",
"bio": "java dev",
"email": 

“krzysztof.pawlowski@merapar.com"
}
}
}
GraphQL schema
type Author {

id: Long!
name: String
bio: String
email: String

blogEntries: [BlogEntry]
}



type BlogEntry {
id: Long!
title: String!
comments: [Comment]
}
type Comment {
id: Long!
author: String
comment: String
}

GraphQL schema
type Author {

id: Long!
name: String
bio: String
email: String

blogEntries: [BlogEntry]
}



type BlogEntry {
id: Long!
title: String!
comments: [Comment]
}
type Comment {
id: Long!
author: String
comment: String
}

type Query {
authors(id: Long!): Author
blogEntries(id: Long!): BlogEntry
comments(id: Long!): Comment
}
type Mutation {
addAuthor(author: Author!): Author
updateAuthor(author: Author!): Author
deleteAuthor(author: Author!): Author
…
}
GraphQL schema
type Author {

id: Long!
name: String
bio: String
email: String

blogEntries: [BlogEntry]
}



type BlogEntry {
id: Long!
title: String!
comments: [Comment]
}
type Comment {
id: Long!
author: String
comment: String
}

type Query {
authors(id: Long!): Author
blogEntries(id: Long!): BlogEntry
comments(id: Long!): Comment
}
type Mutation {
addAuthor(author: Author!): Author
updateAuthor(author: Author!): Author
deleteAuthor(author: Author!): Author
…
}
schema {
query: Query
mutation: Mutation
}
Other benefits of GraphQL
‣flexibility
‣one end-point
‣self-documenting (strong typing and schema)
‣query validation
‣no versioning needed
Client and documentation
Spring Boot Starter for GraphQL
‣adding Maven dependency creates GraphQL controller under

/v1/graphql
<dependency>
<groupId>com.merapar</groupId>
<artifactId>graphql-spring-boot-starter</artifactId>
<version>1.0.2</version>
</dependency>
‣adding new queries and mutation is a matter of implementing
GraphQlFields interface
Demo
https://github.com/krzysztof-pawlowski/GraphQLwithSpringBoot
Problems with GraphQL
‣HTTP caching
‣Unpredictable execution
‣No handling for file upload
‣Authorisation and authentication
Thank you!
Questions?
krzysztof.pawlowski@merapar.com | krzychpawlowski
Bonus — GitHub GraphQL API
https://developer.github.com/v4/

More Related Content

What's hot

Austin Day of Rest - Introduction
Austin Day of Rest - IntroductionAustin Day of Rest - Introduction
Austin Day of Rest - IntroductionHandsOnWP.com
 
Cool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearchCool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearchclintongormley
 
Building Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreBuilding Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreNate Barbettini
 
Beautiful REST+JSON APIs with Ion
Beautiful REST+JSON APIs with IonBeautiful REST+JSON APIs with Ion
Beautiful REST+JSON APIs with IonStormpath
 
Building Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreBuilding Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreStormpath
 
The ultimate guide for Elasticsearch plugins
The ultimate guide for Elasticsearch pluginsThe ultimate guide for Elasticsearch plugins
The ultimate guide for Elasticsearch pluginsItamar
 
Practical Elasticsearch - real world use cases
Practical Elasticsearch - real world use casesPractical Elasticsearch - real world use cases
Practical Elasticsearch - real world use casesItamar
 
Webinar: Modern Techniques for Better Search Relevance with Fusion
Webinar: Modern Techniques for Better Search Relevance with FusionWebinar: Modern Techniques for Better Search Relevance with Fusion
Webinar: Modern Techniques for Better Search Relevance with FusionLucidworks
 
State-of-the-Art Drupal Search with Apache Solr
State-of-the-Art Drupal Search with Apache SolrState-of-the-Art Drupal Search with Apache Solr
State-of-the-Art Drupal Search with Apache Solrguest432cd6
 
Pragmatic REST APIs
Pragmatic REST APIsPragmatic REST APIs
Pragmatic REST APIsamesar0
 
Cloud Security Monitoring and Spark Analytics
Cloud Security Monitoring and Spark AnalyticsCloud Security Monitoring and Spark Analytics
Cloud Security Monitoring and Spark Analyticsamesar0
 
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
Episode 8  - Path To Code - Integrate Salesforce with external system using R...Episode 8  - Path To Code - Integrate Salesforce with external system using R...
Episode 8 - Path To Code - Integrate Salesforce with external system using R...Jitendra Zaa
 
Server Logs: After Excel Fails
Server Logs: After Excel FailsServer Logs: After Excel Fails
Server Logs: After Excel FailsOliver Mason
 
Apache Solr/Lucene Internals by Anatoliy Sokolenko
Apache Solr/Lucene Internals  by Anatoliy SokolenkoApache Solr/Lucene Internals  by Anatoliy Sokolenko
Apache Solr/Lucene Internals by Anatoliy SokolenkoProvectus
 
How to automate all your SEO projects
How to automate all your SEO projectsHow to automate all your SEO projects
How to automate all your SEO projectsVincent Terrasi
 
Log File Analysis: The most powerful tool in your SEO toolkit
Log File Analysis: The most powerful tool in your SEO toolkitLog File Analysis: The most powerful tool in your SEO toolkit
Log File Analysis: The most powerful tool in your SEO toolkitTom Bennet
 
Pragmatic REST: recent trends in API design
Pragmatic REST: recent trends in API designPragmatic REST: recent trends in API design
Pragmatic REST: recent trends in API designMarsh Gardiner
 
使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭
使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭
使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭台灣資料科學年會
 
Building a Real-time Solr-powered Recommendation Engine
Building a Real-time Solr-powered Recommendation EngineBuilding a Real-time Solr-powered Recommendation Engine
Building a Real-time Solr-powered Recommendation Enginelucenerevolution
 

What's hot (20)

React & GraphQL
React & GraphQLReact & GraphQL
React & GraphQL
 
Austin Day of Rest - Introduction
Austin Day of Rest - IntroductionAustin Day of Rest - Introduction
Austin Day of Rest - Introduction
 
Cool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearchCool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearch
 
Building Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreBuilding Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET Core
 
Beautiful REST+JSON APIs with Ion
Beautiful REST+JSON APIs with IonBeautiful REST+JSON APIs with Ion
Beautiful REST+JSON APIs with Ion
 
Building Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreBuilding Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET Core
 
The ultimate guide for Elasticsearch plugins
The ultimate guide for Elasticsearch pluginsThe ultimate guide for Elasticsearch plugins
The ultimate guide for Elasticsearch plugins
 
Practical Elasticsearch - real world use cases
Practical Elasticsearch - real world use casesPractical Elasticsearch - real world use cases
Practical Elasticsearch - real world use cases
 
Webinar: Modern Techniques for Better Search Relevance with Fusion
Webinar: Modern Techniques for Better Search Relevance with FusionWebinar: Modern Techniques for Better Search Relevance with Fusion
Webinar: Modern Techniques for Better Search Relevance with Fusion
 
State-of-the-Art Drupal Search with Apache Solr
State-of-the-Art Drupal Search with Apache SolrState-of-the-Art Drupal Search with Apache Solr
State-of-the-Art Drupal Search with Apache Solr
 
Pragmatic REST APIs
Pragmatic REST APIsPragmatic REST APIs
Pragmatic REST APIs
 
Cloud Security Monitoring and Spark Analytics
Cloud Security Monitoring and Spark AnalyticsCloud Security Monitoring and Spark Analytics
Cloud Security Monitoring and Spark Analytics
 
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
Episode 8  - Path To Code - Integrate Salesforce with external system using R...Episode 8  - Path To Code - Integrate Salesforce with external system using R...
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
 
Server Logs: After Excel Fails
Server Logs: After Excel FailsServer Logs: After Excel Fails
Server Logs: After Excel Fails
 
Apache Solr/Lucene Internals by Anatoliy Sokolenko
Apache Solr/Lucene Internals  by Anatoliy SokolenkoApache Solr/Lucene Internals  by Anatoliy Sokolenko
Apache Solr/Lucene Internals by Anatoliy Sokolenko
 
How to automate all your SEO projects
How to automate all your SEO projectsHow to automate all your SEO projects
How to automate all your SEO projects
 
Log File Analysis: The most powerful tool in your SEO toolkit
Log File Analysis: The most powerful tool in your SEO toolkitLog File Analysis: The most powerful tool in your SEO toolkit
Log File Analysis: The most powerful tool in your SEO toolkit
 
Pragmatic REST: recent trends in API design
Pragmatic REST: recent trends in API designPragmatic REST: recent trends in API design
Pragmatic REST: recent trends in API design
 
使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭
使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭
使用 Elasticsearch 及 Kibana 進行巨量資料搜尋及視覺化-曾書庭
 
Building a Real-time Solr-powered Recommendation Engine
Building a Real-time Solr-powered Recommendation EngineBuilding a Real-time Solr-powered Recommendation Engine
Building a Real-time Solr-powered Recommendation Engine
 

Similar to GraphQL with Spring Boot

Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL Josh Price
 
Overview of GraphQL & Clients
Overview of GraphQL & ClientsOverview of GraphQL & Clients
Overview of GraphQL & ClientsPokai Chang
 
APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...
APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...
APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...apidays
 
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and TypescriptMongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and TypescriptMongoDB
 
Introduction to Graph QL
Introduction to Graph QLIntroduction to Graph QL
Introduction to Graph QLDeepak More
 
Into to GraphQL
Into to GraphQLInto to GraphQL
Into to GraphQLshobot
 
Cascalog at May Bay Area Hadoop User Group
Cascalog at May Bay Area Hadoop User GroupCascalog at May Bay Area Hadoop User Group
Cascalog at May Bay Area Hadoop User Groupnathanmarz
 
Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"George Stathis
 
GraphQL in an Age of REST
GraphQL in an Age of RESTGraphQL in an Age of REST
GraphQL in an Age of RESTYos Riady
 
REST API に疲れたあなたへ贈る GraphQL 入門
REST API に疲れたあなたへ贈る GraphQL 入門REST API に疲れたあなたへ贈る GraphQL 入門
REST API に疲れたあなたへ贈る GraphQL 入門Keisuke Tsukagoshi
 
Next-generation API Development with GraphQL and Prisma
Next-generation API Development with GraphQL and PrismaNext-generation API Development with GraphQL and Prisma
Next-generation API Development with GraphQL and PrismaNikolas Burk
 
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27Ruby Meditation
 
GraphQL and its schema as a universal layer for database access
GraphQL and its schema as a universal layer for database accessGraphQL and its schema as a universal layer for database access
GraphQL and its schema as a universal layer for database accessConnected Data World
 
GraphQL Los Angeles Meetup Slides
GraphQL Los Angeles Meetup SlidesGraphQL Los Angeles Meetup Slides
GraphQL Los Angeles Meetup SlidesGrant Miller
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript WorkshopPamela Fox
 

Similar to GraphQL with Spring Boot (20)

Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL
 
Overview of GraphQL & Clients
Overview of GraphQL & ClientsOverview of GraphQL & Clients
Overview of GraphQL & Clients
 
APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...
APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...
APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...
 
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and TypescriptMongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
 
Introduction to Graph QL
Introduction to Graph QLIntroduction to Graph QL
Introduction to Graph QL
 
Graphql usage
Graphql usageGraphql usage
Graphql usage
 
Into to GraphQL
Into to GraphQLInto to GraphQL
Into to GraphQL
 
Cascalog at May Bay Area Hadoop User Group
Cascalog at May Bay Area Hadoop User GroupCascalog at May Bay Area Hadoop User Group
Cascalog at May Bay Area Hadoop User Group
 
Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"
 
GraphQL in an Age of REST
GraphQL in an Age of RESTGraphQL in an Age of REST
GraphQL in an Age of REST
 
REST API に疲れたあなたへ贈る GraphQL 入門
REST API に疲れたあなたへ贈る GraphQL 入門REST API に疲れたあなたへ贈る GraphQL 入門
REST API に疲れたあなたへ贈る GraphQL 入門
 
Hands On - GraphQL
Hands On - GraphQLHands On - GraphQL
Hands On - GraphQL
 
SamBO
SamBOSamBO
SamBO
 
Next-generation API Development with GraphQL and Prisma
Next-generation API Development with GraphQL and PrismaNext-generation API Development with GraphQL and Prisma
Next-generation API Development with GraphQL and Prisma
 
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
 
kRouter
kRouterkRouter
kRouter
 
GraphQL and its schema as a universal layer for database access
GraphQL and its schema as a universal layer for database accessGraphQL and its schema as a universal layer for database access
GraphQL and its schema as a universal layer for database access
 
GraphQL Los Angeles Meetup Slides
GraphQL Los Angeles Meetup SlidesGraphQL Los Angeles Meetup Slides
GraphQL Los Angeles Meetup Slides
 
SamKK
SamKKSamKK
SamKK
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript Workshop
 

Recently uploaded

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

GraphQL with Spring Boot

  • 1. GraphQL with Spring Boot 18.11.2017 Krzysztof Pawłowski krzysztof.pawlowski@merapar.com | krzychpawlowski
  • 2. About me • Senior Java Developer @ Merapar Technologies • Coder, Lecturer (PJATK), Java Trainer (iSA) • 7+ years of experience in Java Development • using GraphQL for a year now • E-mail: krzysztof.pawlowski@merapar.com • Twitter: krzychpawlowski
  • 3. REST not so restful? GET /author/:id <<class>>
 Author Long id String name String email String bio List<BlogEntry>
 blogEntries <<class>>
 BlogEntry Long id String title List<Comment> comments <<class>>
 Comment Long id String author String comment
  • 4. REST not so restful? GET /author/:id <<class>>
 Author Long id String name String email String bio List<BlogEntry>
 blogEntries <<class>>
 BlogEntry Long id String title List<Comment> comments <<class>>
 Comment Long id String author String comment {
 id: 1,
 name: “Krzysztof”,
 email:”k@example.com“,
 bio: “java dev”, blogEntriesIds: [1, 2]
 }
  • 5. REST not so restful? GET /author/:id GET /author/:id/blogEntry/:id <<class>>
 Author Long id String name String email String bio List<BlogEntry>
 blogEntries <<class>>
 BlogEntry Long id String title List<Comment> comments <<class>>
 Comment Long id String author String comment
  • 6. REST not so restful? GET /author/:id GET /author/:id/blogEntry/:id <<class>>
 Author Long id String name String email String bio List<BlogEntry>
 blogEntries <<class>>
 BlogEntry Long id String title List<Comment> comments <<class>>
 Comment Long id String author String comment {
 id: 1, title: “GraphQL”,
 authorId: 1, commentsIds: [1, 2]
 }
  • 7. REST not so restful? GET /author/:id/blogEntry/:id/comments GET /author/:id GET /author/:id/blogEntry/:id <<class>>
 Author Long id String name String email String bio List<BlogEntry>
 blogEntries <<class>>
 BlogEntry Long id String title List<Comment> comments <<class>>
 Comment Long id String author String comment
  • 8. REST not so restful? GET /author/:id/blogEntry/:id/comments GET /author/:id GET /author/:id/blogEntry/:id <<class>>
 Author Long id String name String email String bio List<BlogEntry>
 blogEntries <<class>>
 BlogEntry Long id String title List<Comment> comments <<class>>
 Comment Long id String author String comment {
 id: 1,
 author: “anonymous”,
 comment: “super!”
 }
  • 9. While in GraphQL… authors(filter : {id : 1 }) {
 name
 blogEntry {
 title
 comment {
 comment
 }
 }
 } <<class>>
 Author Long id String name String email String bio List<BlogEntry>
 blogEntries <<class>>
 BlogEntry Long id String title List<Comment> comments <<class>>
 Comment Long id String author String comment
  • 10. What is GraphQL? “GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data.” — http://graphql.org
  • 11. What is GraphQL? “GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data.” — http://graphql.org Declarative
 Ask for what you need, get exactly that
  • 12. What is GraphQL? “GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data.” — http://graphql.org Declarative
 Ask for what you need, get exactly that Compositional
 Get many resources in a single request
  • 13. What is GraphQL? “GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data.” — http://graphql.org Declarative
 Ask for what you need, get exactly that Compositional
 Get many resources in a single request Strongly Typed
 Describe what’s possible with a type system
  • 14. GraphQL query authors { # queries can have comments! name email blogEntries { title } }
  • 15. GraphQL query authors { # queries can have comments! name email blogEntries { title } } { "data": { "authors": [ { "name": "author 1", "email": "Python dev", "blogEntries": [ { "title": "blog entry 1" }, { "title": "blog entry 3" } ] }, { "name": "author 2", "email": "Java dev", "blogEntries": [ { "title": "blog entry 2" }, { "title": "blog entry 4" } ] } ] }
  • 16. GraphQL query - filter authors(filter : {id : 1 }) { name email blogEntries { title } }
  • 17. GraphQL query - filter authors(filter : {id : 1 }) { name email blogEntries { title } } { "data": { "authors": [ { "name": "author 1", "email": "Python dev", "blogEntries": [ { "title": "blog entry 1" }, { "title": "blog entry 3" } ] } ] } }
  • 18. GraphQL mutation mutation addAuthorMutation($authorInfo: addAuthorInput!) { addAuthor(input : $authorInfo) { id name bio email } } { "authorInfo": { "id": 1, “name" : "Krzysztof Pawlowski", "bio" : "java dev", "email" : "krzysztof.pawlowski@merapar.com" }
  • 19. GraphQL mutation mutation addAuthorMutation($authorInfo: addAuthorInput!) { addAuthor(input : $authorInfo) { id name bio email } } { "authorInfo": { "id": 1, “name" : "Krzysztof Pawlowski", "bio" : "java dev", "email" : "krzysztof.pawlowski@merapar.com" } { "data": { "addAuthor": { "id": 1, "name": "Krzysztof Pawlowski", "bio": "java dev", "email": 
 “krzysztof.pawlowski@merapar.com" } } }
  • 20. GraphQL schema type Author {
 id: Long! name: String bio: String email: String
 blogEntries: [BlogEntry] }
 
 type BlogEntry { id: Long! title: String! comments: [Comment] } type Comment { id: Long! author: String comment: String }

  • 21. GraphQL schema type Author {
 id: Long! name: String bio: String email: String
 blogEntries: [BlogEntry] }
 
 type BlogEntry { id: Long! title: String! comments: [Comment] } type Comment { id: Long! author: String comment: String }
 type Query { authors(id: Long!): Author blogEntries(id: Long!): BlogEntry comments(id: Long!): Comment } type Mutation { addAuthor(author: Author!): Author updateAuthor(author: Author!): Author deleteAuthor(author: Author!): Author … }
  • 22. GraphQL schema type Author {
 id: Long! name: String bio: String email: String
 blogEntries: [BlogEntry] }
 
 type BlogEntry { id: Long! title: String! comments: [Comment] } type Comment { id: Long! author: String comment: String }
 type Query { authors(id: Long!): Author blogEntries(id: Long!): BlogEntry comments(id: Long!): Comment } type Mutation { addAuthor(author: Author!): Author updateAuthor(author: Author!): Author deleteAuthor(author: Author!): Author … } schema { query: Query mutation: Mutation }
  • 23. Other benefits of GraphQL ‣flexibility ‣one end-point ‣self-documenting (strong typing and schema) ‣query validation ‣no versioning needed
  • 25. Spring Boot Starter for GraphQL ‣adding Maven dependency creates GraphQL controller under
 /v1/graphql <dependency> <groupId>com.merapar</groupId> <artifactId>graphql-spring-boot-starter</artifactId> <version>1.0.2</version> </dependency> ‣adding new queries and mutation is a matter of implementing GraphQlFields interface
  • 27. Problems with GraphQL ‣HTTP caching ‣Unpredictable execution ‣No handling for file upload ‣Authorisation and authentication
  • 29. Bonus — GitHub GraphQL API https://developer.github.com/v4/