GraphQL vs REST: How One Shopify Partner Increased Performance and Reliability

graphql vs rest

As the Senior Business Process Consultant atFisher Technology, Rich Borek prides himself on staying ahead of the development curve. Paying close attention to trends and looking for a leading edge helps the company business stay competitive, and keeps its clients’ businesses running smoothly.

Founded in 2006, Fisher Technology is the North American Distributor of Codeless Platforms’BPA Platform, a business process automation and integration platform, andApplications Platform, a rapid application development (RAD) platform. As a Shopify Plus Technology Partner, they enable Shopify Plus merchants to integrate with accounting, CRM, and ERP systems and sync their huge databases of customers and products.

In dealing with such massive amounts of data, Rich observed first hand how the growth of Fisher Technology’s clients impacted the calls made to Shopify’s REST Admin API, the API that allows developers to build apps and integrations for the Shopify Admin. Watching that growth accelerate, Rich knew they would catch up to the API’s limits.

“I knew it was coming, I just didn’t know it would be last year,” Rich says with a laugh.

Something had to change. Passionate about ensuring his business and his clients stayed ahead of the curve, he discovered a new opportunity using theGraphQL Admin API. In this article, Rich shares his experience of switching from a REST API to the GraphQL API, and the impact it had on his business and the businesses of his Shopify Plus clients.

Build apps for Shopify merchants

Whether you want to build apps for the Shopify App Store, offer private app development services, or are looking for ways to grow your user base, the Shopify Partner Program will set you up for success. Join for free and access educational resources, developer preview environments, and recurring revenue share opportunities.

Sign up

The limitations of the REST API

For Rich and the rest of the Fisher Technology team, the limitations of the REST Admin API were beginning to chafe. Hitting the limit has consequences—attempting tomake a call while at the limitwill get an HTTP429 Too Many Requestserror. None of the requested data is returned, and the app has to pause before retrying the call. For Rich, this meant that nothing would sync between his ERP integration and his clients’ stores.

“When you hit the limit you’re done. Our systems start failing, alarm bells are going off, and emails are coming in. It’s bad,” Rich warns.

Fisher Technology processes tens of thousands of dollars every day, and having their integration break would cause a delay in syncing inventory or customer data. The resulting discrepancies could cause everything from accounting records being incorrect, to customer service teams lacking insight into purchases. It was bad business, so Rich and his team avoided hitting their API limit at all costs.

The biggest near miss came in 2015. One of their clients operated a store with hundreds of products, each with five images and over a dozen metafields, meaning that just one product accounted for 15 to 18 API calls. This was the first time the team realized they could break the call limit, and it required workarounds to avoid catastrophe.

“I told the customer it would take a couple of days to upload their inventory,” Rich says. “I intentionally delayed my code so that my integration would only make an API call every couple of minutes, allowing time for that API bucket to replenish.”

That smart planning meant they didn’t exceed the call limits, but it was close. And with their growth only continuing, Rich knew they needed a new strategy to deal with the challenges coming over the horizon.

You might also like:How the New GraphQL Admin API Can Help You Manage Inventory and Locations

Reaching the breaking point

So far, Rich’s workarounds had saved them from any major issues, but his improvised solutions wouldn’t work forever. In 2018, a loyal client of seven years approached the team with a big request: usingLiquidto present metafields to the customer. Their client wanted to present buying values and key metrics to customers on the customer screen when they logged in. To do this, they used metafields on the Customer Object and added Liquid tags to the Customer Theme for presentation.

The team knew that to be able to do this project, they would need to get innovative. Rich had always relied on the REST Admin API for these kinds of jobs, but after their near miss a few years ago, it wasn’t going to cut it this time around.

“The metafields were always one to one and it just killed me,” Rich says. “Take five metafields per customer; with 40,000 customers, that’s over 200,000 API calls. This is going to take a week to run! And you want me to report data that’s transactional? That’s impossible.”

