SlideShare une entreprise Scribd logo
1  sur  37
Télécharger pour lire hors ligne
GRAPHQL
INDYJS MEETUP APRIL 2016
MEMES…
REST
REST IS AN ACRONYM FOR ?
REST
REST HISTORY
▸ The term representational state transfer was introduced and
defined in 2000 by Roy Fielding
▸ The defacto standard for communicating with a server
▸ Defines simple operations: GET, PUT, POST, DELETE
▸ A query operation (like GET) promises no side-effects (e.g.
changes) in data being queried. Commands (like PUT/DELETE)
answer no questions about the data, but compute changes
applied to the data (e.g. UPDATE or INSERT to use database
terms).
REST
REST ISSUES
▸ Many endpoints - proliferation of ad hoc endpoints
▸ Many round trips between the client and server
▸ First fetch pilots, then fetch homeworld info for each pilot, then…
▸ Very expensive for mobile apps
▸ Response structure may change over time
▸ Data overfetching
▸ We don’t always need all the data for a REST call
▸ Usually no metadata
▸ Big blob of data…we can’t run inquires on it’s types or structure

REST
FIXES FOR REST??
▸ Define your own ad-hoc query language
▸ Use REST PATCH to minimize data transfer ?
▸ REST API introspection via Swagger (http://swagger.io/)
GRAPHQL
JAVASCRIPT FATIGUE
BECAUSE A NEW JAVASCRIPT FRAMEWORK IS RELEASED
GRAPHQL
WHAT IS GRAPHQL?
▸ Queries describe the shape of data that the client needs. The
response has the same structure as the request query.
▸ Server interprets GraphQL calls and queries the database (or
any other source of data)
▸ GraphQL is language-, database- and protocol-agnostic 

GRAPHQL WAS
INVENTED AT FACEBOOK
IN 2012, BUT IT WAS
FIRST SHOWN TO
PUBLIC IN 2015 DURING
REACT.JS CONF AS A
PART OF FACEBOOK
OPEN-SOURCE
ECOSYSTEM.
GRAPHQL
GRAPHQL MOTIVATION
▸ Single endpoint
▸ Hierarchical nature
▸ Strongly typed - enables validation, introspection and more
▸ Response mirrors the shape of the query
▸ Introspection - make inquiries from your client about the schema
▸ Application-Layer Protocol
▸ GraphQL is an application-layer protocol and does not require a particular
transport. It is a string that is parsed and interpreted by a server.
GRAPHQL
GRAPHS - DAG/AST
*
-
397
+
6
DIRECTED ACYCLIC GRAPH ABSTRACT SYNTAX TREES
(6 + 7) * (9 - 3)
GRAPHQL
GRAPHS PERSON
[NAME, ID, …]
STARSHIP-A
[ID, MANUF,..]
STARSHIP-B
[ID, MANUF,..]
STARSHIP-C
[ID, MANUF,..]
PILOT-A
[ID, NAME,..]
STARSHIPCONNECTION
STARSHIPCONNECTION
STARSHIP CONNECTION
PILOT CONNECTION
HOMEWORLD-A
[ID, NAME,..]
HOMEWORLD CONNECTION
HOMEWORLDCONNECTION
NODE
NODE
EDGE
GRAPHQL
FOLLOW ALONG!
▸ Go here and follow along with me
▸ http://graphql-swapi.parseapp.com
GRAPHQL
BASIC QUERY
GRAPHQL
NESTED FIELDS
GRAPHQL
CONNECTIONS
GRAPHQL
MANY CONNECTIONS
GRAPHQL
ARGUMENTS
GRAPHQL
FRAGMENTS
GRAPHQL
MORE FRAGMENTS
GRAPHQL
INTROSPECTION
GRAPHQL
SCARED YET?
▸ Syntax (covered)
▸ Type System
▸ Resolving
▸ Edges/Nodes & Pagination
GRAPHQL
GRAPHQL TYPE SYSTEM
▸ Scalars - basic types
▸ Schema - a representation of the capabilities of the GraphQL
server
▸ Definitions - defining types
▸ Predicates - meta info on types
▸ Un-modifiers - type “un” modifiers
GRAPHQL
GRAPHQL SCALARS
▸ GraphQLInt - integer number
▸ GraphQLFloat - float number
▸ GraphQLString - string
▸ GraphQLBoolean - boolean
▸ GraphQLID - represents an ID (essentially a string)
GRAPHQL
GRAPHQL SCHEMAS
▸ It all starts with a “root” query
▸ Fields on type can be plain data or “resolved”
▸ You can define your own types
▸ You can define/override the serialization on a type
▸ You can add enhanced validation to types
▸ From a schema, you can generate a more human readable
schema and JSON based schema for clients to use
GRAPHQL
GRAPHQL DEFINITIONS
▸ GraphQLScalarType - the class of scalars
▸ GraphQLObjectType - an object
▸ GraphQLInterfaceType - a interface
▸ GraphQLUnionType - a union
▸ GraphQLEnumType - enum
▸ GraphQLInputObjectType
▸ GraphQLList - what you use for lists arrays of objects
▸ GraphQLNonNull - an object for which null is an invalid value
GRAPHQL
GRAPHQL DATA RESOLUTION
▸ Resolve to data - synchronous
result. Return the data as teh
result of a resolve.
▸ Resolve to promise -
asynchronous result. Return a
promise that will return the
data in the future. My
preference is to use ES6 and
async functions (which actually
return promises).
GRAPHQL
GRAPHQL EDGES/NODES
▸ Not built into the language, but provided by types
▸ The type Facebook uses and I recommend you use too, are in
: https://github.com/graphql/graphql-relay-js
▸ Using edges and nodes allow for pagination. If you don’t
need pagination, then use a simple GraphQLList.
GRAPHQL
RUNNING ON EXPRESS https://github.com/graphql/graphql-js
GRAPHQL
EXAMPLE SCHEMA
GRAPHQL
CUSTOM SCALAR
Credits: Snippet from https://github.com/mattkrick/meatier
GRAPHQL
BUILD IT!
▸ Build your server…I use Babel and ES6
▸ You’ll also need to run (see sample code) a script to “update”
your schema. This creates a client and a human readable
version of your schema.
▸ If you are using Relay, you will also need to use the Babel-
Relay plugin to consume, compile and validate your GraphQL
queries in your components.
▸ You also need to tell the Babel-Relay plugin where to find the
schema you built above (the JSON form).
GRAPHQL
MAKE SENSE?
▸ Hopefully more sense
than Chewy!
GRAPHQL
GRAPHQL MISUNDERSTANDINGS
▸ All of the queries you see are defined by your schema. I.e.
things like viewer, user, edge, node are defined by the
schema and not an inherent part of the language.
▸ GraphQL is Javascript only. Nope!
▸ There are 3rd party ports for Python, Scala, Go, Ruby, etc.
▸ GraphQL requires special communications protocol. Nope!
▸ The default implementation uses a basic REST post call, but you can use
web sockets, etc. and even mix and match.
GRAPHQL & RELAY
RESOURCES
▸ Cartoon Guides To
GraphQL: https://code-
cartoons.com
▸ Awesome GraphQL -
curated list on Github:
https://github.com/
chentsulin/awesome-
graphql
GRAPHQL & RELAY
MORE RESOURCES
▸ GraphQL Home: http://graphql.org/
▸ GraphQL Spec: https://facebook.github.io/graphql/
▸ Many REST APIs you can experiment with using GraphQL:
https://www.graphqlhub.com/
QUESTIONS???▸ Twitter: @BradPillow, GitHub: pillowsoft
THANKS!

Contenu connexe

Tendances

Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL Josh Price
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsSashko Stubailo
 
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/MeteorWhy UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/MeteorJon Wong
 
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architectureSashko Stubailo
 
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)Hafiz Ismail
 
