SlideShare a Scribd company logo
© 2019 Magento, Inc. Page | 1
Magento 2.3
Introduction to
GraphQL
© 2019 Magento, Inc.
.
Page | 2
Senior Software Engineer at BORN Group
https://www.linkedin.com/in/vishakha-borkar-9b96bb61
Vishakha Borkar
© 2019 Magento, Inc. Page | 3
Agenda
© 2019 Magento, Inc. Page | 4
Agenda
• Challenges with REST
• History and Adoption
• What is GraphQL?
• GraphQL v/s REST
• GraphQL Query Language
• GraphQL in Magento
• Magento GraphQL Implemenation
• GraphQL: Fetch combined/nested data
• GraphQL Mutations
• GraphQL Fragementation
•
© 2019 Magento, Inc. Page | 5
Challenges with REST
© 2019 Magento, Inc. Page | 6
Challenges with REST
 Increased mobile usage creates need for efficient data loading
 Variety of different frontend frameworks and platforms
 Fast development & expectation for rapid feature development
© 2019 Magento, Inc. Page | 7
History and Adoption
© 2019 Magento, Inc. Page | 8
History and Adoption
 Facebook started using GraphQL in 2012 in their native mobile apps
 Initially used and introduced with React.js
 Can be used everywhere a client needs to communicate with API
 Used by many companies. To name a few GitHub, Twitter, Yelp,
Coursea and Shopify
© 2019 Magento, Inc. Page | 9
What is GraphQL?
© 2019 Magento, Inc. Page | 10
What is GraphQL?
• GraphQL is a very powerful and strongly typed query
language.
• Used to communicate data between client and server.
GraphQL provides a complete and understandable description
of the data in your API
• Gives clients the power to ask for exactly what they need,
making it easier to evolve APIs over time
• Enables powerful development tools and thus making
GraphQL a more flexible & efficient approach than REST API.
© 2019 Magento, Inc. Page | 11
GraphQL v/s REST
© 2019 Magento, Inc. Page | 12
GraphQL v/s REST
REST GraphQL
Data Fetching Gathers data by accessing
multiple endpoints
Single query to the GraphQL server that
includes the concrete data requirements
Over- and Underfetching of
data
One of the most common
problems with REST is that
of over- and underfetching
Unlike traditional APIs, GraphQL exposes all
of the data from a single endpoint.
Rapid Product Iterations on
the Frontend
With every change that is
made to the UI, there is a
high risk that now there is
more (or less) data required
than before
changes on the client-side can be made
without any extra work on the server
Type System N/A GraphQL Schema Definition Language (SDL)
Insightful Analytics on the
Backend
Over- and Underfetching of
data are the drawbacks
Fine-grained insights about the data that’s
requested on the backend
© 2019 Magento, Inc. Page | 13
GraphQL Query
Language
© 2019 Magento, Inc. Page | 14
GraphQL Query Language
 GraphQL is an open-source query language for APIs (not databases)
developed by Facebook
 GraphQL query performs the READ operation in a GraphQL API
 It is replacement of REST
 Server-side runtime for executing queries by using a type system you
define for your data
 It is not tied to any specific database or storage engine
© 2019 Magento, Inc. Page | 15
User get what they want
© 2019 Magento, Inc. Page | 16
GraphQL in Magento
2.3
© 2019 Magento, Inc. Page | 17
Why Magento2.3 introduced GraphQL?
 GraphQL is a powerful query
language for API´s and convenient
for javascript or Progressive Web
App solutions.
 With the rise of PWA, there is a
need to get smaller amounts of
data and to make fewer API
requests.
 Allowing the requestor to request a
limited subset of attributes and
Significantly smaller responses
 Continued...
© 2019 Magento, Inc. Page | 18
 To support GraphQL, Magento is writing
an entirely new layer that interfaces
directly to the Query API
 The GraphQL implementation will be the
