<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chethan G on Medium]]></title>
        <description><![CDATA[Stories by Chethan G on Medium]]></description>
        <link>https://medium.com/@gchethan7602?source=rss-7ce778a9618f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*j77ciIwb1KMDBVd4</url>
            <title>Stories by Chethan G on Medium</title>
            <link>https://medium.com/@gchethan7602?source=rss-7ce778a9618f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 21:21:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gchethan7602/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[REST vs GraphQL: Choosing the Right API for Your Project]]></title>
            <link>https://medium.com/@gchethan7602/rest-vs-graphql-choosing-the-right-api-for-your-project-cd7b81fdd774?source=rss-7ce778a9618f------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd7b81fdd774</guid>
            <dc:creator><![CDATA[Chethan G]]></dc:creator>
            <pubDate>Sat, 28 Jun 2025 02:31:07 GMT</pubDate>
            <atom:updated>2025-07-01T07:27:42.574Z</atom:updated>
            <content:encoded><![CDATA[<h4>Struggling with too many endpoints and rigid APIs? Let’s explore how GraphQL might help.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eGe5rNLirqLvUyQ7QwTyOg.jpeg" /></figure><h3>Introduction: Too Many Endpoints, Not Enough Time</h3><p>When I started working with APIs, I’ve often found myself asking a simple question:<br> <strong>“Why do we need to create a new endpoint for every new requirement?”</strong></p><p>Let’s say the frontend team suddenly needs just a list of item names. Then, the dashboard team needs the same data, but with some extra fields. Before you know it, you’ve got a jungle of endpoints like:</p><ul><li>/items</li><li>/items/summary</li><li>/items/details</li><li>/items/for-dashboard</li></ul><p>Each one doing something slightly different, but built from the same data source.</p><p>This process can get <strong>frustrating</strong>, <strong>time-consuming</strong>, and worse — <strong>hard to maintain</strong>.<br>Wouldn’t it be nice if the client could just ask for what it needs — no more, no less?</p><p>That’s where REST and GraphQL come into the picture. In this blog, we’ll explore both approaches and walk through a real-world example to help you decide which one fits your needs best.</p><h4>A Quick Overview of REST</h4><p>REST (Representational State Transfer) is a popular architectural style for building APIs. It uses standard HTTP methods (GET, POST, PUT, DELETE) to manage <strong>resources</strong> via <strong>endpoints</strong>.</p><p>Typical REST examples look like:</p><ul><li>GET /users/123</li><li>POST /orders</li><li>PUT /products/456</li></ul><p>While REST is widely used and easy to understand, it often leads to over-fetching or under-fetching data. To handle different use cases, developers are forced to create <strong>multiple variations of endpoints</strong> — which bloats the API and increases maintenance overhead.</p><p>Also, REST tends to make services and responses <strong>tightly coupled</strong>. If a frontend needs some specific fields, we must modify the API response or create a new endpoint. This tight coupling means both sides (client and server) have to change in sync — which reduces flexibility and slows development.</p><h4>A Quick Overview of GraphQL</h4><p>GraphQL is a query language and runtime for APIs, developed by Facebook (now Meta). The core idea is simple:<br><strong>The client asks for exactly what it needs, and the server responds with just that.</strong></p><p>Here’s a small GraphQL example:</p><pre>query {<br>  user(id: &quot;123&quot;) {<br>    name<br>    email<br>    profilePicture<br>  }<br>}</pre><p>Only one endpoint — /graphql — but infinite flexibility.</p><p>GraphQL APIs are <strong>strongly typed</strong>, introspectable (you can query the schema itself), and great for evolving requirements without constantly changing the backend.</p><h4>Use Case: Inventory Service Example</h4><p>Now, let me try to explain how REST and GraphQL work with an example.</p><p>Let’s say we have an Inventory Service with the following data:</p><pre>{<br>  &quot;id&quot;: &quot;item123&quot;,<br>  &quot;name&quot;: &quot;Wireless Mouse&quot;,<br>  &quot;description&quot;: &quot;Ergonomic wireless mouse&quot;,<br>  &quot;price&quot;: 699,<br>  &quot;availableStock&quot;: 45,<br>  &quot;warehouseLocation&quot;: &quot;Aisle 3&quot;,<br>  &quot;vendor&quot;: {<br>    &quot;name&quot;: &quot;TechSupply Co.&quot;,<br>    &quot;email&quot;: &quot;support@techsupply.com&quot;<br>  }<br>},<br>{<br>  &quot;id&quot;: &quot;item345&quot;,<br>  ...<br>}</pre><p>We have three client services:</p><ul><li>Catalogue Servic<strong>e</strong> → Needs name and price</li><li><strong>Warehouse Service </strong>→ Needs warehouseLocation and availableStock</li><li>Sales Service → Needs name, price, vendor.name, availableStock</li></ul><h4>Doing It with REST</h4><p>With REST, we either:</p><ol><li>Create <strong>multiple endpoints</strong> for each service:</li></ol><ul><li>/inventory/catalogue/:id</li><li>/inventory/warehouse/:id</li><li>/inventory/sales/:id</li></ul><p>2. Or send the <strong>entire payload</strong> and let the client filter what it needs — which wastes bandwidth and reveals more data than necessary.</p><p>REST forces us to define <strong>how</strong> the response should look <strong>on the server side</strong> for each consumer. This leads to <strong>tight coupling</strong> — if the frontend team wants one more field, the backend has to modify the existing endpoint or create a new one.</p><p>This slows teams down and makes versioning difficult.</p><h4>Doing It with GraphQL</h4><p>With GraphQL, there’s only <strong>one endpoint</strong>, and the client decides what to fetch.</p><p><strong>Catalogue Service Query:</strong></p><pre>query {<br>  inventory(id: &quot;item123&quot;) {<br>    name<br>    price<br>  }<br>}</pre><p><strong>Warehouse Service Query:</strong></p><pre>query {<br>  inventory(id: &quot;item123&quot;) {<br>    warehouseLocation<br>    availableStock<br>  }<br>}</pre><p><strong>Sales Service Query:</strong></p><pre>query {<br>  inventory(id: &quot;item123&quot;) {<br>    name<br>    price<br>    availableStock<br>    vendor {<br>      name<br>    }<br>  }<br>}</pre><ul><li>No over-fetching</li><li>No new endpoints</li><li>No tight coupling — clients control what they want</li><li>One schema evolves with all consumers</li></ul><p><strong>Feature Comparison</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kokDpefMfQSAWT2kFyUDpg.png" /><figcaption>A Developer-Friendly Look at REST vs. GraphQL</figcaption></figure><h4>Summary</h4><ul><li>REST is a great choice for simpler, stable APIs with predictable responses.</li><li>GraphQL shines when you have <strong>multiple consumers</strong> needing <strong>different slices of data</strong> from the same source.</li><li>REST can become <strong>tightly coupled and bloated</strong> with endpoints as your needs evolve.</li><li>GraphQL offers <strong>more flexibility, better developer experience</strong>, and easier frontend-backend collaboration.</li></ul><h4>Conclusion</h4><p>If you’re tired of creating yet another endpoint every time the frontend changes — maybe it’s time to explore GraphQL.<br>It doesn’t replace REST in all cases, but when used right, it can significantly reduce complexity and improve your workflow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd7b81fdd774" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>