<?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 V Sirimalla on Medium]]></title>
        <description><![CDATA[Stories by V Sirimalla on Medium]]></description>
        <link>https://medium.com/@v.sirimalla?source=rss-58a513cd61a8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jGr-hBSLrJ6segx3J78X8A.jpeg</url>
            <title>Stories by V Sirimalla on Medium</title>
            <link>https://medium.com/@v.sirimalla?source=rss-58a513cd61a8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 10:41:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@v.sirimalla/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: Why Does GraphQL Exist?]]></title>
            <link>https://medium.com/@v.sirimalla/rest-vs-graphql-why-does-graphql-exist-911cb0431af1?source=rss-58a513cd61a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/911cb0431af1</guid>
            <category><![CDATA[rest-api-design]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[V Sirimalla]]></dc:creator>
            <pubDate>Sat, 21 Nov 2026 14:10:22 GMT</pubDate>
            <atom:updated>2026-11-21T14:10:22.546Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern applications need to communicate with servers to fetch, create, update and delete data.</p><p>Imagine building a developer community application where users can explore events, register for meetups, view speaker profiles and interact with other developers.</p><p>The frontend needs data from different resources, such as users, events, speakers and registrations.</p><p>REST APIs have traditionally been a popular way to handle this communication. However, as applications became more complex, developers started facing a few challenges when fetching data.</p><p>Two common problems are:</p><ul><li><strong>Over-fetching:</strong> Receiving more data than the application actually needs.</li><li><strong>Under-fetching:</strong> Having to make multiple API requests to collect all the data required by a screen.</li></ul><p>This is where GraphQL comes into the picture.</p><p>GraphQL was developed internally at Facebook in 2012 and publicly open-sourced in 2015. It introduced a different approach to fetching data by allowing clients to specify exactly which fields they need.</p><p>But before understanding GraphQL, let’s look at how REST works.</p><h3>How REST APIs Work</h3><p>REST stands for Representational State Transfer. It is an architectural style used for designing APIs that communicate over HTTP.</p><p>In REST, data is generally organised around resources, and each resource is accessed through a URL (endpoint).</p><p>Let’s say our frontend needs to display a user’s profile.</p><p>It sends a request:</p><pre>GET /users/1</pre><p>The server might return:</p><pre>{<br>  &quot;id&quot;: 1,<br>  &quot;name&quot;: &quot;Vaishali&quot;,<br>  &quot;email&quot;: &quot;vaishali@example.com&quot;,<br>  &quot;phone&quot;: &quot;9876543210&quot;,<br>  &quot;address&quot;: &quot;Mumbai&quot;<br>}</pre><p>The frontend receives this response and uses the required information to display the profile.</p><p>This approach is straightforward and works well for many applications.</p><p>However, things can get a little complicated when the frontend needs different combinations of related data.</p><h3>What Are Over-fetching and Under-fetching?</h3><p>Let’s understand these two problems using the same example.</p><h3>Over-fetching</h3><p>Over-fetching happens when an API returns more data than the client actually needs.</p><p>Imagine our profile card only displays the user’s name.</p><p>However, the REST API returns:</p><pre>{<br>  &quot;id&quot;: 1,<br>  &quot;name&quot;: &quot;Vaishali&quot;,<br>  &quot;email&quot;: &quot;vaishali@example.com&quot;,<br>  &quot;phone&quot;: &quot;9876543210&quot;,<br>  &quot;address&quot;: &quot;Mumbai&quot;,<br>  &quot;createdAt&quot;: &quot;2026-01-10&quot;<br>}</pre><p>Our UI only needs:</p><pre>{<br>  &quot;name&quot;: &quot;Vaishali&quot;<br>}</pre><p>We receive several additional fields that our UI doesn’t even use.</p><p>This is called over-fetching.</p><h3>Under-fetching</h3><p>Under-fetching happens when a single API request doesn’t provide all the data required by the frontend.</p><p>Imagine our profile page needs:</p><ul><li>User name</li><li>User email</li><li>Registered event names</li><li>Event dates</li></ul><p>We first request:</p><pre>GET /users/1</pre><p>The response contains:</p><pre>{<br>  &quot;id&quot;: 1,<br>  &quot;name&quot;: &quot;Vaishali&quot;,<br>  &quot;email&quot;: &quot;vaishali@example.com&quot;<br>}</pre><p>But where are the registered events?</p><p>We need another request:</p><pre>GET /users/1/events</pre><p>Now we’re making multiple requests just to collect the information needed for one screen.</p><p>This is an example of under-fetching.</p><p><strong>Note:</strong> These are common possibilities with REST APIs, not unavoidable limitations. REST endpoints can also be designed to return related data together or support field selection.</p><h3>How Does GraphQL Approach Data Fetching Differently?</h3><p>GraphQL is a query language for APIs and a runtime for fulfilling those queries with data.</p><p>Unlike traditional REST API designs, GraphQL allows the client to specify exactly which fields it needs.</p><p>Let’s take our previous example.</p><p>We want to display:</p><ul><li>User name</li><li>User email</li><li>Registered event names</li><li>Event dates</li></ul><p>With GraphQL, we can write a single query:</p><pre>query {<br>  user(id: &quot;1&quot;) {<br>    name<br>    email<br>    events {<br>      eventName<br>      date<br>    }<br>  }<br>}</pre><p>The server can return:</p><pre>{<br>  &quot;data&quot;: {<br>    &quot;user&quot;: {<br>      &quot;name&quot;: &quot;Vaishali&quot;,<br>      &quot;email&quot;: &quot;vaishali@example.com&quot;,<br>      &quot;events&quot;: [<br>        {<br>          &quot;eventName&quot;: &quot;React Meetup&quot;,<br>          &quot;date&quot;: &quot;2026-12-10&quot;<br>        },<br>        {<br>          &quot;eventName&quot;: &quot;GraphQL Workshop&quot;,<br>          &quot;date&quot;: &quot;2026-12-15&quot;<br>        }<br>      ]<br>    }<br>  }<br>}</pre><p>Notice something interesting?</p><p>We requested only the fields we needed, and the response follows the structure of our query.</p><p>We also didn’t need to make separate frontend requests for the user and their events.</p><p>That’s one of the main advantages of GraphQL: <strong>the client gets more control over the shape of the response.</strong></p><p>One important thing to understand is that a single GraphQL request doesn’t necessarily mean a single database query.</p><p>Behind the scenes, the server might still fetch information from multiple tables, databases or other data sources to prepare the response.</p><p>GraphQL doesn’t require a completely different database structure either. It works as a layer between the client and the underlying data sources.</p><p>We’ll explore how this actually works in the next blog.</p><h3>REST vs GraphQL: A Practical Comparison</h3><p>Let’s quickly compare both approaches.</p><p>FeatureRESTGraphQLAPI structureResource-based endpointsCommonly a single endpointData fetchingResponse generally defined by the endpointClient specifies requested fieldsOver-fetchingCan occurReduced through field selectionUnder-fetchingMay require multiple requestsRelated data can be requested togetherResponse structureDefined by the server endpointFollows the requested query structureCachingWell-supported HTTP cachingRequires additional caching strategiesVersioningOften uses URL versioningCan evolve through schema changes</p><p>Neither approach is perfect for every situation.</p><p>GraphQL also introduces challenges, such as query complexity, caching, authorization and the N+1 problem.</p><p>Choosing between them depends on the application’s requirements.</p><h3>When Should You Use GraphQL or REST?</h3><p><strong>GraphQL can be useful when:</strong></p><ul><li>An application has complex relationships between data.</li><li>Different screens require different combinations of fields.</li><li>Multiple clients, such as web and mobile applications, consume the same API.</li><li>Developers need more flexibility when fetching data.</li></ul><p>For example, our developer community platform might have different screens for users, event organisers and speakers. Each screen needs a different combination of related data.</p><p>GraphQL can make handling these requirements easier.</p><p><strong>REST can be a better choice when:</strong></p><ul><li>The application has simple CRUD operations.</li><li>Resources have straightforward endpoint structures.</li><li>Standard HTTP caching is important.</li><li>The team already has a well-established REST architecture.</li></ul><p>For example, a simple blog application with endpoints to retrieve posts, create posts and delete posts might not need the additional complexity of GraphQL.</p><p>Sometimes, keeping things simple is the best architectural decision.</p><h3>What I Learned</h3><p>While exploring REST and GraphQL, one thing that stood out to me was that GraphQL isn’t about replacing REST everywhere.</p><p>Both approaches solve the problem of communication between applications and servers, but they approach data fetching differently.</p><p>REST structures API access around resources and endpoints, whereas GraphQL allows clients to describe the data they need through queries.</p><p>I also learned that making one GraphQL request doesn’t necessarily mean executing just one database query.</p><p>This was my first step in exploring GraphQL beyond just writing queries and mutations.</p><p>There’s still a lot more to learn, and I’m excited to experiment with implementations and contribute to the open-source ecosystem.</p><p>In the next blog, I’ll explore the building blocks of GraphQL, including:</p><ul><li>Schema design and GraphQL types</li><li>Queries and mutations</li><li>Resolvers and context</li><li>The N+1 problem and why it matters for GraphQL performance</li></ul><p><strong>Part of my Exploring GraphQL learning journey.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=911cb0431af1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>