base on how a PWA frontend will retrieve
the data it needs
© 2019 Magento, Inc. Page | 19
Modules
© 2019 Magento, Inc. Page | 20
Current Status
Done In Progress
 Products
 Categories
 Customer
 Cms
 Coupons
 Store Config
 Shopping Cart
 Checkout
 My Account
 Wishlist
 Send to friend
© 2019 Magento, Inc. Page | 21
Magento’s GraphQL implementation
(Basic module creation)
© 2019 Magento, Inc. Page | 22
Module Structure
© 2019 Magento, Inc. Page | 23
 Defines the structure of queries.
 Determines which attributes to make available for GraphQL queries.
You can define separate lists of attributes for queries and results.
 Points to the resolvers that verify and process the query data and
response
 Serves as the source for displaying the schema in a GraphQL
browser
<module_root>/etc/schema.graphqls
© 2019 Magento, Inc. Page | 24
<module_root>/etc/schema.graphqls
© 2019 Magento, Inc. Page | 25
<module_root>/Model/Resolver/Customer.php
© 2019 Magento, Inc. Page | 26
<module_root>/Model/Resolver/Customer.php
© 2019 Magento, Inc. Page | 27
<module_root>/Model/Resolver/Customer.php
© 2019 Magento, Inc. Page | 28
ChromeiQL
 Its a simple extension wrapper around the great GraphiQL
IDE allowing it to work with any GraphQL endpoint of your
choosing.
 As long as you are authorized to send requests to the
endpoint from your current browser session (cookies are
set etc.) you are good to use ChromeiQL.
© 2019 Magento, Inc. Page | 29
Some alternates to ChromeiQL
 Insomnia
 https://support.insomnia.rest/article/61-graphql
 Altair GraphQL Client – Mozilla addon
 https://addons.mozilla.org/en-US/firefox/addon/altair-graphql-client/
© 2019 Magento, Inc. Page | 30
Set endpoint url in ChromeiQL
© 2019 Magento, Inc. Page | 31
ChromeiQL Documentation Explorer
© 2019 Magento, Inc. Page | 32
Use “testcustomer” graphQL in ChromeiQL
© 2019 Magento, Inc. Page | 33
GraphQL: Fetch combined/nested data
© 2019 Magento, Inc. Page | 34
<module_root>/etc/schema.graphqls
© 2019 Magento, Inc. Page | 35
<module_root>/Model/Resolver/Store.php
© 2019 Magento, Inc. Page | 36
<Module_Name>/Model/Resolver/Store.php
© 2019 Magento, Inc. Page | 37
Use “pickUpStore” graphQL in ChromeiQL
© 2019 Magento, Inc. Page | 38
GraphQL API Authentication
© 2019 Magento, Inc. Page | 39
Apply authentication on GraphQL Access
© 2019 Magento, Inc. Page | 40
GraphQL access with authentication
© 2019 Magento, Inc. Page | 41
GraphQL access authentication failed
© 2019 Magento, Inc. Page | 42
GraphQL Mutations
© 2019 Magento, Inc. Page | 43
GraphQL Mutation
 GraphQL queries perform read operations, mutations change
the data
 Mutations are used to perform the Create, Update, delete
operation in GraphQl.
 It is similar to POST, PUT and DELETE in REST API
© 2019 Magento, Inc. Page | 44
Basic example of mutation
© 2019 Magento, Inc. Page | 45
Magento core - mutation example
(fetch customer’s token)
© 2019 Magento, Inc. Page | 46
vendor/magento/module-customer-graph-ql/etc/schema.graphqls
© 2019 Magento, Inc. Page | 47
vendor/magento/module-customer-graph-
ql/Model/Resolver/GenerateCustomerToken.php::resolve()
© 2019 Magento, Inc. Page | 48
GraphQL Fragements
© 2019 Magento, Inc. Page | 49
 A fragment is basically a reusable piece of query.
 In GraphQL, you often need to query for the same data fields in different
queries.
 By reusing this code, we can be more efficient with our time and reuse these
