<?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[KashmereLabs - Medium]]></title>
        <description><![CDATA[KashmereLabs is a dev studio specializing in e-commerce and DLT solutions. - Medium]]></description>
        <link>https://medium.com/kashmerelabs?source=rss----254e151e8ed1---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>KashmereLabs - Medium</title>
            <link>https://medium.com/kashmerelabs?source=rss----254e151e8ed1---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 02:12:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/kashmerelabs" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Problem-Solving with Shopify Admin API — GraphQL vs REST]]></title>
            <link>https://medium.com/kashmerelabs/problem-solving-with-shopify-admin-api-graphql-vs-rest-b5239a67e7f2?source=rss----254e151e8ed1---4</link>
            <guid isPermaLink="false">https://medium.com/p/b5239a67e7f2</guid>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[shopify]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[shopify-development]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[Pritam Roy]]></dc:creator>
            <pubDate>Thu, 24 Jan 2019 15:48:30 GMT</pubDate>
            <atom:updated>2019-01-24T15:48:30.418Z</atom:updated>
            <content:encoded><![CDATA[<h3>Problem-Solving with Shopify Admin API — GraphQL vs REST</h3><h4>Shopify supports GraphQL and REST based integrations for custom app development. Let’s unravel some use-cases for GraphQL and REST so we can make better choices while designing our app without having to make costly code changes further down the lifecycle</h4><h3>GraphQL in context</h3><p>In a typical app-dev scenario, where you are the one building the API and the client, you can design your endpoints exactly tailored to functionality that your client exposes… but when developing clients for third-party platforms like Shopify, the API endpoints exposed to you as an app-developer tend to be generic and your client may need more or fewer data points than what the API exposes. This leads to inefficiencies and wasteful chaining.</p><p>GraphQL is designed to solve some of the inefficiencies of REST related to data over fetching and under fetching by minimizing the data that needs to be transferred over the network.<br><strong>In a nutshell, the motto of GraphQL is don’t waste bandwidth and don’t fetch more data than you need…</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*odaQWYEB4z-epp13o4sJ7A.png" /></figure><p>GraphQL is the sniper rifle of data operations and anyone who has used one or has played ghost warrior will tell you that sniper rifles do serve a purpose but sometimes what you need is a chaingun. So let’s examine some use-cases in Shopify admin and efficiency of GraphQL vis-a-vis REST and requests where each is suitable.</p><h3>Comparing efficiency and costs —</h3><p>GraphQL provides you with constructs to reduce the round-trips and chaining for some requests. It is however not just the speed that you can optimize for, Rate-limits work differently in GraphQL and REST API. While rate limits in Admin API are tied to the number of requests you make in a given time-period, rate-limits in Shopify GraphQL are tied to the costs of each request that you make and governed by the Leaky-bucket algorithm, so by optimizing for the kind of request you can potentially make more requests without hitting individual rate limits. To see how rate limits work in GraphQL check out this documentation link here.</p><p>For instance, a request to <strong>duplicate a product</strong> in REST would be a two-step operation.</p><ol><li>Fetch the product to be duplicated.<br>Edit the fields to be updated.</li><li>Post the new product description.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22be71a79f44a909d263f35ec0c17be1/href">https://medium.com/media/22be71a79f44a909d263f35ec0c17be1/href</a></iframe><p>In GraphQL it would instead be a single step operation using the DuplicateProduct mutation</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4eb9d74187832f4a03a6c47f0303829e/href">https://medium.com/media/4eb9d74187832f4a03a6c47f0303829e/href</a></iframe><p>As is evident, for most chained request queries, a GraphQL equivalent will reduce the number of roundtrips and save network bandwidth and unlike the REST equivalent will not hit API limits.</p><h4>So where does it make sense to use the REST API instead?</h4><p>In a situation where a single atomic REST request can be used to achieve the desired functionality, such as in bulk query/update operations, fetch count operations, that operate on the entire set and no delimiter or cursor needs to be specified.</p><p>For instance, a query to <strong>get all products in a store</strong> would require only one REST call without needing any knowledge of the exact number of products in the store, whereas the GraphQL implementation would require you to get n products and then loop over the cursor until you get to the end of the list. The alternative would be to pick an upper estimate of products which would reserve a bigger bucket cost than what you need, and estimating an upper-bound that is too high may hamper your ability to make further queries in quick succession.</p><p>Shopify supports a simple REST endpoint that allows you to fetch all products in the store without needing to know the number of products beforehand.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e444f6260061263f61cc7e56ab52b02/href">https://medium.com/media/1e444f6260061263f61cc7e56ab52b02/href</a></iframe><p>The graph API equivalent requires you to either fetch first n products and then iterate over the cursor until you reach the end or alternatively estimate an upper bound of products n and fetch the first n products. For instance, if you knew that the number of products in your store is less than an upper bound N, you could use the following query to fetch all the products in your store.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0402c5d1f82821b454dad472a70aa56/href">https://medium.com/media/c0402c5d1f82821b454dad472a70aa56/href</a></iframe><p>The problem with this approach is that you reserve a bucket capacity of n (900 in this case) even though the actual number of products may be less than 900. This hinders your ability to make future GraphQL requests until the current request returns and the extra allocated space is released.</p><h3>Better choices made earlier makes you more productive</h3><p>When designing a new app, we usually work on an exploratory approach, we try something if it doesn’t work we try something else. The problem with rate-limits and scalability of queries, however, is that they often don’t manifest until you have shipped and start seeing a growing number of users. Then fixing scalability bugs becomes more like debugging a space-shuttle mid-flight. Some general guidelines when designing an application query layer —</p><ol><li>If you want to fetch all items of a type and the server provides an endpoint that supports it, it’s better to use the REST endpoint than page through Graphql cursors.</li><li>If there is a straightforward endpoint that allows you to achieve the desired outcome use REST.</li><li>If you find yourself chaining a bunch of requests, it may be better to design a GraphQL solution.</li><li>If the app is targeted towards bandwidth-constrained users such as those using phones and smart-watches, you should design GraphQL solutions as reducing network round-trips is a feature that may make or break your app.</li></ol><p>The performance of GraphQL queries depends on several factors, not just how the query is constructed but also the GraphQL middleware is implemented. A GraphQL middleware which fetches from a graph database is likely to be more performant than one that does a join internally and exposes a graph API to the client.</p><p>GraphQL provides you with stronger constructs that natively allow you to query and mutate complex data types without chaining network requests. REST APIs provide standard solutions to the most common data queries and mutations. A performant app uses both REST and GraphQL in places where it shines and Shopify support for both standards means that apps can support complex use-cases and be fast at the same time by judiciously applying the two standards where they are needed the most.</p><p>If you found the above writeup useful, there are 50 ways (claps) to show your appreciation. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5239a67e7f2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kashmerelabs/problem-solving-with-shopify-admin-api-graphql-vs-rest-b5239a67e7f2">Problem-Solving with Shopify Admin API — GraphQL vs REST</a> was originally published in <a href="https://medium.com/kashmerelabs">KashmereLabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>