SlideShare une entreprise Scribd logo
1  sur  18
GraphQl
Name: Abhay Kumar Agrawal
Date: 18 March,2020
Topics
1. Introduction About GraphQl
2. API vs GraphQl
3. Magento2 module
4. GraphQl Tool
5. Type System
6. The Schema Definition Language(SDF)
7. Subscriptions
8. Module structure
9. Resolver
About GraphQl
● GraphQl is an open source server side technology which was developed by facebook to optimize
RESTFUL API calls.
● It is an execution engine and a data query language.
● GraphQl structures data in the form of a graph with its powerful query syntax for traversing,
retrieving and modifying data.
● The request made by a client to the GraphQl server is called a query.
● GraphQl is a query language for APIs - not a databases.
REST API vs GraphQl
GraphQl
● Single endpoint
● Client decide how data is returned
● Schema based
● Performance fast
● Development speed rapid
● Operations- Query,Mutations,subscriptions
● Specific data with a single API calls
● Community growing
REST API
● Lots of end point
● Server side decide how data is returned
● There is no schema for the data
● Multiple network calls take up more time
● Development speed slower
● Operations- CRUD
● Fixed data with multiple API calls
● Community large
GraphQl REST API
Magento2 module
There are many core module used GraphQl query language in Magento 2.3 version. Below is the list of
GraphQl Modules.
GraphQl is the parent Module for all the GraphQl related module, provides the framework for the
application to expose GraphQl compliant web services. We can check it under
folder_name/vendor/Magento/GraphQl path.
● BundleGraphQl
● CatalogGraphQl
● CatalogInventoryGraphQl
● CatalogUrlRewriteGraphQl
● CmsGraphQl
● CmsUrlRewriteGraphQl
● ConfigurableProductGraphQl
● CustomerGraphQl
● DownloadableGraphQl
● EavGraphQl
● GroupedProductGraphQl
● QuoteGraphQl
● StoreGraphQl
● SwatchesGraphQl
● TaxGraphQl
● ThemeGraphQl
● UrlRewriteGraphQl
● WeeeGraphQl
GraphQl Tool
● GraphiQL is an in-browser tool for write and testing GraphQl queries.
● For Google Chrome, ChromeiQL extension is supported, GraphQl Query. Others are Altair GraphQl
addon used in both Firefox as well as Chrome.
Type System
GraphQl is a strongly typed language. Type System defines various data types that can be used in a
GraphQl application. The type system helps to define the schema, which is a contract between client and
server. The commonly used GraphQl data types are as follows −
S.No. Type Description
1 Scalar Stores a single value
2 Object Shows what kind of object can be fetched
3 Query Entry point type to other specific types
4 Mutation Entry point for data manipulation
5 Enum Useful in a situation where we need the user to pick from a prescribed list of options.
Scalar Type
Scalar types are primitive data types that can store only a single value. The default scalar types that
GraphQl offers are −
● Int − Signed 32-bit Integer
● Float − Signed double precision floating point value
● String − UTF - 8-character sequence
● Boolean − True or false
● ID − A unique identifier, often used as a unique identifier to fetch an object or as the key for a
cache.
The syntax for defining a scalar type is as follows − field: data_type
type user{
Id: ID! # the “!” means required
firstname: string
lastname: string
email: string
}
Object Type
● The object type is the most common type used in a schema and represents a group of fields.
● The most basic components of a GraphQl schema are object types, which just represent a kind of
object you can fetch from your service, and what fields it has.
--Define an object type--
type Student {
stud_id:ID
firstname: String
age: Int
score:Float
}
--Defining a GraphQL schema--
type Query
{
stud_details:[Student]
}
Query Type
● A GraphQl query is used to fetch data. It is like requesting a resource in REST-based APIs. To keep
it simple, the Query type is the request sent from a client application to the GraphQl server.
● GraphQl uses the Schema Definition Language (SDL) to define a Query. Query type is one of the
many root-level types in GraphQl.
type Query {
human(id: ID!): Human
}
type Human {
name: String
appearsIn: [Episode]
starships: [Starship]
}
enum Episode {
X
Y
}
type Starship {
name: String
}
{
human(id: 1002) {
name
appearsIn
starships {
name
}
}
}
Mutation
● Mutations are operations sent to the server to create, update
or delete data.
● Mutation is one of the root-level data-types in GraphQl.
● Mutation queries modify data in the data store and returns a
value.
● A mutation contains the following elements:
● The keyword mutation
● An operation name for your local implementation.
● The mutation name
● The input object or attributes. Most mutations require an
input object that contains data or individual attributes for
the Magento server to process.
● The output object, which specifies which data the
mutation returns.
mutation {
createCustomer(
input: {
firstname: "XYZ"
lastname: "XYZ"
email: "xyz@example.com"
password: "xyzxyz@123"
is_subscribed: true
}
) {
customer {
firstname
lastname
email
is_subscribed
}
}
}
keyword
Enum
An Enum is similar to a scalar type. Enums are useful in a situation where the value for a field must be
from a prescribed list of options.
The syntax for defining an Enum type is −
type enum_name{
value1
value2
}
type Days_of_Week{
SUNDAY
MONDAY
TUESDAY
WEDNESDAY
THURSDAY
FRIDAY
SATURDAY
}
Schema Definition Language
GraphQL has its own type system that’s used to define the schema of an API. The syntax for writing
schemas is called Schema definition language (SDL).
type Person {
name: String!
age: Int!
}
type Person {
name: String!
age: Int!
posts: [Post!]!
}
type Post {
title: String!
}
type Post {
title: String!
author: Person!
}
Adding a relation
Defining simple types
Subscriptions
● In addition to fetching data using queries and modifying data using mutations, the GraphQL
supports a third operation type, called subscriptions.
● GraphQL subscriptions are a way to push data from the server to the clients that select to listen to real
time messages from the server.
● Subscriptions are similar to queries in that they specify a set of fields to be delivered to the client, but
instead of immediately returning a single answer, a result is sent every time a particular event happens
on the server.
type Subscription {
commentAdded(fullName: String!): Comment
}
Module structure
A GraphQL module’s schema.graphqls file defines how the attributes defined in the module can be used in GraphQL
queries and mutations.
The <module_name>/etc/schema.graphqls file:
● Defines the structure of queries and mutations.
● Determines which attributes can be used for input and output in GraphQL queries and mutations. Requests and
responses contain separate lists of valid attributes.
● Points to the resolvers that verify and process the input data and response.
● Serves as the source for displaying the schema in a GraphQL browser.
● Defines which objects are cached.
Resolver
● A resolver performs GraphQL request processing.
● It is responsible for:
– constructing a query
– fetching data
– performing any calculations
– transforming the fetched and calculated data into a GraphQL array format
– finally, it returns the query results for rendering
Thank You !!
GraphQl Introduction