pieces of query logic
GraphQL Fragements
© 2019 Magento, Inc. Page | 50
Fetch customer and pickupStore data at once
© 2019 Magento, Inc. Page | 51
Thank you!
Vishakha Borkar
Born Commerce
© 2019 Magento, Inc. Page | 52
Question!

More Related Content

What's hot (20)

Magento Payment & Vault framework
Magento Payment & Vault frameworkMagento Payment & Vault framework
Magento Payment & Vault framework
Yevhen Sentiabov
 
Apigee Demo: API Platform Overview
Apigee Demo: API Platform OverviewApigee Demo: API Platform Overview
Apigee Demo: API Platform Overview
Apigee | Google Cloud
 
GitHub Actions with Node.js
GitHub Actions with Node.jsGitHub Actions with Node.js
GitHub Actions with Node.js
Stefan Stölzle
 
Container based CI/CD on GitHub Actions
Container based CI/CD on GitHub ActionsContainer based CI/CD on GitHub Actions
Container based CI/CD on GitHub Actions
Casey Lee
 
Grafana Loki: like Prometheus, but for Logs
Grafana Loki: like Prometheus, but for LogsGrafana Loki: like Prometheus, but for Logs
Grafana Loki: like Prometheus, but for Logs
Marco Pracucci
 
Microservices & API Gateways
Microservices & API Gateways Microservices & API Gateways
Microservices & API Gateways
Kong Inc.
 
Api Gateway
Api GatewayApi Gateway
Api Gateway
KhaqanAshraf
 
Real Time Test Data with Grafana
Real Time Test Data with GrafanaReal Time Test Data with Grafana
Real Time Test Data with Grafana
Ioannis Papadakis
 
OpenTelemetry For Developers
OpenTelemetry For DevelopersOpenTelemetry For Developers
OpenTelemetry For Developers
Kevin Brockhoff
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
Behzad Altaf
 
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
Prometheus - Intro, CNCF, TSDB,PromQL,GrafanaPrometheus - Intro, CNCF, TSDB,PromQL,Grafana
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
Sridhar Kumar N
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQL
Tomasz Bak
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
GoogleDevelopersStud1
 
Async-await best practices in 10 minutes
Async-await best practices in 10 minutesAsync-await best practices in 10 minutes
Async-await best practices in 10 minutes
Paulo Morgado
 
Prometheus-Grafana-RahulSoni1584KnolX.pptx.pdf
Prometheus-Grafana-RahulSoni1584KnolX.pptx.pdfPrometheus-Grafana-RahulSoni1584KnolX.pptx.pdf
Prometheus-Grafana-RahulSoni1584KnolX.pptx.pdf
Knoldus Inc.
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentation
Vibhor Grover
 
Getting Started Monitoring with Prometheus and Grafana
Getting Started Monitoring with Prometheus and GrafanaGetting Started Monitoring with Prometheus and Grafana
Getting Started Monitoring with Prometheus and Grafana
Syah Dwi Prihatmoko
 
Angular Observables & RxJS Introduction
Angular Observables & RxJS IntroductionAngular Observables & RxJS Introduction
Angular Observables & RxJS Introduction
Rahat Khanna a.k.a mAppMechanic
 
JVM++: The Graal VM
JVM++: The Graal VMJVM++: The Graal VM
JVM++: The Graal VM
Martin Toshev
 
Automating CICD Pipeline with GitLab and Docker Containers for Java Applications
Automating CICD Pipeline with GitLab and Docker Containers for Java ApplicationsAutomating CICD Pipeline with GitLab and Docker Containers for Java Applications
Automating CICD Pipeline with GitLab and Docker Containers for Java Applications
Jelastic Multi-Cloud PaaS
 
Magento Payment & Vault framework
Magento Payment & Vault frameworkMagento Payment & Vault framework
Magento Payment & Vault framework
Yevhen Sentiabov
 
GitHub Actions with Node.js
GitHub Actions with Node.jsGitHub Actions with Node.js
GitHub Actions with Node.js
Stefan Stölzle
 
