SlideShare a Scribd company logo
2
Most read
4
Most read
12
Most read
An intro to GraphQL
Suraj Paul
https://www.drupal.org/u/suraj2012
● Data Query Language developed by Facebook in 2012.
● Released publicly in 2015.
● GraphQL is a query language for your API, and a server-side
runtime for executing queries by using a type system you
define for your data.
● GraphQL isn't tied to any specific database or storage engine
and is instead backed by your existing code and data.
● Drupal 8 provides module to create and expose graphQL
schema. https://www.drupal.org/project/graphql
What is GraphQL ?
Core Ideas of GraphQL
● Client Requests and Server payloads have same structure.
● The server contains the schema.
● The client dictates what it wants from the server to
provide.
Limitations of RESTful APIs
● Multiple Endpoints -- Endpoints specific to individual views
● Response Bloats -- Response contains more data, mostly
unused.
● Many Round Trips -- Complex and relational data
containing URLs.
● No backwards Compatibility -- REST APIs are versioned
● Not Introspective -- Lack Native Schema, making client
side validation difficult
● Single Endpoint -- Single Endpoint can resolve GraphQL
queries and send a single, unified
response
● Tailored Response -- Response is catered with the client
demand
● Fewer Round Trips -- Returns a single response flexible to
accommodate many relationships
● Backward Compatibility -- common response for each
version
● Introspective -- Native and Highly Extensible Schema
How GraphQL Resolves this
Operations
GraphQL provide 2 types of operations
● Query
● Mutations
Query:
query {
nodeById(id: 1) {
title
}
}
Fields can describe relationships with other data. Fields return
values and can carry arguments.
Arguments
{
nodeById(id: "1") {
title
}
}
Arguments
Fragments
GraphQL includes reusable units called fragments. Fragments let you
construct sets of fields, and then include them in queries where you
need to.
fragment nodeFields on NodeArticle {
nid
type {
targetId
}
created
}
{ nodeQuery: nodeById(id: "2") {
...nodeFields
}
}
Variables
Sometimes we need to pass dynamic values to query. We can pass
dynamic values using variables in GraphQL.
query getArticle($nid: String!) {
nodeById(id: $nid) {
title
}
}
{
"nid": "2"
}
Mutation
● Most discussions of GraphQL focus on data fetching, but any
complete data platform needs a way to modify server-side data as
well.
● A module GraphQL Mutation is needed to perform POST
operations. https://www.drupal.org/project/graphql_mutation
● The module Adds GraphQL mutations for all content entities.
mutation ($input: NodeArticleCreateInput!) {
createNodeArticle(input: $input) {
violations {
path
message
}
errors
entity {
entityId
entityBundle
entityLabel
}
}
}
Mutation
● GraphQL in action in Drupal 8
Demo
Future in Drupal
● Decoupled Drupal using React & graphQL . An example is given on
https://github.com/fubhy/drupal-decoupled-app
● A number of modules supported by amazee.io.
https://www.amazeelabs.com/en/blog/drupal-graphql-batt
Eries-included
● Drupal and GraphQL with React and Apollo
https://www.amazeelabs.com/en/blog/drupal-graphql-react-apollo
Thank you

More Related Content

PDF
Introduction to GraphQL
PPT
Graphql presentation
PPTX
Introduction to GraphQL
PDF
REST vs GraphQL
PDF
Understanding MicroSERVICE Architecture with Java & Spring Boot
PPTX
Introduction to GraphQL
PDF
Smart retail using IOT
PPTX
Intelligent shopping cart
Introduction to GraphQL
Graphql presentation
Introduction to GraphQL
REST vs GraphQL
Understanding MicroSERVICE Architecture with Java & Spring Boot
Introduction to GraphQL
Smart retail using IOT
Intelligent shopping cart

What's hot (20)

