SlideShare a Scribd company logo
1 of 21
Vibhor Grover
DIVING INTO
GRAPHQL ALONG
WITH REACT &
WHAT IS GRAPHQL ?
GraphQL is the new frontier in APIs (Application Programming Interfaces) design, and in how we build and
consume them.
It’s a query language, and a set of server-side runtimes (implemented in various backend languages) for
executing queries. It’s not tied to a specific technology, but you can implement it in any language.
It is a methodology that directly competes with REST (REpresentational State Transfer) APIs, much like
REST competed with SOAP at first.
GraphQL was developed at Facebook, like many of the technologies that are shaking the JavaScript world
lately, like React and React Native, and it was publicly launched in 2015 - although Facebook used it
internally for a few years before.
GRAPHQL - CORE PRINCIPLE
• GraphQL exposes a single endpoint.
• You send a query to that endpoint by using a special Query Language syntax. That query is just a string.
• The server responds to a query by providing a JSON object.
• The Schema Definition Language (SDL)
• 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).
• Here is an example how we can use the SDL to define a simple type called Person
• This type has two fields, they’re called name and age and are respectively of type String and Int. The !
following the type means that this field is required.
CONTINUED..
Example of a query based on schema definition language
The allPersons field in this query is called the root field of the query. Everything that follows the root
field, is called the payload of the query. The only field that’s specified in this query’s payload is name.
This query would return a list of all persons currently stored in the database. Here’s an example
response:
WHY GRAPHQL ? (WHEN WE ALREADY
HAVE REST)
•While REST is built on top of an existing architecture, which in the most common scenarios is HTTP, GraphQL on the other hand is building its
own set of conventions. Which can be an advantage point or not, since REST benefits for free by caching on the HTTP layer.
A single endpoint
GraphQL has only one endpoint, where you send all your queries. With a REST approach, you create multiple endpoints and use
HTTP verbs to distinguish read actions (GET) and write actions (POST, PUT, DELETE). GraphQL does not use HTTP verbs to determine the
request type.
Tailored to your needs
With REST, you generally cannot choose what the server returns back to you, unless you have an API maintainer, otherwise,
The API will usually return you much more information than what you need, unless you control the API server as well, and you tailor your
responses for each different request.
Access nested data resources
GraphQL allows to generate a lot less network calls.
Let’s do an example: you need to access the names of the friends of a person. If your REST API exposes a
/person endpoint, which returns a person object with a list of friends, you generally first get the person
information by doing GET /person/1 which contains a list of ID of its friends.
Unless the list of friends of a person already contains the friend name, with 100 friends you’d need to do 101
HTTP requests to the /person endpoint, which is a huge time cost, and also a resource intensive operation.
With GraphQL, you need only one request, which asks for the names of the friends of a person.
CONTINUED..
WHICH ONE IS BETTER ..?
• GraphQL is a perfect fit when you need to expose complex data representations, and when clients might
need only a subset of the data, or they regularly perform nested queries to get the data they need.
• As with programming languages, there is no single winner, it all depends on your needs
TEXT
THE BIG PICTURE (ARCHITECTURE)
A standard greenfield architecture with one GraphQL Server that connects to a single database.
Client
GraphQl Server
Database
QUERIES..
▸It is a way of fetching data at the client side from the graphQl server by
specifying the fields in the query to fetch the specific data.
MUTATIONS..
• GraphQL mutations are types of GraphQL queries that may result in the
state of your backend "mutating" or changing, just like
typical 'POST', 'PUT', 'PATCH', 'DELETE' APIs.
SUBSCRIPTIONS
• Subscriptions are like GraphQL queries but instead of returning data in
one read, you get data pushed from the server.
• This is useful for your app to subscribe to "events" or "live results" from
the backend, but while allowing you to control the "shape" of the event
from your app.
• subscriptions are great because they allow you to build great
experiences without having to deal with websocket code!
HOW DOES SUBSCRIPTIONS WORK ..?
• GraphQL queries and mutations are strings sent to a POST endpoint. What
is a GraphQL subscription? That can't happen over a POST endpoint,
because a simple HTTP endpoint would just return the response and the
connection would close.
• A GraphQL subscription is a subscription query string sent to a websocket
endpoint. And whenever data changes on the backend, new data is
pushed over websockets from the server to the client.
WHAT IS GRAPHQL - CLIENT ?
consider some “infrastructure” features that you probably want to have in your
app:
• directly sending queries and mutations without constructing HTTP requests
• view-layer integration
• caching
• validating and optimizing queries based on the schema
But GraphQL provides the ability to abstract away a lot of the manual
work you’d usually have to do during that process and lets you focus
on the real important parts of your app!
CONTINUED..
There are two major GraphQL clients available at the moment.
•The first one is Apollo Client, which is a community-driven effort to build a powerful and flexible
GraphQL client for all major development platforms.
•The second one is called Relay and it is Facebook’s homegrown GraphQL client that heavily
optimizes for performance and is only available on the web.
A major benefit of GraphQL is that it allows you to fetch and update data in a declarative manner. Put
differently, we climb up one step higher on the API abstraction ladder and don’t have to deal with low-
level networking tasks ourselves anymore.
When you previously used plain HTTP (like fetch in Javascript or NSURLSession on iOS) to load data
from an API, all you need to do with GraphQL is write a query where you declare your data
requirements and let the system take care of sending the request and handling the response for you.
This is precisely what a GraphQL client will do.
WHAT IS REACT - GRAPHQL - APOLLO -
CLIENT• React renders, updates, and destroys components of the user interface
• Apollo defines the ways we fetch and send data and provides interfaces to store it
• GraphQL is the query language for fetching and updating our data
• To be precise, you should use a GraphQL client for tasks that are repetitive and agnostic to the app you’re building. For example,
being able to send queries and mutations without having to worry about lower-level networking details or maintaining a local cache.
This is what GraphQ-Apollo-Client is created for.
GRAPHQL-APOLLO-CLIENT OVERVIEW
Here’s an overview of the packages you would install:
• apollo-boost offers some convenience by bundling several packages you need when working with Apollo Client:
• apollo-client: Where all the magic happens
• apollo-cache-inmemory: Our recommended cache
• apollo-link-http: An Apollo Link for remote data fetching
• apollo-link-error: An Apollo Link for error handling
• apollo-link-state: An Apollo Link for local state management
• graphql-tag: Exports the gql function for your queries & mutations
• react-apollo contains the bindings to use Apollo Client with React.
• graphql contains Facebook’s reference implementation of GraphQL - Apollo Client uses some of its functionality as
well.
HOW TO GET STARTED ..
Frontend
Creating the app
•First, you are going to create the React project! As mentioned in the beginning, you’ll use create-
react-app for that, In any terminal, type npm create-react-app application-react-apollo
This will create a new directory called application-react-apollo that has all the basic configuration
setup.
Navigate to directory and start the application with npm start
This will open a browser and navigate to http://localhost:3000 where the app
is running. If everything went well, you will see a react welcome page on the
screen.
CONTINUED..
▸Your project structure should look like
• Prepare styling
This tutorial is about the concepts of GraphQL and how you can use it from within a React application, so
we want to spend the least time possible on styling. To reduce the usage of CSS in this project, you can
use the Tachyons library which provides a number of CSS classes.
• Install Apollo Client
Next, you need to pull in the functionality of Apollo Client (and its React bindings) which comes in
several packages:
▸In terminal, type npm install apollo-
boost react-apollo graphql
•Configure ApolloClient
Apollo abstracts away all lower-level networking
logic and provides a nice interface to the
GraphQL server. In contrast to working with
REST APIs, you don’t have to deal with
constructing your own HTTP requests any
more - instead you can simply write queries
and mutations and send them using
an ApolloClient instance.
The first thing you have to do when using
Apollo is configure
your ApolloClient instance. It needs to know
the endpoint of your GraphQL API so it can
deal with the network connections.
That’s it, you’re all set for the frontend to to start
for loading some data into your app! 😎
/application-react-graphql/src/index.js
CONCLUSION
We’ve just scratched the surface of what the abstractions and capabilities of
GraphQL can provide.
TEXT
Thank you