Container based CI/CD on GitHub Actions
Container based CI/CD on GitHub ActionsContainer based CI/CD on GitHub Actions
Container based CI/CD on GitHub Actions
Casey Lee
 
Grafana Loki: like Prometheus, but for Logs
Grafana Loki: like Prometheus, but for LogsGrafana Loki: like Prometheus, but for Logs
Grafana Loki: like Prometheus, but for Logs
Marco Pracucci
 
Microservices & API Gateways
Microservices & API Gateways Microservices & API Gateways
Microservices & API Gateways
Kong Inc.
 
Real Time Test Data with Grafana
Real Time Test Data with GrafanaReal Time Test Data with Grafana
Real Time Test Data with Grafana
Ioannis Papadakis
 
OpenTelemetry For Developers
OpenTelemetry For DevelopersOpenTelemetry For Developers
OpenTelemetry For Developers
Kevin Brockhoff
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
Behzad Altaf
 
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
Prometheus - Intro, CNCF, TSDB,PromQL,GrafanaPrometheus - Intro, CNCF, TSDB,PromQL,Grafana
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
Sridhar Kumar N
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQL
Tomasz Bak
 
Async-await best practices in 10 minutes
Async-await best practices in 10 minutesAsync-await best practices in 10 minutes
Async-await best practices in 10 minutes
Paulo Morgado
 
Prometheus-Grafana-RahulSoni1584KnolX.pptx.pdf
Prometheus-Grafana-RahulSoni1584KnolX.pptx.pdfPrometheus-Grafana-RahulSoni1584KnolX.pptx.pdf
Prometheus-Grafana-RahulSoni1584KnolX.pptx.pdf
Knoldus Inc.
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentation
Vibhor Grover
 
Getting Started Monitoring with Prometheus and Grafana
Getting Started Monitoring with Prometheus and GrafanaGetting Started Monitoring with Prometheus and Grafana
Getting Started Monitoring with Prometheus and Grafana
Syah Dwi Prihatmoko
 
Automating CICD Pipeline with GitLab and Docker Containers for Java Applications
Automating CICD Pipeline with GitLab and Docker Containers for Java ApplicationsAutomating CICD Pipeline with GitLab and Docker Containers for Java Applications
Automating CICD Pipeline with GitLab and Docker Containers for Java Applications
Jelastic Multi-Cloud PaaS
 

Similar to Magento2.3 - GraphQL introduction (20)

PHP, the GraphQL ecosystem and GraphQLite
PHP, the GraphQL ecosystem and GraphQLitePHP, the GraphQL ecosystem and GraphQLite
PHP, the GraphQL ecosystem and GraphQLite
JEAN-GUILLAUME DUJARDIN
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
Rodrigo Prates
 
GraphQL - Tidepool Labs
GraphQL - Tidepool LabsGraphQL - Tidepool Labs
GraphQL - Tidepool Labs
Harutyun Abgaryan
 
Intro to GraphQL
Intro to GraphQLIntro to GraphQL
Intro to GraphQL
Charles Burgess
 
GraphQl Introduction
GraphQl IntroductionGraphQl Introduction
GraphQl Introduction
AbhayKumarAgrawal1
 
API Management for GraphQL
API Management for GraphQLAPI Management for GraphQL
API Management for GraphQL
WSO2
 
Taking Control of your Data with GraphQL
Taking Control of your Data with GraphQLTaking Control of your Data with GraphQL
Taking Control of your Data with GraphQL
Vinci Rufus
 
GraphQL + relay
GraphQL + relayGraphQL + relay
GraphQL + relay
Cédric GILLET
 
GraphQL Bangkok meetup 5.0
GraphQL Bangkok meetup 5.0GraphQL Bangkok meetup 5.0
GraphQL Bangkok meetup 5.0
Tobias Meixner
 
Graphql
GraphqlGraphql
Graphql
Niv Ben David
 
London React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor CharyparLondon React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor Charypar
React London Community
 
