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
MilanoJS - GraphQL
Search
Marco Sampellegrini
April 06, 2016
Programming
61
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
MilanoJS - GraphQL
Marco Sampellegrini
April 06, 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
DevFest Vienna - GraphQL
alpacaaa
0
38
Universal JS day - GraphQL
alpacaaa
0
28
Other Decks in Programming
See All in Programming
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
phperだってパンチカードでコーディングしたい
o0h
PRO
0
340
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
Web Framework Benchmark Battle 2026, Any%
a_matsuda
2
2.3k
すこし踏み込む CancellationToken
htkym
2
1.7k
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
250
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
180
JIS keyboard support in Omarchy
lef237
0
130
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
1
440
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
140
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
Featured
See All Featured
Darren the Foodie - Storyboard
khoart
PRO
4
4k
My Coaching Mixtape
mlcsv
0
360
The agentic SEO stack - context over prompts
schlessera
0
970
We Have a Design System, Now What?
morganepeng
55
8.4k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
460
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
710
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
310
Site-Speed That Sticks
csswizardry
13
1.6k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Automating Front-end Workflow
addyosmani
1369
210k
Transcript
GRAPHQL MILANOJS – 2016
github.com/alpacaaa MARCO SAMPELLEGRINI
Small team – 5 people 100% Javascript codebase React Native
– React – Node.js – RethinkDB Currently working on a classi ed project
A data query and data manipulation language for client apps
ALTERNATIVE TO REST
EXAMPLE: GITHUB REPO PAGE
Start by breaking down the UI into a component hierarchy
THINKING IN REACT
THINKING IN REACT 1. <Repo> 2. <RepoInfo /> 3. <LastCommit
/> 4. 5. <RepoTree> 6. <TreeEntry> 7. <FileLastCommit /> 8. </TreeEntry> 9. 10. <TreeEntry> 11. <FileLastCommit /> 12. </TreeEntry> 13. 14. <TreeEntry> 15. <FileLastCommit />
None
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", 13. ... 14. },
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. }, 15. {
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. }, 12. ... 13. } 14. ] 15.
.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. GithubUser : Object { 3. id
: Int 4. login : String 5. company : String 6. avatar_url : String 7. repos : [GithubRepo] 8. } 1. 9. 10. 11. GithubRepo : Object { 12. id : Int 13. name : String 14. owner : GithubUser 15. issues : [GithubIssue] 16. commits : [GithubCommit] 17. } 18. 19. 20. GithubCommit : Object {
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: () => ({ 16. login: { 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), 16. } 1.
TOOLING: GRAPHIQL An IDE for building GraphQL queries
None
THANKS!