Contenu connexe

Tendances

Getting Started with GraphQL && PHP
Getting Started with GraphQL && PHPGetting Started with GraphQL && PHP
Getting Started with GraphQL && PHPAndrew Rota
 
DGraph: Introduction To Basics & Quick Start W/Ratel
DGraph: Introduction To Basics & Quick Start W/RatelDGraph: Introduction To Basics & Quick Start W/Ratel
DGraph: Introduction To Basics & Quick Start W/RatelKnoldus Inc.
 
Introduction to DGraph - A Graph Database
Introduction to DGraph - A Graph DatabaseIntroduction to DGraph - A Graph Database
Introduction to DGraph - A Graph DatabaseKnoldus Inc.
 
JSONB Tricks: Operators, Indexes, and When (Not) to Use It | PostgresOpen 201...
JSONB Tricks: Operators, Indexes, and When (Not) to Use It | PostgresOpen 201...JSONB Tricks: Operators, Indexes, and When (Not) to Use It | PostgresOpen 201...
JSONB Tricks: Operators, Indexes, and When (Not) to Use It | PostgresOpen 201...Citus Data
 
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 serverPavel Chertorogov
 
GraphQL & DGraph with Go
GraphQL & DGraph with GoGraphQL & DGraph with Go
GraphQL & DGraph with GoJames Tan
 