GraphQL the holy contract between client and server
GraphQL the holy contract between client and serverGraphQL the holy contract between client and server
GraphQL the holy contract between client and server
Pavel Chertorogov
 
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)
Hafiz Ismail
 
GraphQL
GraphQLGraphQL
GraphQL
Cédric GILLET
 
GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018
Sashko Stubailo
 
James Zetlen - PWA Studio Integration…With You
James Zetlen - PWA Studio Integration…With YouJames Zetlen - PWA Studio Integration…With You
James Zetlen - PWA Studio Integration…With You
Meet Magento Italy
 
GraphQL - A love story
GraphQL -  A love storyGraphQL -  A love story
GraphQL - A love story
bwullems
 
GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...
GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...
GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...
CartCoders
 
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQL
valuebound
 
PHP, the GraphQL ecosystem and GraphQLite
PHP, the GraphQL ecosystem and GraphQLitePHP, the GraphQL ecosystem and GraphQLite
PHP, the GraphQL ecosystem and GraphQLite
JEAN-GUILLAUME DUJARDIN
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
Rodrigo Prates
 
API Management for GraphQL
API Management for GraphQLAPI Management for GraphQL
API Management for GraphQL
WSO2
 
Taking Control of your Data with GraphQL
Taking Control of your Data with GraphQLTaking Control of your Data with GraphQL
Taking Control of your Data with GraphQL
Vinci Rufus
 
GraphQL Bangkok meetup 5.0
GraphQL Bangkok meetup 5.0GraphQL Bangkok meetup 5.0
GraphQL Bangkok meetup 5.0
Tobias Meixner
 
London React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor CharyparLondon React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor Charypar
React London Community
 
GraphQL the holy contract between client and server
GraphQL the holy contract between client and serverGraphQL the holy contract between client and server
GraphQL the holy contract between client and server
Pavel Chertorogov
 
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)
Hafiz Ismail
 
GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018
Sashko Stubailo
 
James Zetlen - PWA Studio Integration…With You
James Zetlen - PWA Studio Integration…With YouJames Zetlen - PWA Studio Integration…With You
James Zetlen - PWA Studio Integration…With You
Meet Magento Italy
 
GraphQL - A love story
GraphQL -  A love storyGraphQL -  A love story
GraphQL - A love story
bwullems
 
GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...
GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...
GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...
CartCoders
 
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQL
valuebound
 

Recently uploaded (20)

What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!
cryptouniversityoffi
 
Agentic AI - The New Era of Intelligence
Agentic AI - The New Era of IntelligenceAgentic AI - The New Era of Intelligence
Agentic AI - The New Era of Intelligence
Muzammil Shah
 
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 ProfessioMaster tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Kari Kakkonen
 
AI Trends - Mary Meeker
AI Trends - Mary MeekerAI Trends - Mary Meeker
AI Trends - Mary Meeker
Razin Mustafiz
 
Introducing Ensemble Cloudlet vRouter
Introducing Ensemble  Cloudlet vRouterIntroducing Ensemble  Cloudlet vRouter
Introducing Ensemble Cloudlet vRouter
Adtran
 
Maxx nft market place new generation nft marketing place
Maxx nft market place new generation nft marketing placeMaxx nft market place new generation nft marketing place
Maxx nft market place new generation nft marketing place
usersalmanrazdelhi
 
cloudgenesis cloud workshop , gdg on campus mita
cloudgenesis cloud workshop , gdg on campus mitacloudgenesis cloud workshop , gdg on campus mita
cloudgenesis cloud workshop , gdg on campus mita
siyaldhande02
 
Grannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI ExperiencesGrannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI Experiences
Lauren Parr
 
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AI Emotional Actors:  “When Machines Learn to Feel and Perform"AI Emotional Actors:  “When Machines Learn to Feel and Perform"
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AkashKumar809858
 
Talk: On an adventure into the depths of Maven - Kaya Weers
Talk: On an adventure into the depths of Maven - Kaya WeersTalk: On an adventure into the depths of Maven - Kaya Weers
Talk: On an adventure into the depths of Maven - Kaya Weers
Kaya Weers
 
Droidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing HealthcareDroidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing Healthcare
Droidal LLC
 
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCPMCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
Sambhav Kothari
 
Measuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI SuccessMeasuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI Success
Nikki Chapple
 
Dev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API WorkflowsDev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API Workflows
UiPathCommunity
 
Security Operations and the Defense Analyst - Splunk Certificate
Security Operations and the Defense Analyst - Splunk CertificateSecurity Operations and the Defense Analyst - Splunk Certificate
Security Operations and the Defense Analyst - Splunk Certificate
VICTOR MAESTRE RAMIREZ
 
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Nikki Chapple
 
Fully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and ControlFully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and Control
ShapeBlue
 
Microsoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentationMicrosoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentation
Digitalmara
 
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptxECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
Jasper Oosterveld
 
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPathCommunity
 
What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!
cryptouniversityoffi
 
Agentic AI - The New Era of Intelligence
Agentic AI - The New Era of IntelligenceAgentic AI - The New Era of Intelligence
Agentic AI - The New Era of Intelligence
Muzammil Shah
 
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 ProfessioMaster tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Kari Kakkonen
 
AI Trends - Mary Meeker
AI Trends - Mary MeekerAI Trends - Mary Meeker
AI Trends - Mary Meeker
Razin Mustafiz
 
Introducing Ensemble Cloudlet vRouter
Introducing Ensemble  Cloudlet vRouterIntroducing Ensemble  Cloudlet vRouter
Introducing Ensemble Cloudlet vRouter
Adtran
 
Maxx nft market place new generation nft marketing place
Maxx nft market place new generation nft marketing placeMaxx nft market place new generation nft marketing place
Maxx nft market place new generation nft marketing place
usersalmanrazdelhi
 
cloudgenesis cloud workshop , gdg on campus mita
cloudgenesis cloud workshop , gdg on campus mitacloudgenesis cloud workshop , gdg on campus mita
cloudgenesis cloud workshop , gdg on campus mita
siyaldhande02
 
Grannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI ExperiencesGrannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI Experiences
Lauren Parr
 
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AI Emotional Actors:  “When Machines Learn to Feel and Perform"AI Emotional Actors:  “When Machines Learn to Feel and Perform"
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AkashKumar809858
 
Talk: On an adventure into the depths of Maven - Kaya Weers
Talk: On an adventure into the depths of Maven - Kaya WeersTalk: On an adventure into the depths of Maven - Kaya Weers
Talk: On an adventure into the depths of Maven - Kaya Weers
Kaya Weers
 
Droidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing HealthcareDroidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing Healthcare
Droidal LLC
 
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCPMCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
Sambhav Kothari
 
Measuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI SuccessMeasuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI Success
Nikki Chapple
 
Dev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API WorkflowsDev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API Workflows
UiPathCommunity
 
Security Operations and the Defense Analyst - Splunk Certificate
Security Operations and the Defense Analyst - Splunk CertificateSecurity Operations and the Defense Analyst - Splunk Certificate
Security Operations and the Defense Analyst - Splunk Certificate
VICTOR MAESTRE RAMIREZ
 
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Nikki Chapple
 
Fully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and ControlFully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and Control
ShapeBlue
 
Microsoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentationMicrosoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentation
Digitalmara
 
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptxECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
Jasper Oosterveld
 
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPathCommunity
 

