SlideShare une entreprise Scribd logo
1  sur  52
© 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!

Contenu connexe

Tendances

REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQLSquareboat
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsSashko Stubailo
 
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
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQLTomasz Bak
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL StackSashko Stubailo
 
Getting Started with Spring for GraphQL
Getting Started with Spring for GraphQLGetting Started with Spring for GraphQL
Getting Started with Spring for GraphQLVMware Tanzu
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQLvaluebound
 
GraphQL API Gateway and microservices
GraphQL API Gateway and microservicesGraphQL API Gateway and microservices
GraphQL API Gateway and microservicesMohammed Shaban
 
GraphQL Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL IntroductionSerge Huber
 
Introduction to PWA Studio by Vijay Golani
Introduction to PWA Studio by Vijay GolaniIntroduction to PWA Studio by Vijay Golani
Introduction to PWA Studio by Vijay Golanivijaygolani
 
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...luisw19
 
Micro Front Ends for Micro Services using Oracle JET
Micro Front Ends for Micro Services using Oracle JETMicro Front Ends for Micro Services using Oracle JET
Micro Front Ends for Micro Services using Oracle JETVijay Nair
 
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 GraphQLMorgan Dedmon
 
GraphQL vs REST
GraphQL vs RESTGraphQL vs REST
GraphQL vs RESTGreeceJS
 
Apicurio Registry: Event-driven APIs & Schema governance for Apache Kafka | F...
Apicurio Registry: Event-driven APIs & Schema governance for Apache Kafka | F...Apicurio Registry: Event-driven APIs & Schema governance for Apache Kafka | F...
Apicurio Registry: Event-driven APIs & Schema governance for Apache Kafka | F...HostedbyConfluent
 

Tendances (20)

REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQL
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer tools
 
GraphQL Fundamentals
GraphQL FundamentalsGraphQL Fundamentals
GraphQL Fundamentals
 
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
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQL
 
Intro GraphQL
Intro GraphQLIntro GraphQL
Intro GraphQL
 
Graphql
GraphqlGraphql
Graphql
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
 
Getting Started with Spring for GraphQL
Getting Started with Spring for GraphQLGetting Started with Spring for GraphQL
Getting Started with Spring for GraphQL
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQL
 
GraphQL API Gateway and microservices
GraphQL API Gateway and microservicesGraphQL API Gateway and microservices
GraphQL API Gateway and microservices
 
GraphQL Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL Introduction
 
Introduction to PWA Studio by Vijay Golani
Introduction to PWA Studio by Vijay GolaniIntroduction to PWA Studio by Vijay Golani
Introduction to PWA Studio by Vijay Golani
 
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
 
Micro Front Ends for Micro Services using Oracle JET
Micro Front Ends for Micro Services using Oracle JETMicro Front Ends for Micro Services using Oracle JET
Micro Front Ends for Micro Services using Oracle JET
 
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 vs REST
GraphQL vs RESTGraphQL vs REST
GraphQL vs REST
 
Apicurio Registry: Event-driven APIs & Schema governance for Apache Kafka | F...
Apicurio Registry: Event-driven APIs & Schema governance for Apache Kafka | F...Apicurio Registry: Event-driven APIs & Schema governance for Apache Kafka | F...
Apicurio Registry: Event-driven APIs & Schema governance for Apache Kafka | F...
 
Git and git hub basics
Git and git hub basicsGit and git hub basics
Git and git hub basics
 

Similaire à Magento2.3 - GraphQL introduction

GraphQL research summary
GraphQL research summaryGraphQL research summary
GraphQL research summaryObjectivity
 
Graphql for Frontend Developers Simplifying Data Fetching.docx
Graphql for Frontend Developers Simplifying Data Fetching.docxGraphql for Frontend Developers Simplifying Data Fetching.docx
Graphql for Frontend Developers Simplifying Data Fetching.docxssuser5583681
 
Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...
Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...
Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...ssuser5583681
 
Scaling Your Team With GraphQL: Why Relationships Matter
Scaling Your Team With GraphQL: Why Relationships MatterScaling Your Team With GraphQL: Why Relationships Matter
Scaling Your Team With GraphQL: Why Relationships MatterJoel Bowen
 
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 togetherSashko Stubailo
 
GraphQL Advanced
GraphQL AdvancedGraphQL Advanced
GraphQL AdvancedLeanIX GmbH
 
apidays Helsinki & North 2023 - The future of API Management, Jona Apelbaum &...
apidays Helsinki & North 2023 - The future of API Management, Jona Apelbaum &...apidays Helsinki & North 2023 - The future of API Management, Jona Apelbaum &...
apidays Helsinki & North 2023 - The future of API Management, Jona Apelbaum &...apidays
 
Intro to GraphQL for Database Developers
Intro to GraphQL for Database DevelopersIntro to GraphQL for Database Developers
Intro to GraphQL for Database DevelopersDaniel McGhan
 
High performing Salesforce Data Connectors
High performing Salesforce Data ConnectorsHigh performing Salesforce Data Connectors
High performing Salesforce Data ConnectorsNishanth Kadiyala
 
Marcia Villalba "Developing Serverless Applications with GraphQL"
Marcia Villalba "Developing Serverless Applications with GraphQL"Marcia Villalba "Developing Serverless Applications with GraphQL"
Marcia Villalba "Developing Serverless Applications with GraphQL"Fwdays
 
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 YouMeet Magento Italy
 