Performant APIs with GraphQL and PHP (Dutch PHP 2019)
Performant APIs with GraphQL and PHP (Dutch PHP 2019)Performant APIs with GraphQL and PHP (Dutch PHP 2019)
Performant APIs with GraphQL and PHP (Dutch PHP 2019)Andrew Rota
 
Apollo Server IV
Apollo Server IVApollo Server IV
Apollo Server IVNodeXperts
 
Apollo server II
Apollo server IIApollo server II
Apollo server IINodeXperts
 
GraphQL and its schema as a universal layer for database access
GraphQL and its schema as a universal layer for database accessGraphQL and its schema as a universal layer for database access
GraphQL and its schema as a universal layer for database accessConnected Data World
 
SHACL-based data life cycle management
SHACL-based data life cycle managementSHACL-based data life cycle management
SHACL-based data life cycle managementConnected Data World
 
Best Practices for Building Open Source Data Layers
Best Practices for Building Open Source Data LayersBest Practices for Building Open Source Data Layers
Best Practices for Building Open Source Data LayersIBMCompose
 
GraphGen: Conducting Graph Analytics over Relational Databases
GraphGen: Conducting Graph Analytics over Relational DatabasesGraphGen: Conducting Graph Analytics over Relational Databases
GraphGen: Conducting Graph Analytics over Relational DatabasesKonstantinos Xirogiannopoulos
 
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)Ayla Khan
 

Tendances (20)

Getting Started with GraphQL && PHP
Getting Started with GraphQL && PHPGetting Started with GraphQL && PHP
Getting Started with GraphQL && PHP
 
DGraph: Introduction To Basics & Quick Start W/Ratel
DGraph: Introduction To Basics & Quick Start W/RatelDGraph: Introduction To Basics & Quick Start W/Ratel
DGraph: Introduction To Basics & Quick Start W/Ratel
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
Introduction to DGraph - A Graph Database
Introduction to DGraph - A Graph DatabaseIntroduction to DGraph - A Graph Database
Introduction to DGraph - A Graph Database
 
JSONB Tricks: Operators, Indexes, and When (Not) to Use It | PostgresOpen 201...
JSONB Tricks: Operators, Indexes, and When (Not) to Use It | PostgresOpen 201...JSONB Tricks: Operators, Indexes, and When (Not) to Use It | PostgresOpen 201...
JSONB Tricks: Operators, Indexes, and When (Not) to Use It | PostgresOpen 201...
 
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
 
Linq
LinqLinq
Linq
 
GraphQL & DGraph with Go
GraphQL & DGraph with GoGraphQL & DGraph with Go
GraphQL & DGraph with Go
 
Linq to sql
Linq to sqlLinq to sql
Linq to sql
 
Performant APIs with GraphQL and PHP (Dutch PHP 2019)
Performant APIs with GraphQL and PHP (Dutch PHP 2019)Performant APIs with GraphQL and PHP (Dutch PHP 2019)
Performant APIs with GraphQL and PHP (Dutch PHP 2019)
 
Apollo Server IV
Apollo Server IVApollo Server IV
Apollo Server IV
 
Apollo server II
Apollo server IIApollo server II
Apollo server II
 
Intro to GraphQL
 Intro to GraphQL Intro to GraphQL
Intro to GraphQL
 
GraphQL and its schema as a universal layer for database access
GraphQL and its schema as a universal layer for database accessGraphQL and its schema as a universal layer for database access
GraphQL and its schema as a universal layer for database access
 
SHACL-based data life cycle management
SHACL-based data life cycle managementSHACL-based data life cycle management
SHACL-based data life cycle management
 
Best Practices for Building Open Source Data Layers
Best Practices for Building Open Source Data LayersBest Practices for Building Open Source Data Layers
Best Practices for Building Open Source Data Layers
 
GraphGen: Conducting Graph Analytics over Relational Databases
GraphGen: Conducting Graph Analytics over Relational DatabasesGraphGen: Conducting Graph Analytics over Relational Databases
GraphGen: Conducting Graph Analytics over Relational Databases
 
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
 