More Related Content

What's hot

REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQLSquareboat
 
Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)Rafael Wilber Kerr
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQLvaluebound
 
Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL Josh Price
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQLRodrigo Prates
 
GraphQL vs REST
GraphQL vs RESTGraphQL vs REST
GraphQL vs RESTGreeceJS
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQLTomasz Bak
 
Introduction to graphQL
Introduction to graphQLIntroduction to graphQL
Introduction to graphQLMuhilvarnan V
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & DevelopmentAshok Pundit
 
REST vs. GraphQL: Critical Look
REST vs. GraphQL: Critical LookREST vs. GraphQL: Critical Look
REST vs. GraphQL: Critical LookNordic APIs
 
Getting Started with Spring for GraphQL
Getting Started with Spring for GraphQLGetting Started with Spring for GraphQL
Getting Started with Spring for GraphQLVMware Tanzu
 
Introduction to GraphQL: Mobile Week SF
Introduction to GraphQL: Mobile Week SFIntroduction to GraphQL: Mobile Week SF
Introduction to GraphQL: Mobile Week SFAmazon Web Services
 
Introduction to Swagger
Introduction to SwaggerIntroduction to Swagger
Introduction to SwaggerKnoldus Inc.
 

What's hot (20)

REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQL
 
Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQL
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
GraphQL Fundamentals
GraphQL FundamentalsGraphQL Fundamentals
GraphQL Fundamentals
 
Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
React & GraphQL
React & GraphQLReact & GraphQL
React & GraphQL
 