PyCon Korea - Real World Graphene
PyCon Korea - Real World GraphenePyCon Korea - Real World Graphene
PyCon Korea - Real World GrapheneMarcin Gębala
 
MyEclipse G IDE, Google Cloud
MyEclipse G IDE, Google CloudMyEclipse G IDE, Google Cloud
MyEclipse G IDE, Google CloudGenuitec, LLC
 
Verifying Apache Kafka-Based Data Pipelines With Subhangi Agarwala | Current ...
Verifying Apache Kafka-Based Data Pipelines With Subhangi Agarwala | Current ...Verifying Apache Kafka-Based Data Pipelines With Subhangi Agarwala | Current ...
Verifying Apache Kafka-Based Data Pipelines With Subhangi Agarwala | Current ...HostedbyConfluent
 
Gimel at Dataworks Summit San Jose 2018
Gimel at Dataworks Summit San Jose 2018Gimel at Dataworks Summit San Jose 2018
Gimel at Dataworks Summit San Jose 2018Romit Mehta
 
Dataworks | 2018-06-20 | Gimel data platform
Dataworks | 2018-06-20 | Gimel data platformDataworks | 2018-06-20 | Gimel data platform
Dataworks | 2018-06-20 | Gimel data platformDeepak Chandramouli
 
GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0Tobias Meixner
 
GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018Sashko Stubailo
 
Grokking Techtalk #40: AWS’s philosophy on designing MLOps platform
Grokking Techtalk #40: AWS’s philosophy on designing MLOps platformGrokking Techtalk #40: AWS’s philosophy on designing MLOps platform
Grokking Techtalk #40: AWS’s philosophy on designing MLOps platformGrokking VN
 

Similaire à Magento2.3 - GraphQL introduction (20)

GraphQL research summary
GraphQL research summaryGraphQL research summary
GraphQL research summary
 
Graphql for Frontend Developers Simplifying Data Fetching.docx
Graphql for Frontend Developers Simplifying Data Fetching.docxGraphql for Frontend Developers Simplifying Data Fetching.docx
Graphql for Frontend Developers Simplifying Data Fetching.docx
 
Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...
Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...
Building an Android app with GraphQL Unleashing the Power of Modern Mobile De...
 
Scaling Your Team With GraphQL: Why Relationships Matter
Scaling Your Team With GraphQL: Why Relationships MatterScaling Your Team With GraphQL: Why Relationships Matter
Scaling Your Team With GraphQL: Why Relationships Matter
 
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
 
GraphQL Advanced
GraphQL AdvancedGraphQL Advanced
GraphQL Advanced
 
apidays Helsinki & North 2023 - The future of API Management, Jona Apelbaum &...
apidays Helsinki & North 2023 - The future of API Management, Jona Apelbaum &...apidays Helsinki & North 2023 - The future of API Management, Jona Apelbaum &...
apidays Helsinki & North 2023 - The future of API Management, Jona Apelbaum &...
 
Intro to GraphQL for Database Developers
Intro to GraphQL for Database DevelopersIntro to GraphQL for Database Developers
Intro to GraphQL for Database Developers
 
High performing Salesforce Data Connectors
High performing Salesforce Data ConnectorsHigh performing Salesforce Data Connectors
High performing Salesforce Data Connectors
 
Marcia Villalba "Developing Serverless Applications with GraphQL"
Marcia Villalba "Developing Serverless Applications with GraphQL"Marcia Villalba "Developing Serverless Applications with GraphQL"
Marcia Villalba "Developing Serverless Applications with GraphQL"
 
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
 
PyCon Korea - Real World Graphene
PyCon Korea - Real World GraphenePyCon Korea - Real World Graphene
PyCon Korea - Real World Graphene
 
MyEclipse G IDE, Google Cloud
MyEclipse G IDE, Google CloudMyEclipse G IDE, Google Cloud
MyEclipse G IDE, Google Cloud
 
Verifying Apache Kafka-Based Data Pipelines With Subhangi Agarwala | Current ...
Verifying Apache Kafka-Based Data Pipelines With Subhangi Agarwala | Current ...Verifying Apache Kafka-Based Data Pipelines With Subhangi Agarwala | Current ...
Verifying Apache Kafka-Based Data Pipelines With Subhangi Agarwala | Current ...
 
codersera_com (1).pdf
codersera_com (1).pdfcodersera_com (1).pdf
codersera_com (1).pdf
 
Gimel at Dataworks Summit San Jose 2018
Gimel at Dataworks Summit San Jose 2018Gimel at Dataworks Summit San Jose 2018
Gimel at Dataworks Summit San Jose 2018
 
Dataworks | 2018-06-20 | Gimel data platform
Dataworks | 2018-06-20 | Gimel data platformDataworks | 2018-06-20 | Gimel data platform
Dataworks | 2018-06-20 | Gimel data platform
 
GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0
 
GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018
 
Grokking Techtalk #40: AWS’s philosophy on designing MLOps platform
Grokking Techtalk #40: AWS’s philosophy on designing MLOps platformGrokking Techtalk #40: AWS’s philosophy on designing MLOps platform
Grokking Techtalk #40: AWS’s philosophy on designing MLOps platform
 

Dernier

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Dernier (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

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!