Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GraphQL on Rails
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Marc-Andre Giroux
March 15, 2016
Programming
1.2k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GraphQL on Rails
Introduction to GraphQl and how to use it in Rails.
Marc-Andre Giroux
March 15, 2016
More Decks by Marc-Andre Giroux
See All by Marc-Andre Giroux
It Depends - Examining GraphQL Myths & Assumptions
xuorig
0
140
So you Want to Distribute your GraphQL Schema?
xuorig
4
880
So you Want to Distribute your GraphQL Schema?
xuorig
0
690
GraphQL Schema Design @ Scale
xuorig
5
2.2k
Continuous Evolution of GraphQL Schemas @ GitHub
xuorig
3
2.2k
GraphQL à Shopify
xuorig
0
290
Exploring GraphQL
xuorig
0
310
GraphQL @ Shopify
xuorig
6
1.8k
GraphQL on Rails
xuorig
2
400
Other Decks in Programming
See All in Programming
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.8k
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
410
AI時代のUIはどこへ行く?その2!
yusukebe
22
7.5k
AI 輔助遺留系統現代化的經驗分享
jame2408
1
1k
はてなアカウント基盤 State of the Union
cockscomb
1
900
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
200
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
180
JavaDoc 再入門
nagise
1
420
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
280
ランチタイムLT会3周年!ランチタイムLT会を3年間続けられたお話
y0hgi
1
110
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
170
Featured
See All Featured
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
950
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
620
The Mindset for Success: Future Career Progression
greggifford
PRO
0
370
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
400
So, you think you're a good person
axbom
PRO
2
2.1k
Music & Morning Musume
bryan
47
7.2k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Site-Speed That Sticks
csswizardry
13
1.2k
Transcript
GraphQL on Rails FROM REST TO GRAP HQL @ _
_XU O R IG _ _
@ _ _XU O R IG _ _
/product/1 product/1/photos/a product/1/photos/b product/1/variants
Way too many roundtrips!
/productview?include=variants&photo_count=2
/productview_thumbnail?include=price /productview_thumbnail?include=price&photo_size=small /productview_super_special_thumbnail_with_description?photo_size=100,1000 /an_endpoint_that_returns_a_bunch_of_things_that_i_need_for_a_particular_view
Better, but quickly becomes a nightmare.
Server Client product view v1 product model v1 update endpoints
create new endpoints product view v2 product view v3 product model v2 product model v3
GraphQL to the rescue
{ myShop { name } } Selection set Field
{ “myShop” { “name”: “GitHub” } } { myShop {
name } } Lexed Parsed Validated Executed
{ myShop { name } }
{ shop(id: 19423) { name } } { myShop {
name } }
{ myShop { name location { city address } }
}
{ “myShop” { “name”: “GitHub” “location”: { “city”: “San Francisco”
“address”: “88 Colin P Kelly Jr St” } } }
The Type System
{ myShop { name location { city address } products(orderby:
POPULARITY) { name price } } }
{ myShop { name location { city address } products(orderby:
POPULARITY) { name price } } } type QueryRoot { myShop: Shop shop(id: Int): Shop }
{ myShop { name location { city address } products(orderby:
POPULARITY) { name price } } } type Shop { name: String location: Address products(orderby: OrderEnum): [Product] } enum ProductOrderEnum { PRICE, POPULARITY, ALPHABETICAL }
{ myShop { name location { city address } products(orderby:
POPULARITY) { name price } } } type Address { city: String address: String }
{ myShop { name location { city address } products(orderby:
POPULARITY) { name price } } } type Product { name: String price: Int }
Server Client H ER E I S P RO DU
C T W I TH I D = 1 G ET P R OD U C T W IT H I D= 1
Server Client EX P O SES S C HE M
A O F AL L PO S SI B I L IT I ES ( T Y P E SYS T EM ) DATA R EQ UI R EM EN T S (G R AP H Q L LA N GUAG E )
Server Client O K H ER E’S EX AC T
LY T HE DATA YO U NEE D G I VE ME DATA O F T HAT PAR T IC U LA R S H AP E
Server Client product view v1 Product model v1 product view
v3 Product model v3 product view v2 Product model v2 Doesn’t care
One endpoint to rule them all
Web iOS App POS App Android App
Fragments
{ myShop { name location { city address } }
}
{ myShop { name …locationFragment } } fragment locationFragment on
Shop { location { city address } }
Mutations
{ createBlog(title: “my cool blog") { title } }
Introspection
None
IDE integration Static Validation Code Generation Auto Documentation
GraphQL on Rails
rails generate model Blog title:string content:string author_id:integer rails generate model
Author name:string class Blog < ActiveRecord::Base has_one :author end
GEM ‘GRAPHQL’
None
None
None
query allBlogs { blogs { title author { name }
} }
{ "data": { "blogs": [ { "title": "Intro to GraphQL",
"content": "Something something something. Blah blah blah. Etc etc etc.", "author": { "name": "Marc-Andre Giroux" } }, { "title": "Hello, it's me", "content": "I've been wondering", "author": { "name": "Marc-Andre Giroux" } }, { "title": "Hello, it's me", "content": "I've been wondering", "author": { "name": "Marc-Andre Giroux" } } ] } }
GraphiQL
MG I ROUX.M E G RAPH QL-SLACK .HE R OK
UA P P.COM/ Slack channel My blog graphql-ruby G IT HU B.COM /R MO SO LG O/ G R A P H Q L-R U BY Twitter @__ XUORI G__
Thank You :D