LINQ
LINQLINQ
LINQ
 
GraphQL & Ratpack
GraphQL & RatpackGraphQL & Ratpack
GraphQL & Ratpack
 

Similaire à GraphQl Introduction

Introduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptxIntroduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptxKnoldus Inc.
 
Modern APIs with GraphQL
Modern APIs with GraphQLModern APIs with GraphQL
Modern APIs with GraphQLTaikai
 
Graphql Overview By Chirag Dodia
Graphql Overview By Chirag DodiaGraphql Overview By Chirag Dodia
Graphql Overview By Chirag Dodiavijaygolani
 
GraphQL API Gateway and microservices
GraphQL API Gateway and microservicesGraphQL API Gateway and microservices
GraphQL API Gateway and microservicesMohammed Shaban
 
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) ExtensionSimplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) ExtensionVMware Tanzu
 
Exposing GraphQLs as Managed APIs
Exposing GraphQLs as Managed APIsExposing GraphQLs as Managed APIs
Exposing GraphQLs as Managed APIsWSO2
 
Getting Started with Spring for GraphQL
Getting Started with Spring for GraphQLGetting Started with Spring for GraphQL
Getting Started with Spring for GraphQLVMware Tanzu
 
How to provide a GraphQL API - I want it that way
How to provide a GraphQL API - I want it that wayHow to provide a GraphQL API - I want it that way
How to provide a GraphQL API - I want it that wayQAware GmbH
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQLRodrigo Prates
 
DevNexus 2019: GraphQL From Beginner to Expert in 60 Minutes
DevNexus 2019: GraphQL From Beginner to Expert in 60 MinutesDevNexus 2019: GraphQL From Beginner to Expert in 60 Minutes
DevNexus 2019: GraphQL From Beginner to Expert in 60 MinutesYoel Spotts
 
Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)Seven Peaks Speaks
 
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScriptMongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScriptMongoDB
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQLKnoldus Inc.
 
CONDG April 23 2020 - Baskar Rao - GraphQL
CONDG April 23 2020 - Baskar Rao - GraphQLCONDG April 23 2020 - Baskar Rao - GraphQL
CONDG April 23 2020 - Baskar Rao - GraphQLMatthew Groves
 
Let's start GraphQL: structure, behavior, and architecture
Let's start GraphQL: structure, behavior, and architectureLet's start GraphQL: structure, behavior, and architecture
Let's start GraphQL: structure, behavior, and architectureAndrii Gakhov
 
GraphQL Advanced Concepts A Comprehensive Guide.docx
GraphQL Advanced Concepts A Comprehensive Guide.docxGraphQL Advanced Concepts A Comprehensive Guide.docx
GraphQL Advanced Concepts A Comprehensive Guide.docxssuser5583681
 
GraphQL in an Age of REST
GraphQL in an Age of RESTGraphQL in an Age of REST
GraphQL in an Age of RESTYos Riady
 

Similaire à GraphQl Introduction (20)

Introduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptxIntroduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptx
 
Modern APIs with GraphQL
Modern APIs with GraphQLModern APIs with GraphQL
Modern APIs with GraphQL
 
Graphql Overview By Chirag Dodia
Graphql Overview By Chirag DodiaGraphql Overview By Chirag Dodia
Graphql Overview By Chirag Dodia
 
GraphQL API Gateway and microservices
GraphQL API Gateway and microservicesGraphQL API Gateway and microservices
GraphQL API Gateway and microservices
 
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) ExtensionSimplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
 
Exposing GraphQLs as Managed APIs
Exposing GraphQLs as Managed APIsExposing GraphQLs as Managed APIs
Exposing GraphQLs as Managed APIs
 
GraphQL + relay
GraphQL + relayGraphQL + relay
GraphQL + relay
 
Getting Started with Spring for GraphQL
Getting Started with Spring for GraphQLGetting Started with Spring for GraphQL
Getting Started with Spring for GraphQL
 
