SlideShare a Scribd company logo
Introduction to GraphQL in Ruby
Amr Abdelwahab
Introduction to GraphQL with Ruby
Introduction to GraphQL with Ruby
How do we currently fetch data?
What is GraphQL?
Demo
Downsides
Outline
A simple UI component
What data do we need here?
Cart resource
Product Resource
Product Image Resource
Reusable Endpoints (REST)
● That will expose HREFs of the products
● Fetch the product resources
● Every product resource will expose Hrefs to
the product image
/cart/:id
Reusable Endpoints (REST)
Introduction to GraphQL with Ruby
● Deeper Nesting?
● Field selection?
/cart/:id?expand=products
Reusable Endpoints (REST)
● What is the convention?
/cart/:id?fields=products(name, description, price)
Reusable Endpoints (REST)
Reusable Endpoints (REST)
Introduction to GraphQL with Ruby
Custom Endpoints
/cart_with_everything_needed
Custom Endpoints
Introduction to GraphQL with Ruby
/cart_with_everything_needed
Custom Endpoints
/cart_with_everything_needed
/cart_v2_with_everything_needed
Custom Endpoints
/cart_with_everything_needed
/cart_v2_with_everything_needed
/cart_v3_with_everything_needed/cart_v3_with_everything_needed
Custom Endpoints
/cart_with_everything_needed
/cart_v2_with_everything_needed
/cart_v3_with_everything_needed/cart_v3_with_everything_needed
/cart_with_everything_needed/cart_with_everything_needed/cart_with_everything_needed
/cart_v2_with_everything_needed/cart_v2_with_everything_needed/cart_v2_with_everything_needed
/cart_v3_with_everything_needed/cart_v3_with_everything_needed/cart_v3_with_everything_needed/cart_v3_with_everything_needed
Custom Endpoints
Custom Endpoints
Client
● Updates a view
● Creates a new view
● New view version
Server
● Updates the endpoint
● Creates a new Endpoint
What is GraphQL?
What is NOT GraphQL?
What is NOT GraphQL?
● Not a database
● Not a library to install
● Not a language specific
What is GraphQL?
● A query language
○ Data shapes Not Resources
○ Client specified
● A server specs
○ How a server lexes, parses and executes
a query?
Post /graphql
Post /graphql
Demo Definition
● Shop(id)
○ Fetch all fields with children products
● product(id)
○ Fetch all fields with product image
● Create a new shop
Types, fields and arguments
Types
● Describes a value in the system
● Built in scalar types
● Custom types
○ Object types
○ Custom scalar types
○ Enum types
○ Interface or Union types
○ List types
Types Example
Types Example
Fields and arguments
● Fields are like a function
○ They accept arguments
○ They have a return type
Types Example
Fields and arguments
Fields and arguments
Fields and arguments
Fields and arguments
Fields and arguments
Fields and arguments
Fields and arguments
Fields and arguments
Fields and arguments
Fields and arguments
Fields and arguments
Project configuration
● Normal rails 5 application
● Add graphql-ruby gem
● rails generate graphql:install
○ Set up a folder structure in
app/graphql/
○ Add schema definition
○ Add a Query type definition
○ Add a route and controller for
executing queries
○ Install graphiql-rails
Introduction to GraphQL with Ruby
Introduction to GraphQL with Ruby
Introduction to GraphQL with Ruby
Schema definition
Schema definition
Schema definition
Schema definition
Query type
Query type
Query type
Introduction to GraphQL with Ruby
Query type
Query type
Shop Query field
Shop Query field
Shop Query field
Shop Query field
Introduction to GraphQL with Ruby
Shop Query field
Shop Query field
Shop Query field
Shop Type
Shop Type
Introduction to GraphQL with Ruby
Shop Type
Introduction to GraphQL with Ruby
Shop Type
Shop Type
Product Type
Product Type
Introduction to GraphQL with Ruby
Product Type
Introduction to GraphQL with Ruby
Product Type
Product Type
Product Image Type
Product Image Type
Introduction to GraphQL with Ruby
Product Image Type
Mutations
Introduction to GraphQL with Ruby
First
Query Variables
Introduction to GraphQL with Ruby
Introduction to GraphQL with Ruby
Introduction to GraphQL with Ruby
Back
To the Mutation
Introduction to GraphQL with Ruby
Schema definition
Schema definition
Mutation type
Mutation type
Introduction to GraphQL with Ruby
Mutation type
Mutation type
Create shop mutation
Create shop mutation
Create shop mutation
Create shop mutation
Create shop mutation
Introduction to GraphQL with Ruby
Create shop mutation
Principles
● Hierarchical
● Product centric
● Strongly typed
● Client-specified queries
● Introspective
● Version free
Introspection
Introspection
● Auto Documentation
● Client side validations
● IDE integrations
Downsides
Downsides
● N + 1 queries
● Http Caching
● Security
Thank you
Any questions?
E-MAIL
info@digitalnatives.hu
job@digitalnatives.hu
PHONE
+36 30 208 5625
ADDRESS
Andrássy út 66. Budapest, H-1062
Digital Natives Ltd.

