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
Shift Remote: WEB - GraphQL and React – Quick Start - Dubravko Bogovic (Infobip)
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

PPTX
GraphQL, Redux, and React
PPTX
The API Journey: from REST to GraphQL
PPTX
The API Journey: GraphQL Specification and Implementation
PDF
Introduction to GraphQL at API days
PDF
Intro to GraphQL
PDF
I/O intensiveなKafka ConsumerアプリケーションのスループットをLINE Ads Platformではどのように改善したか
PDF
Better APIs with GraphQL
PDF
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
GraphQL, Redux, and React
The API Journey: from REST to GraphQL
The API Journey: GraphQL Specification and Implementation
Introduction to GraphQL at API days
Intro to GraphQL
I/O intensiveなKafka ConsumerアプリケーションのスループットをLINE Ads Platformではどのように改善したか
Better APIs with GraphQL
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor

What's hot (20)

PPTX
CONDG April 23 2020 - Baskar Rao - GraphQL
PPTX
An intro to GraphQL
PDF
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
PDF
Graphql
PPT
Graphql presentation
PDF
GraphQL & Relay
PDF
GraphQL With Relay Part Deux
PPTX
Elastic Stack Basic - All The Capabilities in 6.3!
PDF
GraphQL IndyJS April 2016
PDF
Adding GraphQL to your existing architecture
PDF
GraphQL in an Age of REST
PDF
The journey of Moving from AWS ELK to GCP Data Pipeline
PDF
Building GraphQL Servers with Node.JS & Prisma
PPTX
Serverless GraphQL. AppSync 101
PDF
GraphQL + relay
PDF
SAS integration with NoSQL data
PPTX
GraphQL Introduction
PDF
Selenium camp 2017. Alexander Chumakin
PDF
Data Provision API with BigQuery - Google Cloud Summit Jakarta 18
PDF
The Magic of LINE 購物 Testing
CONDG April 23 2020 - Baskar Rao - GraphQL
An intro to GraphQL
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Graphql
Graphql presentation
GraphQL & Relay
GraphQL With Relay Part Deux
Elastic Stack Basic - All The Capabilities in 6.3!
GraphQL IndyJS April 2016
Adding GraphQL to your existing architecture
GraphQL in an Age of REST
The journey of Moving from AWS ELK to GCP Data Pipeline
Building GraphQL Servers with Node.JS & Prisma
Serverless GraphQL. AppSync 101
GraphQL + relay
SAS integration with NoSQL data
GraphQL Introduction
Selenium camp 2017. Alexander Chumakin
Data Provision API with BigQuery - Google Cloud Summit Jakarta 18
The Magic of LINE 購物 Testing
Ad

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

PDF
Tutorial: Building a GraphQL API in PHP
PDF
Getting started with Apollo Client and GraphQL
PDF
Graphql usage
PPTX
Building a GraphQL API in PHP
PPTX
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
PPTX
How to provide a GraphQL API - I want it that way
PPTX
Introduction to Graph QL
PDF
Serverless GraphQL for Product Developers
PDF
GraphQL and its schema as a universal layer for database access
PDF
PiterPy 2016: Parallelization, Aggregation and Validation of API in Python
PDF
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
PDF
Modern APIs with GraphQL
PDF
Multi model-databases
PDF
Multi model-databases
PDF
GraphQL across the stack: How everything fits together
PPTX
Connecting the Dots: Kong for GraphQL Endpoints
PDF
Grails 101
PDF
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
PPT
Pentest Application With GraphQL | Null Bangalore Meetup
PDF
GraphQL: Enabling a new generation of API developer tools
Tutorial: Building a GraphQL API in PHP
Getting started with Apollo Client and GraphQL
Graphql usage
Building a GraphQL API in PHP
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
How to provide a GraphQL API - I want it that way
Introduction to Graph QL
Serverless GraphQL for Product Developers
GraphQL and its schema as a universal layer for database access
PiterPy 2016: Parallelization, Aggregation and Validation of API in Python
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
Modern APIs with GraphQL
Multi model-databases
Multi model-databases
GraphQL across the stack: How everything fits together
Connecting the Dots: Kong for GraphQL Endpoints
Grails 101
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
Pentest Application With GraphQL | Null Bangalore Meetup
GraphQL: Enabling a new generation of API developer tools
Ad

More from Shift Conference (20)

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

Recently uploaded (20)

PPTX
presentation_pfe-universite-molay-seltan.pptx
PPTX
Introduction to Information and Communication Technology
PPTX
Digital Literacy And Online Safety on internet
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PPTX
international classification of diseases ICD-10 review PPT.pptx
PDF
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
PDF
Introduction to the IoT system, how the IoT system works
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PPTX
Introuction about WHO-FIC in ICD-10.pptx
DOCX
Unit-3 cyber security network security of internet system
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PDF
How to Ensure Data Integrity During Shopify Migration_ Best Practices for Sec...
PPTX
E -tech empowerment technologies PowerPoint
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
presentation_pfe-universite-molay-seltan.pptx
Introduction to Information and Communication Technology
Digital Literacy And Online Safety on internet
Module 1 - Cyber Law and Ethics 101.pptx
introduction about ICD -10 & ICD-11 ppt.pptx
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
international classification of diseases ICD-10 review PPT.pptx
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
Introduction to the IoT system, how the IoT system works
Cloud-Scale Log Monitoring _ Datadog.pdf
RPKI Status Update, presented by Makito Lay at IDNOG 10
An introduction to the IFRS (ISSB) Stndards.pdf
Decoding a Decade: 10 Years of Applied CTI Discipline
Introuction about WHO-FIC in ICD-10.pptx
Unit-3 cyber security network security of internet system
522797556-Unit-2-Temperature-measurement-1-1.pptx
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
How to Ensure Data Integrity During Shopify Migration_ Best Practices for Sec...
E -tech empowerment technologies PowerPoint
Job_Card_System_Styled_lorem_ipsum_.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
  • 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