How to provide a GraphQL API - I want it that way
How to provide a GraphQL API - I want it that wayHow to provide a GraphQL API - I want it that way
How to provide a GraphQL API - I want it that way
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
Attacking GraphQL
Attacking GraphQLAttacking GraphQL
Attacking GraphQL
 
DevNexus 2019: GraphQL From Beginner to Expert in 60 Minutes
DevNexus 2019: GraphQL From Beginner to Expert in 60 MinutesDevNexus 2019: GraphQL From Beginner to Expert in 60 Minutes
DevNexus 2019: GraphQL From Beginner to Expert in 60 Minutes
 
Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
Graph ql vs rest api - Seven Peaks Software (Node.JS Meetup 18 nov 2021)
 
Graphql usage
Graphql usageGraphql usage
Graphql usage
 
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScriptMongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
CONDG April 23 2020 - Baskar Rao - GraphQL
CONDG April 23 2020 - Baskar Rao - GraphQLCONDG April 23 2020 - Baskar Rao - GraphQL
CONDG April 23 2020 - Baskar Rao - GraphQL
 
Let's start GraphQL: structure, behavior, and architecture
Let's start GraphQL: structure, behavior, and architectureLet's start GraphQL: structure, behavior, and architecture
Let's start GraphQL: structure, behavior, and architecture
 
GraphQL Advanced Concepts A Comprehensive Guide.docx
GraphQL Advanced Concepts A Comprehensive Guide.docxGraphQL Advanced Concepts A Comprehensive Guide.docx
GraphQL Advanced Concepts A Comprehensive Guide.docx
 
GraphQL in an Age of REST
GraphQL in an Age of RESTGraphQL in an Age of REST
GraphQL in an Age of REST
 

Dernier

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Dernier (20)

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