Magento2.3 - GraphQL introduction

  • 1. © 2019 Magento, Inc. Page | 1 Magento 2.3 Introduction to GraphQL
  • 2. © 2019 Magento, Inc. . Page | 2 Senior Software Engineer at BORN Group https://www.linkedin.com/in/vishakha-borkar-9b96bb61 Vishakha Borkar
  • 3. © 2019 Magento, Inc. Page | 3 Agenda
  • 4. © 2019 Magento, Inc. Page | 4 Agenda • Challenges with REST • History and Adoption • What is GraphQL? • GraphQL v/s REST • GraphQL Query Language • GraphQL in Magento • Magento GraphQL Implemenation • GraphQL: Fetch combined/nested data • GraphQL Mutations • GraphQL Fragementation •
  • 5. © 2019 Magento, Inc. Page | 5 Challenges with REST
  • 6. © 2019 Magento, Inc. Page | 6 Challenges with REST  Increased mobile usage creates need for efficient data loading  Variety of different frontend frameworks and platforms  Fast development & expectation for rapid feature development
  • 7. © 2019 Magento, Inc. Page | 7 History and Adoption
  • 8. © 2019 Magento, Inc. Page | 8 History and Adoption  Facebook started using GraphQL in 2012 in their native mobile apps  Initially used and introduced with React.js  Can be used everywhere a client needs to communicate with API  Used by many companies. To name a few GitHub, Twitter, Yelp, Coursea and Shopify
  • 9. © 2019 Magento, Inc. Page | 9 What is GraphQL?
  • 10. © 2019 Magento, Inc. Page | 10 What is GraphQL? • GraphQL is a very powerful and strongly typed query language. • Used to communicate data between client and server. GraphQL provides a complete and understandable description of the data in your API • Gives clients the power to ask for exactly what they need, making it easier to evolve APIs over time • Enables powerful development tools and thus making GraphQL a more flexible & efficient approach than REST API.
  • 11. © 2019 Magento, Inc. Page | 11 GraphQL v/s REST
  • 12. © 2019 Magento, Inc. Page | 12 GraphQL v/s REST REST GraphQL Data Fetching Gathers data by accessing multiple endpoints Single query to the GraphQL server that includes the concrete data requirements Over- and Underfetching of data One of the most common problems with REST is that of over- and underfetching Unlike traditional APIs, GraphQL exposes all of the data from a single endpoint. Rapid Product Iterations on the Frontend With every change that is made to the UI, there is a high risk that now there is more (or less) data required than before changes on the client-side can be made without any extra work on the server Type System N/A GraphQL Schema Definition Language (SDL) Insightful Analytics on the Backend Over- and Underfetching of data are the drawbacks Fine-grained insights about the data that’s requested on the backend
  • 13. © 2019 Magento, Inc. Page | 13 GraphQL Query Language
  • 14. © 2019 Magento, Inc. Page | 14 GraphQL Query Language  GraphQL is an open-source query language for APIs (not databases) developed by Facebook  GraphQL query performs the READ operation in a GraphQL API  It is replacement of REST  Server-side runtime for executing queries by using a type system you define for your data  It is not tied to any specific database or storage engine
  • 15. © 2019 Magento, Inc. Page | 15 User get what they want
  • 16. © 2019 Magento, Inc. Page | 16 GraphQL in Magento 2.3
  • 17. © 2019 Magento, Inc. Page | 17 Why Magento2.3 introduced GraphQL?  GraphQL is a powerful query language for API´s and convenient for javascript or Progressive Web App solutions.  With the rise of PWA, there is a need to get smaller amounts of data and to make fewer API requests.  Allowing the requestor to request a limited subset of attributes and Significantly smaller responses  Continued...
  • 18. © 2019 Magento, Inc. Page | 18  To support GraphQL, Magento is writing an entirely new layer that interfaces directly to the Query API  The GraphQL implementation will be the base on how a PWA frontend will retrieve the data it needs
  • 19. © 2019 Magento, Inc. Page | 19 Modules
  • 20. © 2019 Magento, Inc. Page | 20 Current Status Done In Progress  Products  Categories  Customer  Cms  Coupons  Store Config  Shopping Cart  Checkout  My Account  Wishlist  Send to friend
  • 21. © 2019 Magento, Inc. Page | 21 Magento’s GraphQL implementation (Basic module creation)
  • 22. © 2019 Magento, Inc. Page | 22 Module Structure
  • 23. © 2019 Magento, Inc. Page | 23  Defines the structure of queries.  Determines which attributes to make available for GraphQL queries. You can define separate lists of attributes for queries and results.  Points to the resolvers that verify and process the query data and response  Serves as the source for displaying the schema in a GraphQL browser <module_root>/etc/schema.graphqls
  • 24. © 2019 Magento, Inc. Page | 24 <module_root>/etc/schema.graphqls
  • 25. © 2019 Magento, Inc. Page | 25 <module_root>/Model/Resolver/Customer.php
  • 26. © 2019 Magento, Inc. Page | 26 <module_root>/Model/Resolver/Customer.php
  • 27. © 2019 Magento, Inc. Page | 27 <module_root>/Model/Resolver/Customer.php
  • 28. © 2019 Magento, Inc. Page | 28 ChromeiQL  Its a simple extension wrapper around the great GraphiQL IDE allowing it to work with any GraphQL endpoint of your choosing.  As long as you are authorized to send requests to the endpoint from your current browser session (cookies are set etc.) you are good to use ChromeiQL.
  • 29. © 2019 Magento, Inc. Page | 29 Some alternates to ChromeiQL  Insomnia  https://support.insomnia.rest/article/61-graphql  Altair GraphQL Client – Mozilla addon  https://addons.mozilla.org/en-US/firefox/addon/altair-graphql-client/
  • 30. © 2019 Magento, Inc. Page | 30 Set endpoint url in ChromeiQL
  • 31. © 2019 Magento, Inc. Page | 31 ChromeiQL Documentation Explorer
  • 32. © 2019 Magento, Inc. Page | 32 Use “testcustomer” graphQL in ChromeiQL
  • 33. © 2019 Magento, Inc. Page | 33 GraphQL: Fetch combined/nested data
  • 34. © 2019 Magento, Inc. Page | 34 <module_root>/etc/schema.graphqls
  • 35. © 2019 Magento, Inc. Page | 35 <module_root>/Model/Resolver/Store.php
  • 36. © 2019 Magento, Inc. Page | 36 <Module_Name>/Model/Resolver/Store.php
  • 37. © 2019 Magento, Inc. Page | 37 Use “pickUpStore” graphQL in ChromeiQL
  • 38. © 2019 Magento, Inc. Page | 38 GraphQL API Authentication
  • 39. © 2019 Magento, Inc. Page | 39 Apply authentication on GraphQL Access
  • 40. © 2019 Magento, Inc. Page | 40 GraphQL access with authentication
  • 41. © 2019 Magento, Inc. Page | 41 GraphQL access authentication failed
  • 42. © 2019 Magento, Inc. Page | 42 GraphQL Mutations
  • 43. © 2019 Magento, Inc. Page | 43 GraphQL Mutation  GraphQL queries perform read operations, mutations change the data  Mutations are used to perform the Create, Update, delete operation in GraphQl.  It is similar to POST, PUT and DELETE in REST API
  • 44. © 2019 Magento, Inc. Page | 44 Basic example of mutation
  • 45. © 2019 Magento, Inc. Page | 45 Magento core - mutation example (fetch customer’s token)
  • 46. © 2019 Magento, Inc. Page | 46 vendor/magento/module-customer-graph-ql/etc/schema.graphqls
  • 47. © 2019 Magento, Inc. Page | 47 vendor/magento/module-customer-graph- ql/Model/Resolver/GenerateCustomerToken.php::resolve()
  • 48. © 2019 Magento, Inc. Page | 48 GraphQL Fragements
  • 49. © 2019 Magento, Inc. Page | 49  A fragment is basically a reusable piece of query.  In GraphQL, you often need to query for the same data fields in different queries.  By reusing this code, we can be more efficient with our time and reuse these pieces of query logic GraphQL Fragements
  • 50. © 2019 Magento, Inc. Page | 50 Fetch customer and pickupStore data at once
  • 51. © 2019 Magento, Inc. Page | 51 Thank you! Vishakha Borkar Born Commerce
  • 52. © 2019 Magento, Inc. Page | 52 Question!