SlideShare a Scribd company logo
GraphQL and React
Quick Start
#graphql #hasura #simple #fun #magic
Dubravko Bogović, 14.07.2020
SHIFT REMOTE 2020
The good old REST API
Enter GraphQL
• A query language for your API - https://graphql.org/
• Flexible data acquisition
‣ Get only what you need
‣ Multiple resources at once
‣ Filter or sort the data
‣ Change the requirements easily
Describe your data
type Project {
name: number;
tagline: number;
contributors:[User];
}
Ask for what you want
{
project(where: {
name: {_eq: "GraphQL" }
}) {
tagline
}
}
Get predictable results
{
"project": {
"tagline": "A query language for APIs"
}
}
GraphQL Features
• Drawbacks:
‣ No file upload in specification
‣ Returns only JSON
‣ Caching must be custom built
‣ Complex queries can be slow
‣ Slower learning curve
• Features:
‣ Flexible data acquisition
‣ Built-in introspection
‣ Strongly typed
‣ Client-driven
‣ Rapid application development
‣ Code sharing
‣ Detailed error messages
‣ Fine grain permission
‣ Data subscriptions
‣ Combining schemas (APIs)
Who Uses GraphQL?
• Developed internally by Facebook
• https://graphql.org/users/
• A Google search revels even more and
much bigger users (link)
‣ Shopify
‣ GitHub
‣ Medium
‣ Docker
‣ Twitter
‣ IBM (technical blog post)
‣ Netflix (technical blog post)
‣ Sainsbury (technical blog post)
‣ Yelp
‣ Infobip
‣ …
Netflix
IBM
GraphQL Operations – quick overview
Mutations
• Fragments
‣ Reusable code fragments
• Directives
‣ Allow dynamic changes to the
query structure
GraphQL flavors
• Data management action
mutation CreateReviewForEpisode($ep: Episode!,
$review: ReviewInput!) {
createReview(episode: $ep, review: $review)
{
stars
commentary
}
}
Variables:
{
"ep": "JEDI",
"review": {
"stars": 5,
"commentary": "This is a great movie!"
}
}
Result:
{
"data": {
"createReview": {
"stars": 5,
"commentary": "This is a great movie!"
}
}
}
Queries
• Data fetch actions
• Elements
‣ Operation type
‣ Operation name
‣ Variables
‣ Variable type
query UserData($alignment: String = "good") {
user(id: 1, alignment: $alignment) {
name: full_name
title
home_planet {
name
sector
}
}
}
‣ Default value
‣ Entity name
‣ Arguments
‣ Fields
‣ Alias
fragment userFields on User {
name: full_name
title
}
query Hero($withFriends: Boolean!) {
hero {
name
friends @include(if: $withFriends) {
name
}
}
}
• Subscriptions
‣ Queries with real time data
Hasura GraphQL Engine
• GraphQL engine that can easily be added to an existing PostgreSQL database
• Features:
‣ Realtime data with GraphQL subscriptions
‣ Dynamic access control that integrates with your auth
‣ Allow-list for GraphQL queries
‣ Merge remote GraphQL schemas
‣ Trigger webhooks on database events
‣ Schema migrations
‣ Query performance analysis
Apollo React.js client
• For our current projects we use the Apollo client to connect to our Hasura GraphQL server
• Components we use:
‣ apollo-link-http
‣ apollo-link-ws
‣ subscriptions-transport-ws
‣ apollo-link-context
‣ apollo-client
‣ apollo-cache-inmemory
Demo
Todo application
Github - https://github.com/AvronNet/GraphQL_quickStart
Going beyond
• https://gramps.js.org/ - GrAMPS (GraphQL Apollo Microservice Pattern Server)
‣ GraphQL at massive scale: GraphQL as the glue in a microservice architecture
• GraphQL server libraries in many languages - https://graphql.org/code/
‣ GraphQL DotNet
• https://github.com/graphql-dotnet/graphql-dotnet
• Building a GraphQL API with ASP.NET Core 2 and Entity Framework Core
‣ GraphQL Java - https://www.graphql-java.com/
• OpenAPI to GraphQL - https://github.com/ibm/openapi-to-graphql
‣ https://developer.ibm.com/open/projects/openapi-to-graphql/ (great short video)
• Top 5 GraphQL Predictions for 2019 – GraphQL adoption will grow
• A bundle of useful links about GraphQL - https://wiki.nikitavoloboev.xyz/networking/graphql
May GraphQL be with you
dubravko.bogovic@gmail.com