GraphQL
GraphQLGraphQL
GraphQL
 
GraphQL vs REST
GraphQL vs RESTGraphQL vs REST
GraphQL vs REST
 
Intro GraphQL
Intro GraphQLIntro GraphQL
Intro GraphQL
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQL
 
Introduction to graphQL
Introduction to graphQLIntroduction to graphQL
Introduction to graphQL
 
Graphql
GraphqlGraphql
Graphql
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
 
REST vs. GraphQL: Critical Look
REST vs. GraphQL: Critical LookREST vs. GraphQL: Critical Look
REST vs. GraphQL: Critical Look
 
Spring GraphQL
Spring GraphQLSpring GraphQL
Spring GraphQL
 
Getting Started with Spring for GraphQL
Getting Started with Spring for GraphQLGetting Started with Spring for GraphQL
Getting Started with Spring for GraphQL
 
Introduction to GraphQL: Mobile Week SF
Introduction to GraphQL: Mobile Week SFIntroduction to GraphQL: Mobile Week SF
Introduction to GraphQL: Mobile Week SF
 
Introduction to Swagger
Introduction to SwaggerIntroduction to Swagger
Introduction to Swagger
 

Similar to Graphql presentation

GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018Sashko Stubailo
 
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceLuca Mattia Ferrari
 
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
 
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
 
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...apidays
 
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything togetherSashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything togetherReact Conf Brasil
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL StackSashko Stubailo
 
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
 
Create GraphQL server with apolloJS
Create GraphQL server with apolloJSCreate GraphQL server with apolloJS
Create GraphQL server with apolloJSJonathan Jalouzot
 
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architectureSashko Stubailo
 
GraphQL API Gateway and microservices
GraphQL API Gateway and microservicesGraphQL API Gateway and microservices
GraphQL API Gateway and microservicesMohammed Shaban
 
Modern APIs with GraphQL
Modern APIs with GraphQLModern APIs with GraphQL
Modern APIs with GraphQLTaikai
 
Implementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPCImplementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPCTim Burks
 
GraphQL research summary
GraphQL research summaryGraphQL research summary
GraphQL research summaryObjectivity
 
GraphQL-ify your APIs - Devoxx UK 2021
 GraphQL-ify your APIs - Devoxx UK 2021 GraphQL-ify your APIs - Devoxx UK 2021
GraphQL-ify your APIs - Devoxx UK 2021Soham Dasgupta
 
Tutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHPTutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHPAndrew Rota
 
Scaling your GraphQL applications with Dgraph
Scaling your GraphQL applications with DgraphScaling your GraphQL applications with Dgraph
Scaling your GraphQL applications with DgraphKarthic Rao
 

Similar to Graphql presentation (20)

GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018
 
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performance
 
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
 
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.pptx
GraphQL.pptxGraphQL.pptx
GraphQL.pptx
 
GraphQL.pptx
GraphQL.pptxGraphQL.pptx
GraphQL.pptx
 
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
 
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything togetherSashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
 
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
 
Create GraphQL server with apolloJS
Create GraphQL server with apolloJSCreate GraphQL server with apolloJS
Create GraphQL server with apolloJS
 
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architecture
 
GraphQL API Gateway and microservices
GraphQL API Gateway and microservicesGraphQL API Gateway and microservices
GraphQL API Gateway and microservices
 
Modern APIs with GraphQL
Modern APIs with GraphQLModern APIs with GraphQL
Modern APIs with GraphQL
 
Implementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPCImplementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPC
 
GraphQL.net
GraphQL.netGraphQL.net
GraphQL.net
 
GraphQL research summary
GraphQL research summaryGraphQL research summary
GraphQL research summary
 
GraphQL-ify your APIs - Devoxx UK 2021
 GraphQL-ify your APIs - Devoxx UK 2021 GraphQL-ify your APIs - Devoxx UK 2021
GraphQL-ify your APIs - Devoxx UK 2021
 
Tutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHPTutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHP
 
Scaling your GraphQL applications with Dgraph
Scaling your GraphQL applications with DgraphScaling your GraphQL applications with Dgraph
Scaling your GraphQL applications with Dgraph
 

Recently uploaded

Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 

Recently uploaded (20)

Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 

Graphql presentation

  • 2. WHAT IS GRAPHQL ? GraphQL is the new frontier in APIs (Application Programming Interfaces) design, and in how we build and consume them. It’s a query language, and a set of server-side runtimes (implemented in various backend languages) for executing queries. It’s not tied to a specific technology, but you can implement it in any language. It is a methodology that directly competes with REST (REpresentational State Transfer) APIs, much like REST competed with SOAP at first. GraphQL was developed at Facebook, like many of the technologies that are shaking the JavaScript world lately, like React and React Native, and it was publicly launched in 2015 - although Facebook used it internally for a few years before.
  • 3. GRAPHQL - CORE PRINCIPLE • GraphQL exposes a single endpoint. • You send a query to that endpoint by using a special Query Language syntax. That query is just a string. • The server responds to a query by providing a JSON object. • The Schema Definition Language (SDL) • 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). • Here is an example how we can use the SDL to define a simple type called Person • This type has two fields, they’re called name and age and are respectively of type String and Int. The ! following the type means that this field is required.
  • 4. CONTINUED.. Example of a query based on schema definition language The allPersons field in this query is called the root field of the query. Everything that follows the root field, is called the payload of the query. The only field that’s specified in this query’s payload is name. This query would return a list of all persons currently stored in the database. Here’s an example response:
  • 5. WHY GRAPHQL ? (WHEN WE ALREADY HAVE REST) •While REST is built on top of an existing architecture, which in the most common scenarios is HTTP, GraphQL on the other hand is building its own set of conventions. Which can be an advantage point or not, since REST benefits for free by caching on the HTTP layer. A single endpoint GraphQL has only one endpoint, where you send all your queries. With a REST approach, you create multiple endpoints and use HTTP verbs to distinguish read actions (GET) and write actions (POST, PUT, DELETE). GraphQL does not use HTTP verbs to determine the request type. Tailored to your needs With REST, you generally cannot choose what the server returns back to you, unless you have an API maintainer, otherwise, The API will usually return you much more information than what you need, unless you control the API server as well, and you tailor your responses for each different request.
  • 6. Access nested data resources GraphQL allows to generate a lot less network calls. Let’s do an example: you need to access the names of the friends of a person. If your REST API exposes a /person endpoint, which returns a person object with a list of friends, you generally first get the person information by doing GET /person/1 which contains a list of ID of its friends. Unless the list of friends of a person already contains the friend name, with 100 friends you’d need to do 101 HTTP requests to the /person endpoint, which is a huge time cost, and also a resource intensive operation. With GraphQL, you need only one request, which asks for the names of the friends of a person. CONTINUED..
  • 7. WHICH ONE IS BETTER ..? • GraphQL is a perfect fit when you need to expose complex data representations, and when clients might need only a subset of the data, or they regularly perform nested queries to get the data they need. • As with programming languages, there is no single winner, it all depends on your needs
  • 8. TEXT THE BIG PICTURE (ARCHITECTURE) A standard greenfield architecture with one GraphQL Server that connects to a single database. Client GraphQl Server Database
  • 9. QUERIES.. ▸It is a way of fetching data at the client side from the graphQl server by specifying the fields in the query to fetch the specific data.
  • 10. MUTATIONS.. • GraphQL mutations are types of GraphQL queries that may result in the state of your backend "mutating" or changing, just like typical 'POST', 'PUT', 'PATCH', 'DELETE' APIs.
  • 11. SUBSCRIPTIONS • Subscriptions are like GraphQL queries but instead of returning data in one read, you get data pushed from the server. • This is useful for your app to subscribe to "events" or "live results" from the backend, but while allowing you to control the "shape" of the event from your app. • subscriptions are great because they allow you to build great experiences without having to deal with websocket code!
  • 12. HOW DOES SUBSCRIPTIONS WORK ..? • GraphQL queries and mutations are strings sent to a POST endpoint. What is a GraphQL subscription? That can't happen over a POST endpoint, because a simple HTTP endpoint would just return the response and the connection would close. • A GraphQL subscription is a subscription query string sent to a websocket endpoint. And whenever data changes on the backend, new data is pushed over websockets from the server to the client.
  • 13. WHAT IS GRAPHQL - CLIENT ? consider some “infrastructure” features that you probably want to have in your app: • directly sending queries and mutations without constructing HTTP requests • view-layer integration • caching • validating and optimizing queries based on the schema But GraphQL provides the ability to abstract away a lot of the manual work you’d usually have to do during that process and lets you focus on the real important parts of your app!
  • 14. CONTINUED.. There are two major GraphQL clients available at the moment. •The first one is Apollo Client, which is a community-driven effort to build a powerful and flexible GraphQL client for all major development platforms. •The second one is called Relay and it is Facebook’s homegrown GraphQL client that heavily optimizes for performance and is only available on the web. A major benefit of GraphQL is that it allows you to fetch and update data in a declarative manner. Put differently, we climb up one step higher on the API abstraction ladder and don’t have to deal with low- level networking tasks ourselves anymore. When you previously used plain HTTP (like fetch in Javascript or NSURLSession on iOS) to load data from an API, all you need to do with GraphQL is write a query where you declare your data requirements and let the system take care of sending the request and handling the response for you. This is precisely what a GraphQL client will do.
  • 15. WHAT IS REACT - GRAPHQL - APOLLO - CLIENT• React renders, updates, and destroys components of the user interface • Apollo defines the ways we fetch and send data and provides interfaces to store it • GraphQL is the query language for fetching and updating our data • To be precise, you should use a GraphQL client for tasks that are repetitive and agnostic to the app you’re building. For example, being able to send queries and mutations without having to worry about lower-level networking details or maintaining a local cache. This is what GraphQ-Apollo-Client is created for.
  • 16. GRAPHQL-APOLLO-CLIENT OVERVIEW Here’s an overview of the packages you would install: • apollo-boost offers some convenience by bundling several packages you need when working with Apollo Client: • apollo-client: Where all the magic happens • apollo-cache-inmemory: Our recommended cache • apollo-link-http: An Apollo Link for remote data fetching • apollo-link-error: An Apollo Link for error handling • apollo-link-state: An Apollo Link for local state management • graphql-tag: Exports the gql function for your queries & mutations • react-apollo contains the bindings to use Apollo Client with React. • graphql contains Facebook’s reference implementation of GraphQL - Apollo Client uses some of its functionality as well.
  • 17. HOW TO GET STARTED .. Frontend Creating the app •First, you are going to create the React project! As mentioned in the beginning, you’ll use create- react-app for that, In any terminal, type npm create-react-app application-react-apollo This will create a new directory called application-react-apollo that has all the basic configuration setup. Navigate to directory and start the application with npm start This will open a browser and navigate to http://localhost:3000 where the app is running. If everything went well, you will see a react welcome page on the screen.
  • 18. CONTINUED.. ▸Your project structure should look like • Prepare styling This tutorial is about the concepts of GraphQL and how you can use it from within a React application, so we want to spend the least time possible on styling. To reduce the usage of CSS in this project, you can use the Tachyons library which provides a number of CSS classes. • Install Apollo Client Next, you need to pull in the functionality of Apollo Client (and its React bindings) which comes in several packages:
  • 19. ▸In terminal, type npm install apollo- boost react-apollo graphql •Configure ApolloClient Apollo abstracts away all lower-level networking logic and provides a nice interface to the GraphQL server. In contrast to working with REST APIs, you don’t have to deal with constructing your own HTTP requests any more - instead you can simply write queries and mutations and send them using an ApolloClient instance. The first thing you have to do when using Apollo is configure your ApolloClient instance. It needs to know the endpoint of your GraphQL API so it can deal with the network connections. That’s it, you’re all set for the frontend to to start for loading some data into your app! 😎 /application-react-graphql/src/index.js
  • 20. CONCLUSION We’ve just scratched the surface of what the abstractions and capabilities of GraphQL can provide.