Course 37 - Building Web Apps with Ruby On Rails | Episode 18:Navigating GraphQL and the Graphiti Middle Ground
In this lesson, you’ll learn about: REST limitations, GraphQL fundamentals, and the hybrid approach with Graphiti1. The Problem with REST APIsUsing REST:🔹 Key limitations:
Overfetching
Client receives more data than needed
Underfetching
Requires multiple requests to get all data
No strict typing
Errors happen at runtime
Heavy reliance on documentation
👉 Key Insight REST is simple and scalable—but not always efficient2. Example of Overfetching🔹 Request:GET /users/1 🔹 Response:{ "id": 1, "name": "John", "email": "[email protected]", "address": "...", "preferences": "...", "settings": "..." } 👉 Problem:
Client may only need name
👉 Key Insight REST responses are fixed by the server, not flexible for clients3. Introducing GraphQLUsing GraphQL:🔹 What it solves:
👉 Key Insight GraphQL flexibility comes with added complexity8. Introducing Graphiti (Hybrid Approach)Using Graphiti:🔹 Goal:
Combine REST simplicity + GraphQL flexibility
🔹 Features:
Filtering
Sorting
Including relationships
👉 Key Insight Graphiti gives you flexibility without abandoning REST9. Graphiti Resources🔹 Concept:
Define API behavior using “Resources”
🔹 Example:class UserResource < ApplicationResource attribute :name, :string end 👉 Key Insight Resources act like a structured API layer10. REST vs GraphQL vs Graphiti🔹 REST:
Simple
Fast
Limited flexibility
🔹 GraphQL:
Flexible
Precise data fetching
More complex
🔹 Graphiti:
Balanced approach
Keeps HTTP benefits
Adds flexibility
👉 Key Insight There is no perfect solution—only trade-offs11. When to Use Each🔹 Use REST:
Simple APIs
Standard CRUD apps
🔹 Use GraphQL:
Complex frontend needs
Multiple data sources
🔹 Use Graphiti:
Want flexibility + REST structure
👉 Key Insight Choose based on project complexity and team needsKey Takeaways
REST suffers from overfetching and lack of typing
GraphQL provides flexible, precise queries
GraphQL introduces complexity and trade-offs
Graphiti offers a middle-ground solution
API design is about balancing performance, flexibility, and simplicity
You can listen and download our episodes for free on more than 10 different platforms: https://linktr.ee/cybercode_academy
Course 37 - Building Web Apps with Ruby On Rails | Episode 18:Navigating GraphQL and the Graphiti Middle Ground
In this lesson, you’ll learn about: REST limitations, GraphQL fundamentals, and the hybrid approach with Graphiti1. The Problem with REST APIsUsing REST:🔹 Key limitations:
Overfetching
Client receives more data than needed
Underfetching
Requires multiple requests to get all data
No strict typing
Errors happen at runtime
Heavy reliance on documentation
👉 Key Insight REST is simple and scalable—but not always efficient2. Example of Overfetching🔹 Request:GET /users/1 🔹 Response:{ "id": 1, "name": "John", "email": "[email protected]", "address": "...", "preferences": "...", "settings": "..." } 👉 Problem:
Client may only need name
👉 Key Insight REST responses are fixed by the server, not flexible for clients3. Introducing GraphQLUsing GraphQL:🔹 What it solves:
👉 Key Insight GraphQL flexibility comes with added complexity8. Introducing Graphiti (Hybrid Approach)Using Graphiti:🔹 Goal:
Combine REST simplicity + GraphQL flexibility
🔹 Features:
Filtering
Sorting
Including relationships
👉 Key Insight Graphiti gives you flexibility without abandoning REST9. Graphiti Resources🔹 Concept:
Define API behavior using “Resources”
🔹 Example:class UserResource < ApplicationResource attribute :name, :string end 👉 Key Insight Resources act like a structured API layer10. REST vs GraphQL vs Graphiti🔹 REST:
Simple
Fast
Limited flexibility
🔹 GraphQL:
Flexible
Precise data fetching
More complex
🔹 Graphiti:
Balanced approach
Keeps HTTP benefits
Adds flexibility
👉 Key Insight There is no perfect solution—only trade-offs11. When to Use Each🔹 Use REST:
Simple APIs
Standard CRUD apps
🔹 Use GraphQL:
Complex frontend needs
Multiple data sources
🔹 Use Graphiti:
Want flexibility + REST structure
👉 Key Insight Choose based on project complexity and team needsKey Takeaways
REST suffers from overfetching and lack of typing
GraphQL provides flexible, precise queries
GraphQL introduces complexity and trade-offs
Graphiti offers a middle-ground solution
API design is about balancing performance, flexibility, and simplicity
You can listen and download our episodes for free on more than 10 different platforms: https://linktr.ee/cybercode_academy