More Related Content

What's hot

SAS integration with NoSQL data
SAS integration with NoSQL dataSAS integration with NoSQL data
SAS integration with NoSQL data
Kevin Lee
 

What's hot (20)

Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/MeteorWhy UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
 
CONDG April 23 2020 - Baskar Rao - GraphQL
CONDG April 23 2020 - Baskar Rao - GraphQLCONDG April 23 2020 - Baskar Rao - GraphQL
CONDG April 23 2020 - Baskar Rao - GraphQL
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQL
 
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)
 
Graphql
GraphqlGraphql
Graphql
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentation
 
GraphQL & Relay
GraphQL & RelayGraphQL & Relay
GraphQL & Relay
 
GraphQL With Relay Part Deux
GraphQL With Relay Part DeuxGraphQL With Relay Part Deux
GraphQL With Relay Part Deux
 
Elastic Stack Basic - All The Capabilities in 6.3!
Elastic Stack Basic - All The Capabilities in 6.3!Elastic Stack Basic - All The Capabilities in 6.3!
Elastic Stack Basic - All The Capabilities in 6.3!
 
GraphQL IndyJS April 2016
GraphQL IndyJS April 2016GraphQL IndyJS April 2016
GraphQL IndyJS April 2016
 
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architecture
 
GraphQL in an Age of REST
GraphQL in an Age of RESTGraphQL in an Age of REST
GraphQL in an Age of REST
 
The journey of Moving from AWS ELK to GCP Data Pipeline
The journey of Moving from AWS ELK to GCP Data PipelineThe journey of Moving from AWS ELK to GCP Data Pipeline
The journey of Moving from AWS ELK to GCP Data Pipeline
 
Building GraphQL Servers with Node.JS & Prisma
Building GraphQL Servers with Node.JS & PrismaBuilding GraphQL Servers with Node.JS & Prisma
Building GraphQL Servers with Node.JS & Prisma
 
Serverless GraphQL. AppSync 101
Serverless GraphQL. AppSync 101Serverless GraphQL. AppSync 101
Serverless GraphQL. AppSync 101
 
GraphQL + relay
GraphQL + relayGraphQL + relay
GraphQL + relay
 
SAS integration with NoSQL data
SAS integration with NoSQL dataSAS integration with NoSQL data
SAS integration with NoSQL data
 
GraphQL Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL Introduction
 
Selenium camp 2017. Alexander Chumakin
Selenium camp 2017. Alexander ChumakinSelenium camp 2017. Alexander Chumakin
Selenium camp 2017. Alexander Chumakin
 
Data Provision API with BigQuery - Google Cloud Summit Jakarta 18
Data Provision API with BigQuery  - Google Cloud Summit Jakarta 18Data Provision API with BigQuery  - Google Cloud Summit Jakarta 18
Data Provision API with BigQuery - Google Cloud Summit Jakarta 18
 

Similar to Shift Remote: WEB - GraphQL and React – Quick Start - Dubravko Bogovic (Infobip)

Similar to Shift Remote: WEB - GraphQL and React – Quick Start - Dubravko Bogovic (Infobip) (20)

Tutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHPTutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHP
 
Getting started with Apollo Client and GraphQL
Getting started with Apollo Client and GraphQLGetting started with Apollo Client and GraphQL
Getting started with Apollo Client and GraphQL
 
Graphql usage
Graphql usageGraphql usage
Graphql usage
 
Building a GraphQL API in PHP
Building a GraphQL API in PHPBuilding a GraphQL API in PHP
Building a GraphQL API in PHP
 
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
 
How to provide a GraphQL API - I want it that way
How to provide a GraphQL API - I want it that wayHow to provide a GraphQL API - I want it that way
How to provide a GraphQL API - I want it that way
 
Data Driven Application with GraphQL and AWS App Sync
Data Driven Application with GraphQL and AWS App SyncData Driven Application with GraphQL and AWS App Sync
Data Driven Application with GraphQL and AWS App Sync
 
Introduction to Graph QL
Introduction to Graph QLIntroduction to Graph QL
Introduction to Graph QL
 
Build Data Driven Apps with Real-time and Offline Capabilities
Build Data Driven Apps with Real-time and Offline CapabilitiesBuild Data Driven Apps with Real-time and Offline Capabilities
Build Data Driven Apps with Real-time and Offline Capabilities
 
Serverless GraphQL for Product Developers
Serverless GraphQL for Product DevelopersServerless GraphQL for Product Developers
Serverless GraphQL for Product Developers
 
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
 