GraphQl Introduction

  • 1. GraphQl Name: Abhay Kumar Agrawal Date: 18 March,2020
  • 2. Topics 1. Introduction About GraphQl 2. API vs GraphQl 3. Magento2 module 4. GraphQl Tool 5. Type System 6. The Schema Definition Language(SDF) 7. Subscriptions 8. Module structure 9. Resolver
  • 3. About GraphQl ● GraphQl is an open source server side technology which was developed by facebook to optimize RESTFUL API calls. ● It is an execution engine and a data query language. ● GraphQl structures data in the form of a graph with its powerful query syntax for traversing, retrieving and modifying data. ● The request made by a client to the GraphQl server is called a query. ● GraphQl is a query language for APIs - not a databases.
  • 4. REST API vs GraphQl GraphQl ● Single endpoint ● Client decide how data is returned ● Schema based ● Performance fast ● Development speed rapid ● Operations- Query,Mutations,subscriptions ● Specific data with a single API calls ● Community growing REST API ● Lots of end point ● Server side decide how data is returned ● There is no schema for the data ● Multiple network calls take up more time ● Development speed slower ● Operations- CRUD ● Fixed data with multiple API calls ● Community large GraphQl REST API
  • 5. Magento2 module There are many core module used GraphQl query language in Magento 2.3 version. Below is the list of GraphQl Modules. GraphQl is the parent Module for all the GraphQl related module, provides the framework for the application to expose GraphQl compliant web services. We can check it under folder_name/vendor/Magento/GraphQl path. ● BundleGraphQl ● CatalogGraphQl ● CatalogInventoryGraphQl ● CatalogUrlRewriteGraphQl ● CmsGraphQl ● CmsUrlRewriteGraphQl ● ConfigurableProductGraphQl ● CustomerGraphQl ● DownloadableGraphQl ● EavGraphQl ● GroupedProductGraphQl ● QuoteGraphQl ● StoreGraphQl ● SwatchesGraphQl ● TaxGraphQl ● ThemeGraphQl ● UrlRewriteGraphQl ● WeeeGraphQl
  • 6. GraphQl Tool ● GraphiQL is an in-browser tool for write and testing GraphQl queries. ● For Google Chrome, ChromeiQL extension is supported, GraphQl Query. Others are Altair GraphQl addon used in both Firefox as well as Chrome.
  • 7. Type System GraphQl is a strongly typed language. Type System defines various data types that can be used in a GraphQl application. The type system helps to define the schema, which is a contract between client and server. The commonly used GraphQl data types are as follows − S.No. Type Description 1 Scalar Stores a single value 2 Object Shows what kind of object can be fetched 3 Query Entry point type to other specific types 4 Mutation Entry point for data manipulation 5 Enum Useful in a situation where we need the user to pick from a prescribed list of options.
  • 8. Scalar Type Scalar types are primitive data types that can store only a single value. The default scalar types that GraphQl offers are − ● Int − Signed 32-bit Integer ● Float − Signed double precision floating point value ● String − UTF - 8-character sequence ● Boolean − True or false ● ID − A unique identifier, often used as a unique identifier to fetch an object or as the key for a cache. The syntax for defining a scalar type is as follows − field: data_type type user{ Id: ID! # the “!” means required firstname: string lastname: string email: string }
  • 9. Object Type ● The object type is the most common type used in a schema and represents a group of fields. ● The most basic components of a GraphQl schema are object types, which just represent a kind of object you can fetch from your service, and what fields it has. --Define an object type-- type Student { stud_id:ID firstname: String age: Int score:Float } --Defining a GraphQL schema-- type Query { stud_details:[Student] }
  • 10. Query Type ● A GraphQl query is used to fetch data. It is like requesting a resource in REST-based APIs. To keep it simple, the Query type is the request sent from a client application to the GraphQl server. ● GraphQl uses the Schema Definition Language (SDL) to define a Query. Query type is one of the many root-level types in GraphQl. type Query { human(id: ID!): Human } type Human { name: String appearsIn: [Episode] starships: [Starship] } enum Episode { X Y } type Starship { name: String } { human(id: 1002) { name appearsIn starships { name } } }
  • 11. Mutation ● Mutations are operations sent to the server to create, update or delete data. ● Mutation is one of the root-level data-types in GraphQl. ● Mutation queries modify data in the data store and returns a value. ● A mutation contains the following elements: ● The keyword mutation ● An operation name for your local implementation. ● The mutation name ● The input object or attributes. Most mutations require an input object that contains data or individual attributes for the Magento server to process. ● The output object, which specifies which data the mutation returns. mutation { createCustomer( input: { firstname: "XYZ" lastname: "XYZ" email: "xyz@example.com" password: "xyzxyz@123" is_subscribed: true } ) { customer { firstname lastname email is_subscribed } } } keyword
  • 12. Enum An Enum is similar to a scalar type. Enums are useful in a situation where the value for a field must be from a prescribed list of options. The syntax for defining an Enum type is − type enum_name{ value1 value2 } type Days_of_Week{ SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY }
  • 13. Schema Definition Language GraphQL has its own type system that’s used to define the schema of an API. The syntax for writing schemas is called Schema definition language (SDL). type Person { name: String! age: Int! } type Person { name: String! age: Int! posts: [Post!]! } type Post { title: String! } type Post { title: String! author: Person! } Adding a relation Defining simple types
  • 14. Subscriptions ● In addition to fetching data using queries and modifying data using mutations, the GraphQL supports a third operation type, called subscriptions. ● GraphQL subscriptions are a way to push data from the server to the clients that select to listen to real time messages from the server. ● Subscriptions are similar to queries in that they specify a set of fields to be delivered to the client, but instead of immediately returning a single answer, a result is sent every time a particular event happens on the server. type Subscription { commentAdded(fullName: String!): Comment }
  • 15. Module structure A GraphQL module’s schema.graphqls file defines how the attributes defined in the module can be used in GraphQL queries and mutations. The <module_name>/etc/schema.graphqls file: ● Defines the structure of queries and mutations. ● Determines which attributes can be used for input and output in GraphQL queries and mutations. Requests and responses contain separate lists of valid attributes. ● Points to the resolvers that verify and process the input data and response. ● Serves as the source for displaying the schema in a GraphQL browser. ● Defines which objects are cached.
  • 16. Resolver ● A resolver performs GraphQL request processing. ● It is responsible for: – constructing a query – fetching data – performing any calculations – transforming the fetched and calculated data into a GraphQL array format – finally, it returns the query results for rendering