Modular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingModular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingSashko Stubailo
 
GraphQL, Redux, and React
GraphQL, Redux, and ReactGraphQL, Redux, and React
GraphQL, Redux, and ReactKeon Kim
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQLRodrigo Prates
 
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
 
Matheus Marsiglio - Isomorphic React + Redux App
Matheus Marsiglio - Isomorphic React + Redux AppMatheus Marsiglio - Isomorphic React + Redux App
Matheus Marsiglio - Isomorphic React + Redux AppReact Conf Brasil
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQLBrainhub
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQLvaluebound
 
Raphael Amorim - Scrating React Fiber
Raphael Amorim - Scrating React FiberRaphael Amorim - Scrating React Fiber
Raphael Amorim - Scrating React FiberReact Conf Brasil
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL StackSashko Stubailo
 
GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018Sashko Stubailo
 
James Baxley - Statically typing your GraphQL app
James Baxley - Statically typing your GraphQL appJames Baxley - Statically typing your GraphQL app
James Baxley - Statically typing your GraphQL appReact Conf Brasil
 
GraphQL Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL IntroductionSerge Huber
 

Tendances (20)

Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer tools
 
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/MeteorWhy UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
 
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architecture
 
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
 
Modular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingModular GraphQL with Schema Stitching
Modular GraphQL with Schema Stitching
 
