Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
DevFest Vienna - GraphQL
Search
Marco Sampellegrini
November 05, 2016
Programming
38
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
DevFest Vienna - GraphQL
Marco Sampellegrini
November 05, 2016
More Decks by Marco Sampellegrini
See All by Marco Sampellegrini
MilanoJS 2017 - Elm in Production
alpacaaa
0
73
WebAppConf 2017 - Elm in Production
alpacaaa
1
160
Universal JS day - GraphQL
alpacaaa
0
28
MilanoJS - GraphQL
alpacaaa
0
61
Other Decks in Programming
See All in Programming
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
690
Workers Cache を知る
syumai
0
370
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
220
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
ジョジョの世界をXRで再現する
mofurune
0
160
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
380
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
110
Web Framework Benchmark Battle 2026, Any%
a_matsuda
2
2.1k
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
230
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
JIS keyboard support in Omarchy
lef237
0
120
Featured
See All Featured
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
330
The SEO Collaboration Effect
kristinabergwall1
1
590
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
410
Done Done
chrislema
187
17k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
360
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
710
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
280
Ethics towards AI in product and experience design
skipperchong
2
430
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Transcript
GRAPHQL DEVFEST VIENNA – 2016
github.com/alpacaaa MARCO SAMPELLEGRINI
A data query and data manipulation language for client apps
ALTERNATIVE TO REST
EXAMPLE: GITHUB REPO PAGE
REPO INFO
/repos/jonsuh/hamburgers 1. { 2. "id": 52645453, 3. "name": "hamburgers", 4.
"full_name": "jonsuh/hamburgers", 5. "html_url": "https://github.com/jonsuh/hamburgers", 6. "description": "Tasty CSSanimated Hamburgers", 7. ... 8. } 9.
LAST COMMIT
/commits/master 1. [ 2. { 3. "sha": "c06b0d54ca327f8507fd1e032a0adf69c170f122", 4. "commit":
{ 5. "message": "Update readme with new preview.", 6. "date": "20160307T15:12:22Z", 7. ... 8. }, 9. "author": { 10. "login": "jonsuh", 11. "id": 359871, 12. "avatar_url": "https://avatars.githubusercontent.com/u/359871?v=3",
TREE
/git/trees/master 1. { 2. "tree": [ 3. { 4. "path":
".gitignore", 5. "sha": "ea60652264db43aab511d4cec0882f55908dbc59", 6. }, 7. { 8. "path": "README.md", 9. "sha": "b1d830c56ac8232269ea751e3729ea104c476761", 10. }, 11. { 12. "path": "index.html", 13. "sha": "72f0f97bf2aa5655bc6ca61b0c62df01af7b478c", 14. },
CAN WE START CODING???
TREE ENTRY
/git/commits?path=.gitignore 1. [ 2. { 3. "sha": "2732635e20531fb0a63d1d40eca0c24105f1b3e0", 4. "commit":
{ 5. "message": "Flatten asset directory structure.", 6. "date": "20160226T22:39:51Z", 7. ... 8. }, 9. "author": { 10. "login": "jonsuh", 11. "id": 359871, 12. "avatar_url": "https://avatars.githubusercontent.com/u/359871?v=3",
.gitignore README.md index.html ONE REQUEST PER ENTRY
PROBLEMS Many roundtrips to the server Lots of data we
don't need GBOJ – Giant Blob of JSON
THAT WAS FUN!
MEET GRAPHQL
QUERY { repo(ownerUsername: "jonsuh" name: "hamburgers") { description } }
RESULT { "data": { "repo": { "description": "Tasty CSS-animated Hamburgers" } } } HELLO WORLD IN GRAPHQL
LAST COMMIT { repo(ownerUsername: "jonsuh" name: "hamburgers") { description commits(limit:
1) { sha message date } } } { "repo": { "description": "Tasty CSS-animated Hamburgers", "commits": [ { "sha": "c06b0d54ca327f8507fd1e032a0adf69c170f122", "message": "Update readme with new preview.", "date": "2016-03-07T15:12:22Z" } ] } }
TREE { repo(ownerUsername: "jonsuh" name: "hamburgers") { description commits(limit: 1)
{ sha message date tree { entries { path } } } } } { "repo": { "description": "Tasty CSS-animated Hamburgers", "commits": [ { "sha": "c06b0d54ca327f8507fd1e032a0adf69c170f122", ... "tree": { "entries": [ { "path": ".gitignore" }, { "path": "README.md" }, { "path": "index.html" } ... ] } } ] } }
TREE ENTRY { repo(ownerUsername: "jonsuh" name: "hamburgers") { description commits(limit:
1) { sha message date tree { entries { path last_commit { sha message date } } } } } } { "repo": { "description": "Tasty CSS-animated Hamburgers", "commits": [ { "sha": "c06b0d54ca327f8507fd1e032a0adf69c170f122", ... "tree": { "entries": [ { "path": ".gitignore", "last_commit": { "message": "Flatten asset directory structure.", "date": "2016-02-26T22:39:51Z", } }, { "path": "README.md" "last_commit": { ... } } ... ] } } ] } }
TREE ENTRY { repo(ownerUsername: "jonsuh" name: "hamburgers") { description commits(limit:
1) { sha message date tree { entries { path last_commit { sha message date } } } } } } <Repo> <RepoInfo /> <LastCommit /> <RepoTree> <TreeEntry> <FileLastCommit /> </TreeEntry> <TreeEntry> <FileLastCommit /> </TreeEntry> <TreeEntry> <FileLastCommit /> </TreeEntry> ... </RepoTree> </Repo>
What you request is what you get WYRIWYG
Client is responsible for the data returned DECLARATIVE
TYPE SYSTEM
Single root schema Root schema made up of elds Fields
must have a speci c type Developers can de ne their own types GRAPHQL SCHEMA
IMPLEMENT A GRAPHQL SERVER in Node.js
OFFICIAL MODULES graphql-js express-graphql
TYPES WE NEED 2. type GithubUser { 3. id :
Int 4. login : String 5. company : String 6. avatar_url : String 7. repos : [GithubRepo] 8. } 1. 9. 10. 11. type GithubRepo { 12. id : Int 13. name : String 14. owner : GithubUser 15. issues : [GithubIssue] 16. commits : [GithubCommit] 17. } 18. 19.
TYPE DEFINITION 2. import { 3. GraphQLObjectType, 4. GraphQLString, 5.
GraphQLNonNull, 6. GraphQLInt, 7. GraphQLFloat, 8. GraphQLBoolean, 9. GraphQLList, 10. } from 'graphql'; 11. 12. 13. const UserType = new GraphQLObjectType({ 14. name: 'GithubUser', 15. fields: () => ({ 1.
ROOT SCHEMA 2. const schema = new GraphQLSchema({ 3. query:
new GraphQLObjectType({ 4. name: 'RootQueryType', 5. fields: { 6. repo: { 7. type: RepoType, 8. args: { 9. name: { 10. description: 'Name of the repo', 11. type: new GraphQLNonNull(GraphQLString), 12. }, 13. ownerUsername: { 14. description: 'Username of the owner', 15. type: new GraphQLNonNull(GraphQLString), 1.
TOOLING: GRAPHIQL An IDE for building GraphQL queries
None
THANKS!