Shopify is going to stop supporting REST architecture for building APIs. Instead, they entirely switch to GraphQL and urge Shopify users to update their apps and integrations. What’s the difference between these API designs, and how can you migrate smoothly from REST API to GraphQL? This article gets you covered.
Shopify API update
Shopify has designated the REST Admin API as a legacy API as of October 1, 2024, and recommends that all apps and integrations transition to the GraphQL Admin API.
Shopify is deprecating the REST API, and Starting April 1, 2025, all new custom and public apps will default to GraphQL. In other words, after this date, you will be only permitted to use GraphQL for new integrations. And if you are about to add a public app to the Shopify Store, it will only be submitted if you use GraphQL.
Regarding existing apps, Shopify will announce migration timelines in 2025. However, we recommend preparing for new Shopify API requirements beforehand to ensure a smooth transition.
Why Shopify deprecates REST API and switch to GraphQL
REST is an architectural style developed in the early 2000s for building web services that interact via an HTTP protocol. GraphQL is an open-source query language developed by Facebook in 2012 to optimize data fetching.
REST and GraphQL are two different approaches to building APIs. While REST API is convenient for simple data models, more complex data models with nested relationships require GraphQL.
Shopify started experimenting with GraphQL in 2015 to create a new generation of APIs, including Shopify Admin and Storefront APIs, to enhance the mobile experience for merchants.
Why did Shopify decide to switch to GraphQL entirely?
-
Efficient data access: Unlike REST API, GraphQL allows the query and manipulation of data across multiple parts of the platform within a single request.
-
Optimized data retrieval: GraphQL helps reduce the number of requests and the amount of transferred data since it allows you to specify precisely what data you need in a single query.
-
Better code quality: Strongly typed GraphQL schema enables developers to understand what data is available and how to interact with it, which leads to fewer runtime errors.
-
Advanced tools: Such tools as GraphiQL help easily explore and test queries and mutations.
-
Self-documenting: GraphQL doesn’t require documenting your API. Instead, developers use built-in schema descriptions to explain fields of their code.
After ten years of experimenting and developing GraphQL APIs, the Shopify team created solutions that fully cover and exceed REST functionality.
How to ensure migrating from REST to GraphQL?
To convert the existing REST API to GraphQL by yourself, you first need to explore GraphQL resources and operations and then proceed with the transition. If you want to speed up the migration, we recommend contacting Shopify developers for a smooth transition.
Where should you start if you still want to migrate on your own?
-
Explore GraphQL basic and advanced concepts, such as building and using GraphQL queries and mutations.
-
Familiarize yourself with how to use GraphQL in the context of Shopify Admin API.
Once you have gained some experience using GraphQL, start the migration process.
Find GraphQL objects and operations
Many REST Admin API resources and endpoints have direct equivalents in GraphQL. GET, POST, PUT, and DELETE requests for retrieving, creating, updating, and deleting data have equivalent GraphQL mutations and queries. However, some REST operations lack an exact GraphQL equivalent, and functionality included in one POST or PUT operation may require other GraphQL mutations. To identify which mutation to use in your case, explore GraphQL Admin API reference and use the GraphiQL explorer to build and validate GraphQL queries.
Find the required access scope
Once you’ve found a GraphQL equivalent, you need to make sure you have appropriate access scopes to work with the object and associated mutations and queries. You can define access scopes at the top of the page for each type in the GraphQL Admin API reference. Use the appInstallation query in the GraphQL Admin API to check the scopes of granted access for your app.
Translate IDs from REST to GraphQL
REST and GraphQL use different formats for resources and object IDs. If you use stored IDs to retrieve resources in the REST Admin API, then you need to retrieve GraphQL equivalent global ID (GID) before running corresponding GraphQL queries and mutations. See some examples of GraphQL GIDs.
Implement and update pagination
To paginate data in REST, you need to use query parameters like a limit to split the total number of entries into some groups. To apply a similar concept in GraphQL, you can use cursor-based pagination. The equivalent to the limit parameter is the first or last argument that specifies the number of items you want to return from the beginning or the end of the data set. Learn more about cursor-based pagination.
Handle errors
In GraphQL, you can’t rely entirely on HTTP status codes since, in cases that produce 4xx or 5xx errors in REST, GraphQL may return 200 OK status with additional error information. You can find the possible response codes and their meaning here. If an error occurs, the response includes information that can help debug your operation.
Follow rate limits
REST and GraphQL use different rate-limiting approaches. REST uses request-based limits, while GraphQL utilizes a calculated cost query method, where clients receive from 50 to up to 1,000 points per second. The main difference from REST here is that every GraphQL request has a different cost. The easiest way to check the cost of a query or mutation is to run it and get a JSON response with the information about the query cost and your current quota. If your app reaches the limit, you receive a 200 OK response with an error message that a throttle is applied.
Optimize requests
To improve your app performance and reduce the number of calls without exceeding the limits, you can further optimize your GraphQL requests by combining multiple requests into a single query, requesting only the data you need, and using bulk operations for importing or exporting large volumes of data.
Check libraries support
Many API libraries you might have used to call the Shopify Admin API, such as official Shopify libraries like shopify-api-js and Axios, support REST and GraphQL.
However, you need to update your code that references these libraries.
- Switch from REST to GraphQL client
- Change the API endpoint
- Update the request type
- Add your query or mutation and specify the fields to return
- Destruct or dig into the response
Check this page for information on how to update your API calls.
Follow the Shopify migrations guide to learn more about migration from Shopify REST to GraphQL and see the details for specific use cases. If this process seems too challenging, contact a certified Shopify Partner – DigitalSuits. Our specialists are familiar with all aspects of GraphQL and Shopify infrastructure, so you will get updated much faster and more efficiently than you would do it yourself.
How to convert REST API to GraphQL with a Shopify Partner?
Send us a brief request by using this form. We’ll contact you for an interview to get detailed information about your project, its current status, and necessary changes. Once we approve the scope of work, we start the migration process without delays. If you have questions other than GraphQL, we can assist you with any development solutions. We’ll help you edit your code and keep it in line with the newest Shopify requirements for high project performance.
Developers tools and resources we leverage for migrating from REST to GraphQL
DigitalSuits Shopify developers have in-depth knowledge of REST API and GraphQL, as well as the Shopify ecosystem, which helps us solve even the most complex and non-standard problems.
Here are some tools we use to migrate Shopify apps from REST to GraphQL.
- Libraries supported by Shopify for GraphQL
- GraphQL Admin API reference
- GraphiQL for the Admin API
- Shopify GraphiQL App
We also apply best GraphQL practices, including cursor-based pagination, detecting and recovering errors, running bulk operations, using Global IDs, and optimizing requests. Our specialists leverage GraphQL variables to write reusable requests and inline fragments for multi-query requests.
Conclusions
To sum up the information above, let’s recap the main statements of this article.
-
Shopify is fully deprecating the REST and moving to GraphQL APIs.
-
Starting April 1, 2025, you must use GraphQL for all new custom and public apps.
-
Migration timelines for existing apps will be announced in 2025.
-
To migrate from REST to GraphQL by yourself, you should familiarize yourself with the GraphQL concepts and techniques.
-
To start migrations, find GraphQL equivalents for your REST objects and operations and define application access scopes.
-
Translating IDs from REST to GraphQL is the next migration step.
-
Implement pagination using GraphQL cursor-based pagination principles.
-
Learn GraphQL response codes and their meaning for handling errors.
-
Find out Shopify API rate limits and query costs to not be throttled.
-
Optimize requests by leveraging best practices such as combining multiple requests into a single query, bulk operations, and requesting only data that you need.
-
Update your code that references libraries by switching to GraphQL client, changing the API endpoint, and more.
-
To speed up the migration process and ensure high code quality, collaborate with certified Shopify developers with hands-on experience migrating from REST to GraphQL.
Ready to migrate right now? Contact our team for more information and consultation.
Frequently asked questions
How long does it take to migrate from REST to GraphQL API?
It depends on your app or integration complexity. Contact us to estimate your migration timelines.
How much faster is GraphQL than REST?
GraphQL queries are not faster than REST ones; however, adopting GraphQL allows speed up the development cycle since developers can find errors faster, use a single endpoint, and create a single query for multiple resources.
What tooling and libraries are available to work with GraphQL in Shopify?
Shopify supports multiple libraries for working with Shopify Admin API, such as libraries for Remix, Node.js, PHP, Python, Ruby, Go, and Net languages.
Was this helpful?
0
No comments yet