More Related Content

PPTX
The Trials and Tribulations of the API Style Guide
PPTX
[SoftServe IT Academy] JavaScript Forms
PDF
PPTX
Green Custard Friday Talk 8: GraphQL
PDF
GraphQL – the future of APIs?
PPTX
GraphQL API Gateway and microservices
PDF
GraphQL in Ruby on Rails - basics
PDF
GraphQL with .NET Core Microservices.pdf
The Trials and Tribulations of the API Style Guide
[SoftServe IT Academy] JavaScript Forms
Green Custard Friday Talk 8: GraphQL
GraphQL – the future of APIs?
GraphQL API Gateway and microservices
GraphQL in Ruby on Rails - basics
GraphQL with .NET Core Microservices.pdf

Similar to Introduction to GraphQL with Ruby (20)

PPTX
PPTX
Introduction to GraphQL
PPTX
GraphQl Introduction
PDF
Graphql
PDF
Let's start GraphQL: structure, behavior, and architecture
PDF
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
PDF
GraphQL - A love story
PDF
GraphQL in Symfony
PDF
REST to GraphQL migration: Pros, cons and gotchas
PDF
GraphQL - A query language to empower your API consumers (NDC Sydney 2017)
PDF
Intro to GraphQL
PPTX
An intro to GraphQL
PDF
Intro to GraphQL
PDF
Overview of GraphQL & Clients
DOCX
GraphQL Advanced Concepts A Comprehensive Guide.docx
PDF
GraphQL
PDF
DEVOXX UK 2018 - GraphQL as an alternative approach to REST
PPTX
Graph QL Introduction
PDF
GraphQL + relay
PDF
GraphQL and Relay Modern
Introduction to GraphQL
GraphQl Introduction
Graphql
Let's start GraphQL: structure, behavior, and architecture
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL - A love story
GraphQL in Symfony
REST to GraphQL migration: Pros, cons and gotchas
GraphQL - A query language to empower your API consumers (NDC Sydney 2017)
Intro to GraphQL
An intro to GraphQL
Intro to GraphQL
Overview of GraphQL & Clients
GraphQL Advanced Concepts A Comprehensive Guide.docx
GraphQL
DEVOXX UK 2018 - GraphQL as an alternative approach to REST
Graph QL Introduction
GraphQL + relay
GraphQL and Relay Modern
Ad

More from Digital Natives (15)

PDF
How to support innovation in organisations @ Startup Safary
PDF
A termékfejlesztés rögös útja (avagy barangolás a módszertanok és eszközök er...
PDF
Agile és lean workshop @ Startup Safary
PDF
A visual introduction to concurrency and parallellism patterns
PPTX
How flat organisations support the innovation
PPTX
CULTURE OF INNOVATION
PDF
Testing in JavaScript
PDF
Basics of Metaprogramming in Ruby
PDF
Ruby meetup 7_years_in_testing
PPT
Digital natives incubation process_2011-11-23_v09
PDF
Evolution of the Software Development Process ad Digital Natives
PPTX
Mixgar in Volt festival 2011
PPTX
Mixgar prezi v1.2
PDF
Budapest.rb 2011/01 - Rails Deployment
PDF
Budapest.rb 201010
How to support innovation in organisations @ Startup Safary
A termékfejlesztés rögös útja (avagy barangolás a módszertanok és eszközök er...
Agile és lean workshop @ Startup Safary
A visual introduction to concurrency and parallellism patterns
How flat organisations support the innovation
CULTURE OF INNOVATION
Testing in JavaScript
Basics of Metaprogramming in Ruby
Ruby meetup 7_years_in_testing
Digital natives incubation process_2011-11-23_v09
Evolution of the Software Development Process ad Digital Natives
Mixgar in Volt festival 2011
Mixgar prezi v1.2
Budapest.rb 2011/01 - Rails Deployment
Budapest.rb 201010
Ad

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
Teaching material agriculture food technology
PDF
Machine learning based COVID-19 study performance prediction
PDF
Approach and Philosophy of On baking technology
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Electronic commerce courselecture one. Pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
A Presentation on Artificial Intelligence
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Modernizing your data center with Dell and AMD
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
NewMind AI Weekly Chronicles - August'25 Week I
The Rise and Fall of 3GPP – Time for a Sabbatical?
Teaching material agriculture food technology
Machine learning based COVID-19 study performance prediction
Approach and Philosophy of On baking technology
Understanding_Digital_Forensics_Presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
The AUB Centre for AI in Media Proposal.docx
Unlocking AI with Model Context Protocol (MCP)
Electronic commerce courselecture one. Pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
A Presentation on Artificial Intelligence
CIFDAQ's Market Insight: SEC Turns Pro Crypto
NewMind AI Monthly Chronicles - July 2025
Review of recent advances in non-invasive hemoglobin estimation
Modernizing your data center with Dell and AMD
Per capita expenditure prediction using model stacking based on satellite ima...
Spectral efficient network and resource selection model in 5G networks
NewMind AI Weekly Chronicles - August'25 Week I

Introduction to GraphQL with Ruby