REST vs GraphQL Awareness with Express
📖 Scenario: You are building a simple Express server to understand the difference between REST and GraphQL APIs. This will help you see how data can be requested and served in two different ways.
🎯 Goal: Create an Express server that has one REST endpoint and one GraphQL endpoint. The REST endpoint will return a list of books, and the GraphQL endpoint will allow querying the same books with flexible fields.
📋 What You'll Learn
Create an array called
books with 3 book objects, each having id, title, and author propertiesCreate a variable called
port set to 4000Create a REST GET endpoint at
/books that returns the books array as JSONSet up a GraphQL schema with a
Book type and a books query that returns the list of books💡 Why This Matters
🌍 Real World
APIs are how apps talk to each other. REST and GraphQL are two popular ways to build APIs. Understanding both helps you choose the right tool for your project.
💼 Career
Many jobs require building or working with APIs. Knowing REST and GraphQL basics is essential for backend and full-stack developers.
Progress0 / 4 steps