GraphQL, Redux, and React
GraphQL, Redux, and ReactGraphQL, Redux, and React
GraphQL, Redux, and React
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
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
 
Matheus Marsiglio - Isomorphic React + Redux App
Matheus Marsiglio - Isomorphic React + Redux AppMatheus Marsiglio - Isomorphic React + Redux App
Matheus Marsiglio - Isomorphic React + Redux App
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQL
 
Raphael Amorim - Scrating React Fiber
Raphael Amorim - Scrating React FiberRaphael Amorim - Scrating React Fiber
Raphael Amorim - Scrating React Fiber
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
 
Graphql
GraphqlGraphql
Graphql
 
Apollo Server
Apollo ServerApollo Server
Apollo Server
 
Intro to GraphQL
 Intro to GraphQL Intro to GraphQL
Intro to GraphQL
 
GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018
 
James Baxley - Statically typing your GraphQL app
James Baxley - Statically typing your GraphQL appJames Baxley - Statically typing your GraphQL app
James Baxley - Statically typing your GraphQL app
 
GraphQL Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL Introduction
 

En vedette

Zensations Drupal 8 GraphQL Presentation 2015
Zensations Drupal 8 GraphQL Presentation 2015Zensations Drupal 8 GraphQL Presentation 2015
Zensations Drupal 8 GraphQL Presentation 2015Zensations GmbH
 
Relay: Seamless Syncing for React (VanJS)
Relay: Seamless Syncing for React (VanJS)Relay: Seamless Syncing for React (VanJS)
Relay: Seamless Syncing for React (VanJS)Brooklyn Zelenka
 
GraphQL Relay Introduction
GraphQL Relay IntroductionGraphQL Relay Introduction
GraphQL Relay IntroductionChen-Tsu Lin
 
Work with V8 memory leaks
Work with V8 memory leaksWork with V8 memory leaks
Work with V8 memory leaksRoman Krivtsov
 
Introduction to GraphQL at API days
Introduction to GraphQL at API daysIntroduction to GraphQL at API days
Introduction to GraphQL at API daysyann_s
 
Migration microservices to GraphQL
Migration microservices to GraphQLMigration microservices to GraphQL
Migration microservices to GraphQLRoman Krivtsov
 
GraphQL vs REST
GraphQL vs RESTGraphQL vs REST
GraphQL vs RESTGreeceJS
 
GraphQL Story: Intro To GraphQL
GraphQL Story: Intro To GraphQLGraphQL Story: Intro To GraphQL
GraphQL Story: Intro To GraphQLRiza Fahmi
 
Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)Rafael Wilber Kerr
 

En vedette (11)

Graphql
GraphqlGraphql
Graphql
 
Zensations Drupal 8 GraphQL Presentation 2015
Zensations Drupal 8 GraphQL Presentation 2015Zensations Drupal 8 GraphQL Presentation 2015
Zensations Drupal 8 GraphQL Presentation 2015
 
Relay: Seamless Syncing for React (VanJS)
Relay: Seamless Syncing for React (VanJS)Relay: Seamless Syncing for React (VanJS)
Relay: Seamless Syncing for React (VanJS)
 
GraphQL Relay Introduction
GraphQL Relay IntroductionGraphQL Relay Introduction
GraphQL Relay Introduction
 
Work with V8 memory leaks
Work with V8 memory leaksWork with V8 memory leaks
Work with V8 memory leaks
 
Introduction to GraphQL at API days
Introduction to GraphQL at API daysIntroduction to GraphQL at API days
Introduction to GraphQL at API days
 