Fortunately for Rich, Shopify Unite 2018, ourannual partner and developer conference, was just around the corner. At Shopify Unite 2018, we announced many new and exciting ways developers can useGraphQLin Shopify. Inspired by the talks, Rich was excited to learn more about GraphQL.

GraphQL是那一种查询语言和运行时系统t returns requested data (called queries and mutations) in a single endpoint, instead of exposing different endpoints for each resource object like REST. Instead of over-fetching data, you can build queries that return only the data that you need.

For Rich, this meant he could use the schema to build a query that returned the same data in 40,000 API calls, instead of making 200,000 API calls and breaking his integration. Even though his team had never built an integration this way before, the benefits outweighed the learning curve.

Rich left Shopify Unite with a plan.

You might also like:The Shopify GraphQL Learning Kit.

Pivoting to the GraphQL Admin API

The first step for Rich and his team was to find out if and how the GraphQL Admin API could work as a solution with BPA Platform. As a business that is constantly syncing customer records and inventory, Rich had to first gain an understanding of how exactly the GraphQL Admin API would perform differently to the REST Admin API.

“I wanted to be clear on what the ‘cost’ was, as in what does it cost me to get an order or a metafield?”

Just like any developer learning a new coding language, he needed some help. He leaned on theShopify GraphQL Learning Kit,and third party tools likeInsomniaandPostmanto test the GraphQL API with BPA Platform.

“At a glance, GraphQL looks a lot more complicated than it is, but these tools transformed the way I could work with the Shopify API.”

At a glance, GraphQL looks a lot more complicated than it is, but these tools transformed the way I could work with the Shopify API.

Rich Borek

It was in this learning process that Rich had his eureka moment. He started being able to fetch multiple unrelated types of objects in one request. And with this new knowledge in hand, Rich would soon see the dramatic impact the GraphQL Admin API would have on his integration.

Finding success with the GraphQL Admin API

Now that he had a grasp on working in GraphQL, Rich and his team could easily set up BPA Platform to deliver the integration for their valued client. From the start, it was obvious that GraphQL was having a massive positive impact—the integration worked like a charm, pulling the data from three fields instead of making hundreds of thousands of API calls.

Rich built for his client an integration with call limits that don’t make him sweat. From making 200,000 API calls across 40,000 customer records, the integration built with the GraphQL Admin API was able to get the same request with one API call per customer totaling 40,000 API calls—a five-time improvement. This was possible through GraphQL's ability to make more efficient API calls. Rich was no longer required to stop in-between calls because the GraphQL API call throttling change made it possible for continuous operation until complete.

“I'm only downloading the three fields I need and not getting the whole customer record.”

In order to make sure all changes made in the Shopify Admin match the client’s ERP, BPA Platform has a routine that pushes updates every ten minutes. Once a week, all data is downloaded as a batch and synced across the Shopify Admin and the ERP to ensure nothing was missed. Both the weekly batch download and the routine update happen flawlessly with GraphQL. This solution allows them to perform a full sync of all 40,000 customers in a couple of hours, as opposed to the two or three days it took previously.

You might also like:Determination and Devotion: How Two Entrepreneurs Changed the Ecommerce Industry in Mexico.

How GraphQL has helped the business

Fisher Technology’s success with the GraphQL Admin API hasn’t stopped since their first integration, and their new approach to development has had a huge impact on their business and the service promise they can offer clients. Below are three major areas that GraphQL has impacted.

1. Performance

By switching to the GraphQL Admin API, Fisher Technology can offer faster integrations for their clients. Fisher Technology’s integrations now perform better by syncing customer databases faster between Shopify stores and ERP.

It has impacted the confidence of the team, too. When Rich is asked by clients if an integration can be built, he goes back 30 to 90 days in the client's store and database, views their records and number of orders, then averages this data to get an idea of the volume of data they have to pull.