PDF
Intro to GraphQL
PDF
GraphQL: Enabling a new generation of API developer tools
PDF
React & GraphQL
PPTX
Introduction to graphQL
PPTX
GraphQL Introduction
PDF
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
PDF
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
PDF
Better APIs with GraphQL
PDF
How to GraphQL: React Apollo
PPTX
Intro GraphQL
PDF
Introduction to GraphQL
PDF
How to GraphQL
PDF
GraphQL Fundamentals
PDF
Spring GraphQL
PDF
GraphQL
PDF
Graphql
PPTX
Introduction to GraphQL Presentation.pptx
PPTX
GraphQL API Gateway and microservices
PDF
Wroclaw GraphQL - GraphQL in Java
PDF
Getting started with Apollo Client and GraphQL
Intro to GraphQL
GraphQL: Enabling a new generation of API developer tools
React & GraphQL
Introduction to graphQL
GraphQL Introduction
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Better APIs with GraphQL
How to GraphQL: React Apollo
Intro GraphQL
Introduction to GraphQL
How to GraphQL
GraphQL Fundamentals
Spring GraphQL
GraphQL
Graphql
Introduction to GraphQL Presentation.pptx
GraphQL API Gateway and microservices
Wroclaw GraphQL - GraphQL in Java
Getting started with Apollo Client and GraphQL
Ad

Similar to An intro to GraphQL (20)

PDF
Getting Started with Spring for GraphQL
PDF
Tutorial: Building a GraphQL API in PHP
PDF
GraphQL-ify your APIs
PPTX
GraphQL_devoxx_2023.pptx
PPTX
Apollo 4 Kotlin made me Graphql and I learned how to use it
PDF
GraphQL-ify your API - JFall 2022
PDF
GraphQL + relay
PDF
Modern APIs with GraphQL
PDF
Training Week: GraphQL 2022
PDF
GraphQL in an Age of REST
PPTX
GraphQL & DGraph with Go
PDF
GraphQL with .NET Core Microservices.pdf
PPTX
Harnessing the Power of GraphQL in WordPress
PPTX
CONDG April 23 2020 - Baskar Rao - GraphQL
PDF
Introduction to GraphQL
PPTX
Introduction to Graph QL
PPTX
GraphQl Introduction
PPTX
Attacking GraphQL
PPTX
Kotlin REST & GraphQL API
PDF
Building Fullstack Serverless GraphQL APIs In The Cloud
Getting Started with Spring for GraphQL
Tutorial: Building a GraphQL API in PHP
GraphQL-ify your APIs
GraphQL_devoxx_2023.pptx
Apollo 4 Kotlin made me Graphql and I learned how to use it
GraphQL-ify your API - JFall 2022
GraphQL + relay
Modern APIs with GraphQL
Training Week: GraphQL 2022
GraphQL in an Age of REST
GraphQL & DGraph with Go
GraphQL with .NET Core Microservices.pdf
Harnessing the Power of GraphQL in WordPress
CONDG April 23 2020 - Baskar Rao - GraphQL
Introduction to GraphQL
Introduction to Graph QL
GraphQl Introduction
Attacking GraphQL
Kotlin REST & GraphQL API
Building Fullstack Serverless GraphQL APIs In The Cloud
Ad

More from valuebound (20)

PDF
Scaling Drupal for High Traffic Websites
PDF
Drupal 7 to Drupal 10 Migration A Fintech Strategic Blueprint (1).pdf
PDF
How to Use DDEV to Streamline Your Drupal Development Process.
PDF
How to Use AWS to Automate Your IT Operation| Valuebound
PDF
How to Use Firebase to Send Push Notifications to React Native and Node.js Apps
PDF
Mastering Drupal Theming
PDF
The Benefits of Cloud Engineering
PDF
Cloud Computing
PDF
The Future of Cloud Engineering: Emerging Trends and Technologies to Watch in...
PDF
Deep dive into ChatGPT
PDF
Content Creation Solution | Valuebound
PPTX
Road ahead for Drupal 8 contributed projects
PPTX
Chatbot with RASA | Valuebound
PDF
Drupal and Artificial Intelligence for Personalization
PPTX
Drupal growth in last year | Valuebound
PPTX
BE NEW TO THE WORLD "BRAVE FROM CHROME"
PPTX
Event loop in browser
PPTX
The Basics of MongoDB
PPTX
React JS: A Secret Preview
PPTX
Dependency Injection in Drupal 8
Scaling Drupal for High Traffic Websites
Drupal 7 to Drupal 10 Migration A Fintech Strategic Blueprint (1).pdf
How to Use DDEV to Streamline Your Drupal Development Process.
How to Use AWS to Automate Your IT Operation| Valuebound
How to Use Firebase to Send Push Notifications to React Native and Node.js Apps
Mastering Drupal Theming
The Benefits of Cloud Engineering
Cloud Computing
The Future of Cloud Engineering: Emerging Trends and Technologies to Watch in...
Deep dive into ChatGPT
Content Creation Solution | Valuebound
Road ahead for Drupal 8 contributed projects
Chatbot with RASA | Valuebound
Drupal and Artificial Intelligence for Personalization
Drupal growth in last year | Valuebound
BE NEW TO THE WORLD "BRAVE FROM CHROME"
Event loop in browser
The Basics of MongoDB
React JS: A Secret Preview
Dependency Injection in Drupal 8