Migration microservices to GraphQL
Migration microservices to GraphQLMigration microservices to GraphQL
Migration microservices to GraphQL
 
GraphQL vs REST
GraphQL vs RESTGraphQL vs REST
GraphQL vs REST
 
Swift + GraphQL
Swift + GraphQLSwift + GraphQL
Swift + GraphQL
 
GraphQL Story: Intro To GraphQL
GraphQL Story: Intro To GraphQLGraphQL Story: Intro To GraphQL
GraphQL Story: Intro To GraphQL
 
Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)
 

Similaire à GraphQL IndyJS April 2016

GraphQL And Relay Modern
GraphQL And Relay ModernGraphQL And Relay Modern
GraphQL And Relay ModernBrad Pillow
 
GraphQL And Relay Modern
GraphQL And Relay ModernGraphQL And Relay Modern
GraphQL And Relay ModernBrad Pillow
 
GraphQL & DGraph with Go
GraphQL & DGraph with GoGraphQL & DGraph with Go
GraphQL & DGraph with GoJames Tan
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentationVibhor Grover
 
PGQL: A Language for Graphs
PGQL: A Language for GraphsPGQL: A Language for Graphs
PGQL: A Language for GraphsJean Ihm
 
GraphQL vs. (the) REST
GraphQL vs. (the) RESTGraphQL vs. (the) REST
GraphQL vs. (the) RESTcoliquio GmbH
 
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
 
Cascading on starfish
Cascading on starfishCascading on starfish
Cascading on starfishFei Dong
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Tugdual Grall
 
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
 
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...François-Guillaume Ribreau
 
Your API on Steroids - Retrofitting GraphQL by Code, Cloud Native or Serverless
Your API on Steroids - Retrofitting GraphQL by Code, Cloud Native or ServerlessYour API on Steroids - Retrofitting GraphQL by Code, Cloud Native or Serverless
Your API on Steroids - Retrofitting GraphQL by Code, Cloud Native or ServerlessQAware GmbH
 
PipelineAI Optimizes Your Enterprise AI Pipeline from Distributed Training to...
PipelineAI Optimizes Your Enterprise AI Pipeline from Distributed Training to...PipelineAI Optimizes Your Enterprise AI Pipeline from Distributed Training to...
PipelineAI Optimizes Your Enterprise AI Pipeline from Distributed Training to...Chris Fregly
 
Scaling your GraphQL applications with Dgraph
Scaling your GraphQL applications with DgraphScaling your GraphQL applications with Dgraph
Scaling your GraphQL applications with DgraphKarthic Rao
 
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...Alexander Dean
 
PipelineAI + AWS SageMaker + Distributed TensorFlow + AI Model Training and S...
PipelineAI + AWS SageMaker + Distributed TensorFlow + AI Model Training and S...PipelineAI + AWS SageMaker + Distributed TensorFlow + AI Model Training and S...
PipelineAI + AWS SageMaker + Distributed TensorFlow + AI Model Training and S...Chris Fregly
 

Similaire à GraphQL IndyJS April 2016 (20)

GraphQL And Relay Modern
GraphQL And Relay ModernGraphQL And Relay Modern
GraphQL And Relay Modern
 
GraphQL and Relay Modern
GraphQL and Relay ModernGraphQL and Relay Modern
GraphQL and Relay Modern
 
GraphQL And Relay Modern
GraphQL And Relay ModernGraphQL And Relay Modern
GraphQL And Relay Modern
 
The GrapQL ecosystem
The GrapQL ecosystemThe GrapQL ecosystem
The GrapQL ecosystem
 
GraphQL & DGraph with Go
GraphQL & DGraph with GoGraphQL & DGraph with Go
GraphQL & DGraph with Go
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentation
 
PGQL: A Language for Graphs
PGQL: A Language for GraphsPGQL: A Language for Graphs
PGQL: A Language for Graphs
 
GraphQL vs. (the) REST
GraphQL vs. (the) RESTGraphQL vs. (the) REST
GraphQL vs. (the) REST
 
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
 
Cascading on starfish
Cascading on starfishCascading on starfish
Cascading on starfish
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007
 
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
 
Grails 101
Grails 101Grails 101
Grails 101
 
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
 