PiterPy 2016: Parallelization, Aggregation and Validation of API in Python
PiterPy 2016: Parallelization, Aggregation and Validation of API in PythonPiterPy 2016: Parallelization, Aggregation and Validation of API in Python
PiterPy 2016: Parallelization, Aggregation and Validation of API in Python
 
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) ExtensionSimplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
 
Modern APIs with GraphQL
Modern APIs with GraphQLModern APIs with GraphQL
Modern APIs with GraphQL
 
Multi model-databases
Multi model-databasesMulti model-databases
Multi model-databases
 
Multi model-databases
Multi model-databasesMulti model-databases
Multi model-databases
 
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
 
Connecting the Dots: Kong for GraphQL Endpoints
Connecting the Dots: Kong for GraphQL EndpointsConnecting the Dots: Kong for GraphQL Endpoints
Connecting the Dots: Kong for GraphQL Endpoints
 
Grails 101
Grails 101Grails 101
Grails 101
 
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
 

More from Shift Conference

More from Shift Conference (20)

Shift Remote: AI: How Does Face Recognition Work (ars futura)
Shift Remote: AI: How Does Face Recognition Work  (ars futura)Shift Remote: AI: How Does Face Recognition Work  (ars futura)
Shift Remote: AI: How Does Face Recognition Work (ars futura)
 
Shift Remote: AI: Behind the scenes development in an AI company - Matija Ili...
Shift Remote: AI: Behind the scenes development in an AI company - Matija Ili...Shift Remote: AI: Behind the scenes development in an AI company - Matija Ili...
Shift Remote: AI: Behind the scenes development in an AI company - Matija Ili...
 