Recently uploaded (20)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Big Data Technologies - Introduction.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Cloud computing and distributed systems.
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
20250228 LYD VKU AI Blended-Learning.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Network Security Unit 5.pdf for BCA BBA.
Reach Out and Touch Someone: Haptics and Empathic Computing
Digital-Transformation-Roadmap-for-Companies.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Understanding_Digital_Forensics_Presentation.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Big Data Technologies - Introduction.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
MYSQL Presentation for SQL database connectivity
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Chapter 3 Spatial Domain Image Processing.pdf
Spectral efficient network and resource selection model in 5G networks
Diabetes mellitus diagnosis method based random forest with bat algorithm
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Cloud computing and distributed systems.
Programs and apps: productivity, graphics, security and other tools
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

An intro to GraphQL

  • 1. An intro to GraphQL Suraj Paul https://www.drupal.org/u/suraj2012
  • 2. ● Data Query Language developed by Facebook in 2012. ● Released publicly in 2015. ● GraphQL is a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data. ● GraphQL isn't tied to any specific database or storage engine and is instead backed by your existing code and data. ● Drupal 8 provides module to create and expose graphQL schema. https://www.drupal.org/project/graphql What is GraphQL ?
  • 3. Core Ideas of GraphQL ● Client Requests and Server payloads have same structure. ● The server contains the schema. ● The client dictates what it wants from the server to provide.
  • 4. Limitations of RESTful APIs ● Multiple Endpoints -- Endpoints specific to individual views ● Response Bloats -- Response contains more data, mostly unused. ● Many Round Trips -- Complex and relational data containing URLs. ● No backwards Compatibility -- REST APIs are versioned ● Not Introspective -- Lack Native Schema, making client side validation difficult
  • 5. ● Single Endpoint -- Single Endpoint can resolve GraphQL queries and send a single, unified response ● Tailored Response -- Response is catered with the client demand ● Fewer Round Trips -- Returns a single response flexible to accommodate many relationships ● Backward Compatibility -- common response for each version ● Introspective -- Native and Highly Extensible Schema How GraphQL Resolves this
  • 6. Operations GraphQL provide 2 types of operations ● Query ● Mutations Query: query { nodeById(id: 1) { title } }
  • 7. Fields can describe relationships with other data. Fields return values and can carry arguments. Arguments { nodeById(id: "1") { title } } Arguments
  • 8. Fragments GraphQL includes reusable units called fragments. Fragments let you construct sets of fields, and then include them in queries where you need to. fragment nodeFields on NodeArticle { nid type { targetId } created } { nodeQuery: nodeById(id: "2") { ...nodeFields } }
  • 9. Variables Sometimes we need to pass dynamic values to query. We can pass dynamic values using variables in GraphQL. query getArticle($nid: String!) { nodeById(id: $nid) { title } } { "nid": "2" }
  • 10. Mutation ● Most discussions of GraphQL focus on data fetching, but any complete data platform needs a way to modify server-side data as well. ● A module GraphQL Mutation is needed to perform POST operations. https://www.drupal.org/project/graphql_mutation ● The module Adds GraphQL mutations for all content entities.
  • 11. mutation ($input: NodeArticleCreateInput!) { createNodeArticle(input: $input) { violations { path message } errors entity { entityId entityBundle entityLabel } } } Mutation
  • 12. ● GraphQL in action in Drupal 8 Demo
  • 13. Future in Drupal ● Decoupled Drupal using React & graphQL . An example is given on https://github.com/fubhy/drupal-decoupled-app ● A number of modules supported by amazee.io. https://www.amazeelabs.com/en/blog/drupal-graphql-batt Eries-included ● Drupal and GraphQL with React and Apollo https://www.amazeelabs.com/en/blog/drupal-graphql-react-apollo