Your API on Steroids - Retrofitting GraphQL by Code, Cloud Native or Serverless
Your API on Steroids - Retrofitting GraphQL by Code, Cloud Native or ServerlessYour API on Steroids - Retrofitting GraphQL by Code, Cloud Native or Serverless
Your API on Steroids - Retrofitting GraphQL by Code, Cloud Native or Serverless
 
PipelineAI Optimizes Your Enterprise AI Pipeline from Distributed Training to...
PipelineAI Optimizes Your Enterprise AI Pipeline from Distributed Training to...PipelineAI Optimizes Your Enterprise AI Pipeline from Distributed Training to...
PipelineAI Optimizes Your Enterprise AI Pipeline from Distributed Training to...
 
Scaling your GraphQL applications with Dgraph
Scaling your GraphQL applications with DgraphScaling your GraphQL applications with Dgraph
Scaling your GraphQL applications with Dgraph
 
Graphql usage
Graphql usageGraphql usage
Graphql usage
 
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
 
PipelineAI + AWS SageMaker + Distributed TensorFlow + AI Model Training and S...
PipelineAI + AWS SageMaker + Distributed TensorFlow + AI Model Training and S...PipelineAI + AWS SageMaker + Distributed TensorFlow + AI Model Training and S...
PipelineAI + AWS SageMaker + Distributed TensorFlow + AI Model Training and S...
 

Dernier

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 

Dernier (20)

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 

