SlideShare a Scribd company logo
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

More Related Content

What's hot

Getting Started with GraphQL && PHP
Getting Started with GraphQL && PHPGetting Started with GraphQL && PHP
Getting Started with GraphQL && PHP
Andrew 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/Ratel
Knoldus Inc.
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
Bhargav Anadkat
 
Introduction to DGraph - A Graph Database
Introduction to DGraph - A Graph DatabaseIntroduction to DGraph - A Graph Database
Introduction to DGraph - A Graph Database
Knoldus 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 server
Pavel Chertorogov
 
Linq
LinqLinq
Linq
samneang
 
GraphQL & DGraph with Go
GraphQL & DGraph with GoGraphQL & DGraph with Go
GraphQL & DGraph with Go
James Tan
 
Linq to sql
Linq to sqlLinq to sql
Linq to sql
Shivanand Arur
 
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 IV
NodeXperts
 
Apollo server II
Apollo server IIApollo server II
Apollo server II
NodeXperts
 
Intro to GraphQL
 Intro to GraphQL Intro to GraphQL
Intro to GraphQL
Rakuten Group, Inc.
 
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
Connected Data World
 
SHACL-based data life cycle management
SHACL-based data life cycle managementSHACL-based data life cycle management
SHACL-based data life cycle management
Connected 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 Layers
IBMCompose
 
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
Konstantinos 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
 
LINQ
LINQLINQ
GraphQL & Ratpack
GraphQL & RatpackGraphQL & Ratpack
GraphQL & Ratpack
Mario García
 

What's hot (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
 

Similar to GraphQl Introduction

Introduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptxIntroduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptx
Knoldus Inc.
 
GraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfGraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdf
Knoldus Inc.
 
Modern APIs with GraphQL
Modern APIs with GraphQLModern APIs with GraphQL
Modern APIs with GraphQL
Taikai
 
Graphql Overview By Chirag Dodia
Graphql Overview By Chirag DodiaGraphql Overview By Chirag Dodia
Graphql Overview By Chirag Dodia
vijaygolani
 
GraphQL API Gateway and microservices
GraphQL API Gateway and microservicesGraphQL API Gateway and microservices
GraphQL API Gateway and microservices
Mohammed 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) Extension
VMware Tanzu
 
Exposing GraphQLs as Managed APIs
Exposing GraphQLs as Managed APIsExposing GraphQLs as Managed APIs
Exposing GraphQLs as Managed APIs
WSO2
 
GraphQL + relay
GraphQL + relayGraphQL + relay
GraphQL + relay
Cédric GILLET
 
Getting Started with Spring for GraphQL
Getting Started with Spring for GraphQLGetting Started with Spring for GraphQL
Getting Started with Spring for GraphQL
VMware 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 way
QAware GmbH
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
Rodrigo Prates
 
Attacking GraphQL
Attacking GraphQLAttacking GraphQL
Attacking GraphQL
KavishaSheth1
 
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
Yoel 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
 
Graphql usage
Graphql usageGraphql usage
Graphql usage
Valentin Buryakov
 
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
MongoDB
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
Knoldus 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 - GraphQL
Matthew 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 architecture
Andrii 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.docx
ssuser5583681
 

Similar to GraphQl Introduction (20)

Introduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptxIntroduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptx
 
GraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfGraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdf
 
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
 

Recently uploaded

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 

Recently uploaded (20)

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 

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