“My job is to measure in volume,” Rich says. “GraphQL has allowed me to be a little bit more relaxed when I see those massive numbers.”

The increased performance allows his integrations to keep data syncing between a client’s store and their ERP system, no matter the volume.

2. Agility and smaller payloads

By switching to the GraphQL Admin API, Fisher Technology can support bigger clients and spend less time figuring out hacks or tactics to avoid going over the call limits of the REST Admin API.

Previously, Rich had to update customer’s inventory one item at a time, and he would keep an API call running until he hit his limit within a two minute window.

Now, instead of one customer at a time, they bring down hundreds. With the GraphQL Admin API, Rich can update 100 to 500 customer records at once. He’s now trying to push the call limits of GraphQL to find out just how far he can use the tool, and how it can further benefit certain clients.

“每次我打个电话,我的汁液t can’t reach the limit. That’s a beautiful place to be with the clients we’re dealing with. Running our integration on GraphQL, I no longer have to sweat and think about the API loads.”

Running our integration on GraphQL, I no longer have to sweat and think about the API loads.

Rich Borek

3. Changes to the environment are less impactful

As Shopify has grown and evolved over the years, so have the APIs. While updates to the APIs or changes to the platform can leave some developers anxious about how it will affect their apps or integrations, using GraphQL makes Rich less apprehensive that changes to the environment will impact his integration.

“我不知道如何应用程序构建的ground up handle it; to have something introduced or removed, and having to weed through your code to find it. With GraphQL I only need a customer name, email, or phone number—I can query those three fields and every time my code executes I’m only getting those three fields.”

Not only is Rich enjoying the riches of knowing that his team spends less time on rebuilding integrations and hunting for errors in the code, but their solution is far more resilient.

“You can add, update, or increase fields on the customer object and the code will never break, because I’m only asking for those three fields,” he shares.

These improvements add up. Rich is able to use his confidence in the stability of the integrations to increase client trust and retention.

“If a customer sees a new update on Shopify and gets nervous that it will affect their integration, we’re able to give them a yes or no with full confidence.”

You might also like:How Singapore’s Jumpstart Commerce is Taking Over the World.

Fisher Technology’s future with GraphQL

Fisher Technology are now advocates for GraphQL, and they’re looking to push the abilities of integrations built using APIs in GraphQL. They’re talking with some of their clients to get an idea of their dream scenarios and if they can be built, starting with real time updates.

“We want inventory on stores to update as it’s transacted against. We don’t want more than a few minutes’ delay in the time it’s updated in the ERP and in a client’s store,” Rich shares.

Aside from making speed a competitive advantage for their integration partners, they’re also in pursuit of building an integration between stores to make inventory easier for a global client.

“We have a client with separate stores in the US and Canada, and we’re looking at building a huge integration between them using GraphQL. The goal with any integration we build going forward, unless it’s not possible, is to always use GraphQL.”

The goal with any integration we build going forward, unless it’s not possible, is to always use GraphQL.

Rich Borek

Get started with GraphQL

Switching to the GraphQL Admin API has been a three-pronged success for Fisher Technology. It allows them to build more reliable integrations that perform faster for clients, keep customer records synced in a shorter time, and spend less time reacting to platform or API updates.

While the learning curve could seem steep, Rich wishes he did it sooner.

“I would work tirelessly to convince anyone to use it,” he emphasizes. “Just do it. If you’re using REST APIs right now, and dealing with hundreds of orders a day and you only need twenty fields, you’re probably paying a penalty. Or if you’re an app developer building one app for hundreds or thousands of stores, why would you take on that extra burden? Get what you need and only what you need.”

Build apps for Shopify merchants

Whether you want to build apps for the Shopify App Store, offer private app development services, or are looking for ways to grow your user base, the Shopify Partner Program will set you up for success. Join for free and access educational resources, developer preview environments, and recurring revenue share opportunities.

Sign up

Grow your business with the Shopify Partner Program

Learn more