GraphQL IndyJS April 2016

  • 3. REST REST IS AN ACRONYM FOR ?
  • 4. REST REST HISTORY ▸ The term representational state transfer was introduced and defined in 2000 by Roy Fielding ▸ The defacto standard for communicating with a server ▸ Defines simple operations: GET, PUT, POST, DELETE ▸ A query operation (like GET) promises no side-effects (e.g. changes) in data being queried. Commands (like PUT/DELETE) answer no questions about the data, but compute changes applied to the data (e.g. UPDATE or INSERT to use database terms).
  • 5. REST REST ISSUES ▸ Many endpoints - proliferation of ad hoc endpoints ▸ Many round trips between the client and server ▸ First fetch pilots, then fetch homeworld info for each pilot, then… ▸ Very expensive for mobile apps ▸ Response structure may change over time ▸ Data overfetching ▸ We don’t always need all the data for a REST call ▸ Usually no metadata ▸ Big blob of data…we can’t run inquires on it’s types or structure

  • 6. REST FIXES FOR REST?? ▸ Define your own ad-hoc query language ▸ Use REST PATCH to minimize data transfer ? ▸ REST API introspection via Swagger (http://swagger.io/)
  • 7. GRAPHQL JAVASCRIPT FATIGUE BECAUSE A NEW JAVASCRIPT FRAMEWORK IS RELEASED
  • 8. GRAPHQL WHAT IS GRAPHQL? ▸ Queries describe the shape of data that the client needs. The response has the same structure as the request query. ▸ Server interprets GraphQL calls and queries the database (or any other source of data) ▸ GraphQL is language-, database- and protocol-agnostic 

  • 9. GRAPHQL WAS INVENTED AT FACEBOOK IN 2012, BUT IT WAS FIRST SHOWN TO PUBLIC IN 2015 DURING REACT.JS CONF AS A PART OF FACEBOOK OPEN-SOURCE ECOSYSTEM.
  • 10. GRAPHQL GRAPHQL MOTIVATION ▸ Single endpoint ▸ Hierarchical nature ▸ Strongly typed - enables validation, introspection and more ▸ Response mirrors the shape of the query ▸ Introspection - make inquiries from your client about the schema ▸ Application-Layer Protocol ▸ GraphQL is an application-layer protocol and does not require a particular transport. It is a string that is parsed and interpreted by a server.
  • 11. GRAPHQL GRAPHS - DAG/AST * - 397 + 6 DIRECTED ACYCLIC GRAPH ABSTRACT SYNTAX TREES (6 + 7) * (9 - 3)
  • 12. GRAPHQL GRAPHS PERSON [NAME, ID, …] STARSHIP-A [ID, MANUF,..] STARSHIP-B [ID, MANUF,..] STARSHIP-C [ID, MANUF,..] PILOT-A [ID, NAME,..] STARSHIPCONNECTION STARSHIPCONNECTION STARSHIP CONNECTION PILOT CONNECTION HOMEWORLD-A [ID, NAME,..] HOMEWORLD CONNECTION HOMEWORLDCONNECTION NODE NODE EDGE
  • 13. GRAPHQL FOLLOW ALONG! ▸ Go here and follow along with me ▸ http://graphql-swapi.parseapp.com
  • 22. GRAPHQL SCARED YET? ▸ Syntax (covered) ▸ Type System ▸ Resolving ▸ Edges/Nodes & Pagination
  • 23. GRAPHQL GRAPHQL TYPE SYSTEM ▸ Scalars - basic types ▸ Schema - a representation of the capabilities of the GraphQL server ▸ Definitions - defining types ▸ Predicates - meta info on types ▸ Un-modifiers - type “un” modifiers
  • 24. GRAPHQL GRAPHQL SCALARS ▸ GraphQLInt - integer number ▸ GraphQLFloat - float number ▸ GraphQLString - string ▸ GraphQLBoolean - boolean ▸ GraphQLID - represents an ID (essentially a string)
  • 25. GRAPHQL GRAPHQL SCHEMAS ▸ It all starts with a “root” query ▸ Fields on type can be plain data or “resolved” ▸ You can define your own types ▸ You can define/override the serialization on a type ▸ You can add enhanced validation to types ▸ From a schema, you can generate a more human readable schema and JSON based schema for clients to use
  • 26. GRAPHQL GRAPHQL DEFINITIONS ▸ GraphQLScalarType - the class of scalars ▸ GraphQLObjectType - an object ▸ GraphQLInterfaceType - a interface ▸ GraphQLUnionType - a union ▸ GraphQLEnumType - enum ▸ GraphQLInputObjectType ▸ GraphQLList - what you use for lists arrays of objects ▸ GraphQLNonNull - an object for which null is an invalid value
  • 27. GRAPHQL GRAPHQL DATA RESOLUTION ▸ Resolve to data - synchronous result. Return the data as teh result of a resolve. ▸ Resolve to promise - asynchronous result. Return a promise that will return the data in the future. My preference is to use ES6 and async functions (which actually return promises).
  • 28. GRAPHQL GRAPHQL EDGES/NODES ▸ Not built into the language, but provided by types ▸ The type Facebook uses and I recommend you use too, are in : https://github.com/graphql/graphql-relay-js ▸ Using edges and nodes allow for pagination. If you don’t need pagination, then use a simple GraphQLList.
  • 29. GRAPHQL RUNNING ON EXPRESS https://github.com/graphql/graphql-js
  • 31. GRAPHQL CUSTOM SCALAR Credits: Snippet from https://github.com/mattkrick/meatier
  • 32. GRAPHQL BUILD IT! ▸ Build your server…I use Babel and ES6 ▸ You’ll also need to run (see sample code) a script to “update” your schema. This creates a client and a human readable version of your schema. ▸ If you are using Relay, you will also need to use the Babel- Relay plugin to consume, compile and validate your GraphQL queries in your components. ▸ You also need to tell the Babel-Relay plugin where to find the schema you built above (the JSON form).
  • 33. GRAPHQL MAKE SENSE? ▸ Hopefully more sense than Chewy!
  • 34. GRAPHQL GRAPHQL MISUNDERSTANDINGS ▸ All of the queries you see are defined by your schema. I.e. things like viewer, user, edge, node are defined by the schema and not an inherent part of the language. ▸ GraphQL is Javascript only. Nope! ▸ There are 3rd party ports for Python, Scala, Go, Ruby, etc. ▸ GraphQL requires special communications protocol. Nope! ▸ The default implementation uses a basic REST post call, but you can use web sockets, etc. and even mix and match.
  • 35. GRAPHQL & RELAY RESOURCES ▸ Cartoon Guides To GraphQL: https://code- cartoons.com ▸ Awesome GraphQL - curated list on Github: https://github.com/ chentsulin/awesome- graphql
  • 36. GRAPHQL & RELAY MORE RESOURCES ▸ GraphQL Home: http://graphql.org/ ▸ GraphQL Spec: https://facebook.github.io/graphql/ ▸ Many REST APIs you can experiment with using GraphQL: https://www.graphqlhub.com/
  • 37. QUESTIONS???▸ Twitter: @BradPillow, GitHub: pillowsoft THANKS!