Shift Remote: AI: Smarter AI with analytical graph databases - Victor Lee (Ti...
Shift Remote: AI: Smarter AI with analytical graph databases - Victor Lee (Ti...Shift Remote: AI: Smarter AI with analytical graph databases - Victor Lee (Ti...
Shift Remote: AI: Smarter AI with analytical graph databases - Victor Lee (Ti...
 
Shift Remote: DevOps: Devops with Azure Devops and Github - Juarez Junior (Mi...
Shift Remote: DevOps: Devops with Azure Devops and Github - Juarez Junior (Mi...Shift Remote: DevOps: Devops with Azure Devops and Github - Juarez Junior (Mi...
Shift Remote: DevOps: Devops with Azure Devops and Github - Juarez Junior (Mi...
 
Shift Remote: DevOps: Autodesks research into digital twins for AEC - Kean W...
Shift Remote: DevOps: Autodesks research into digital twins for AEC -  Kean W...Shift Remote: DevOps: Autodesks research into digital twins for AEC -  Kean W...
Shift Remote: DevOps: Autodesks research into digital twins for AEC - Kean W...
 
Shift Remote: DevOps: When metrics are not enough, and everyone is on-call - ...
Shift Remote: DevOps: When metrics are not enough, and everyone is on-call - ...Shift Remote: DevOps: When metrics are not enough, and everyone is on-call - ...
Shift Remote: DevOps: When metrics are not enough, and everyone is on-call - ...
 
Shift Remote: DevOps: Modern incident management with opsgenie - Kristijan L...
Shift Remote: DevOps: Modern incident management with opsgenie -  Kristijan L...Shift Remote: DevOps: Modern incident management with opsgenie -  Kristijan L...
Shift Remote: DevOps: Modern incident management with opsgenie - Kristijan L...
 
Shift Remote: DevOps: Gitlab ci hands-on experience - Ivan Rimac (Barrage)
Shift Remote: DevOps: Gitlab ci hands-on experience - Ivan Rimac (Barrage)Shift Remote: DevOps: Gitlab ci hands-on experience - Ivan Rimac (Barrage)
Shift Remote: DevOps: Gitlab ci hands-on experience - Ivan Rimac (Barrage)
 
Shift Remote: DevOps: DevOps Heroes - Adding Advanced Automation to your Tool...
Shift Remote: DevOps: DevOps Heroes - Adding Advanced Automation to your Tool...Shift Remote: DevOps: DevOps Heroes - Adding Advanced Automation to your Tool...
Shift Remote: DevOps: DevOps Heroes - Adding Advanced Automation to your Tool...
 
Shift Remote: DevOps: An (Un)expected Journey - Zeljko Margeta (RBA)
Shift Remote: DevOps: An (Un)expected Journey - Zeljko Margeta (RBA)Shift Remote: DevOps: An (Un)expected Journey - Zeljko Margeta (RBA)
Shift Remote: DevOps: An (Un)expected Journey - Zeljko Margeta (RBA)
 
Shift Remote: Game Dev - Localising Mobile Games - Marta Kunic (Nanobit)
Shift Remote: Game Dev - Localising Mobile Games - Marta Kunic (Nanobit)Shift Remote: Game Dev - Localising Mobile Games - Marta Kunic (Nanobit)
Shift Remote: Game Dev - Localising Mobile Games - Marta Kunic (Nanobit)
 
Shift Remote: Game Dev - Challenges Introducing Open Source to the Games Indu...
Shift Remote: Game Dev - Challenges Introducing Open Source to the Games Indu...Shift Remote: Game Dev - Challenges Introducing Open Source to the Games Indu...
Shift Remote: Game Dev - Challenges Introducing Open Source to the Games Indu...
 
Shift Remote: Game Dev - Ghost in the Machine: Authorial Voice in System Desi...
Shift Remote: Game Dev - Ghost in the Machine: Authorial Voice in System Desi...Shift Remote: Game Dev - Ghost in the Machine: Authorial Voice in System Desi...
Shift Remote: Game Dev - Ghost in the Machine: Authorial Voice in System Desi...
 
Shift Remote: Game Dev - Building Better Worlds with Game Culturalization - K...
Shift Remote: Game Dev - Building Better Worlds with Game Culturalization - K...Shift Remote: Game Dev - Building Better Worlds with Game Culturalization - K...
Shift Remote: Game Dev - Building Better Worlds with Game Culturalization - K...
 
Shift Remote: Game Dev - Open Match: An Open Source Matchmaking Framework - J...
Shift Remote: Game Dev - Open Match: An Open Source Matchmaking Framework - J...Shift Remote: Game Dev - Open Match: An Open Source Matchmaking Framework - J...
Shift Remote: Game Dev - Open Match: An Open Source Matchmaking Framework - J...
 
Shift Remote: Game Dev - Designing Inside the Box - Fernando Reyes Medina (34...
Shift Remote: Game Dev - Designing Inside the Box - Fernando Reyes Medina (34...Shift Remote: Game Dev - Designing Inside the Box - Fernando Reyes Medina (34...
Shift Remote: Game Dev - Designing Inside the Box - Fernando Reyes Medina (34...
 
Shift Remote: Mobile - Efficiently Building Native Frameworks for Multiple Pl...
Shift Remote: Mobile - Efficiently Building Native Frameworks for Multiple Pl...Shift Remote: Mobile - Efficiently Building Native Frameworks for Multiple Pl...
Shift Remote: Mobile - Efficiently Building Native Frameworks for Multiple Pl...
 
Shift Remote: Mobile - Introduction to MotionLayout on Android - Denis Fodor ...
Shift Remote: Mobile - Introduction to MotionLayout on Android - Denis Fodor ...Shift Remote: Mobile - Introduction to MotionLayout on Android - Denis Fodor ...
Shift Remote: Mobile - Introduction to MotionLayout on Android - Denis Fodor ...
 
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
 
Shift Remote: WEB - The Features of WebXR Beyond Virtual Reality - Ada Rose C...
Shift Remote: WEB - The Features of WebXR Beyond Virtual Reality - Ada Rose C...Shift Remote: WEB - The Features of WebXR Beyond Virtual Reality - Ada Rose C...
Shift Remote: WEB - The Features of WebXR Beyond Virtual Reality - Ada Rose C...
 

Recently uploaded

audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkkaudience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
lolsDocherty
 
Article writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptxArticle writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptx
abhinandnam9997
 
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
aagad
 

Recently uploaded (13)

Bug Bounty Blueprint : A Beginner's Guide
Bug Bounty Blueprint : A Beginner's GuideBug Bounty Blueprint : A Beginner's Guide
Bug Bounty Blueprint : A Beginner's Guide
 
The Best AI Powered Software - Intellivid AI Studio
The Best AI Powered Software - Intellivid AI StudioThe Best AI Powered Software - Intellivid AI Studio
The Best AI Powered Software - Intellivid AI Studio
 
The AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdfThe AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdf
 
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkkaudience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
 
How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?
 
Article writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptxArticle writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptx
 
Pvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdfPvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdf
 
The Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyThe Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case Study
 
Case study on merger of Vodafone and Idea (VI).pptx
Case study on merger of Vodafone and Idea (VI).pptxCase study on merger of Vodafone and Idea (VI).pptx
Case study on merger of Vodafone and Idea (VI).pptx
 
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 

Shift Remote: WEB - GraphQL and React – Quick Start - Dubravko Bogovic (Infobip)

  • 1. GraphQL and React Quick Start #graphql #hasura #simple #fun #magic Dubravko Bogović, 14.07.2020 SHIFT REMOTE 2020
  • 2. The good old REST API
  • 3.
  • 4. Enter GraphQL • A query language for your API - https://graphql.org/ • Flexible data acquisition ‣ Get only what you need ‣ Multiple resources at once ‣ Filter or sort the data ‣ Change the requirements easily Describe your data type Project { name: number; tagline: number; contributors:[User]; } Ask for what you want { project(where: { name: {_eq: "GraphQL" } }) { tagline } } Get predictable results { "project": { "tagline": "A query language for APIs" } }
  • 5. GraphQL Features • Drawbacks: ‣ No file upload in specification ‣ Returns only JSON ‣ Caching must be custom built ‣ Complex queries can be slow ‣ Slower learning curve • Features: ‣ Flexible data acquisition ‣ Built-in introspection ‣ Strongly typed ‣ Client-driven ‣ Rapid application development ‣ Code sharing ‣ Detailed error messages ‣ Fine grain permission ‣ Data subscriptions ‣ Combining schemas (APIs)
  • 6. Who Uses GraphQL? • Developed internally by Facebook • https://graphql.org/users/ • A Google search revels even more and much bigger users (link) ‣ Shopify ‣ GitHub ‣ Medium ‣ Docker ‣ Twitter ‣ IBM (technical blog post) ‣ Netflix (technical blog post) ‣ Sainsbury (technical blog post) ‣ Yelp ‣ Infobip ‣ … Netflix IBM
  • 7. GraphQL Operations – quick overview Mutations • Fragments ‣ Reusable code fragments • Directives ‣ Allow dynamic changes to the query structure GraphQL flavors • Data management action mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) { createReview(episode: $ep, review: $review) { stars commentary } } Variables: { "ep": "JEDI", "review": { "stars": 5, "commentary": "This is a great movie!" } } Result: { "data": { "createReview": { "stars": 5, "commentary": "This is a great movie!" } } } Queries • Data fetch actions • Elements ‣ Operation type ‣ Operation name ‣ Variables ‣ Variable type query UserData($alignment: String = "good") { user(id: 1, alignment: $alignment) { name: full_name title home_planet { name sector } } } ‣ Default value ‣ Entity name ‣ Arguments ‣ Fields ‣ Alias fragment userFields on User { name: full_name title } query Hero($withFriends: Boolean!) { hero { name friends @include(if: $withFriends) { name } } } • Subscriptions ‣ Queries with real time data
  • 8. Hasura GraphQL Engine • GraphQL engine that can easily be added to an existing PostgreSQL database • Features: ‣ Realtime data with GraphQL subscriptions ‣ Dynamic access control that integrates with your auth ‣ Allow-list for GraphQL queries ‣ Merge remote GraphQL schemas ‣ Trigger webhooks on database events ‣ Schema migrations ‣ Query performance analysis
  • 9. Apollo React.js client • For our current projects we use the Apollo client to connect to our Hasura GraphQL server • Components we use: ‣ apollo-link-http ‣ apollo-link-ws ‣ subscriptions-transport-ws ‣ apollo-link-context ‣ apollo-client ‣ apollo-cache-inmemory
  • 10. Demo Todo application Github - https://github.com/AvronNet/GraphQL_quickStart
  • 11. Going beyond • https://gramps.js.org/ - GrAMPS (GraphQL Apollo Microservice Pattern Server) ‣ GraphQL at massive scale: GraphQL as the glue in a microservice architecture • GraphQL server libraries in many languages - https://graphql.org/code/ ‣ GraphQL DotNet • https://github.com/graphql-dotnet/graphql-dotnet • Building a GraphQL API with ASP.NET Core 2 and Entity Framework Core ‣ GraphQL Java - https://www.graphql-java.com/ • OpenAPI to GraphQL - https://github.com/ibm/openapi-to-graphql ‣ https://developer.ibm.com/open/projects/openapi-to-graphql/ (great short video) • Top 5 GraphQL Predictions for 2019 – GraphQL adoption will grow • A bundle of useful links about GraphQL - https://wiki.nikitavoloboev.xyz/networking/graphql
  • 12. May GraphQL be with you dubravko.bogovic@gmail.com