While there’s a lot of content out there that digs into the technical specifics of GraphQL, there’s not much that breaks down the value for us non-technical folks.
So here’s a breakdown of GraphQL for the business user.
The what, why, and how of GraphQL
Decoupling the front-end from the backend unlocks agility and flexibility benefits. But this approach requires APIs to connect the two separate layers. An API – application programming interface – allows the front-end and backend to talk to each other.
REST APIs are commonly used in a headless approach. They provide a set of rules that allow the front-end to make a request, and get a response from the backend system. For example, when a shopper navigates to a product display page (PDP), the front-end would request pricing data from a REST API, which would respond with the latest sale price from the ecommerce platform so that the front-end can display that information on the PDP.
But price is just one of many data points on the PDP, so you would may need multiple REST APIs requests done simultaneously to display the price, description, product name, etc. Doing multiple API calls at once can impact performance, and can create a complex web of logic that’s difficult to scale and maintain long-term.
This is where GraphQL comes in. GraphQL is an alternative to REST APIs that allows the front-end to specify what data it needs via a single request, instead of multiple requests. So in this scenario, the front-end would ask for all “product information” with a single request, the GraphQL layer would determine where to pull the price, description and product name from, and then aggregate that data to send it back to the front-end in one document.
Metaphor: Imagine you’re planning a party. Planning it yourself would be like using REST APIs, you would have to buy the decorations, go get a cake, and hire a DJ. But if you got a party planner, it would be like using a GraphQL layer. You would just tell your party planner you want to throw a party and they would figure out where to get the decorations, cake, and DJ. Much more efficient, right?
The business benefits of GraphQL
GraphQL emerged to help solve some of the limitations associated with REST APIs. As we discussed, REST APIs offer a 1-to-1 relationship between the front-end and backend.
This is fine for a basic ecommerce set-up, but once you start adding different kinds of backend functionality and multiple front-end touchpoints, the requests can slow down performance and the complexity becomes difficult to maintain.
That brings us to the two primary business benefits of GraphQL: performance and maintainability.
GraphQL results in better performance for the end customer because the front-end doesn’t have to make as many requests. Instead, the GraphQL layer makes the parallel requests to the backend systems and delivers that data back to the front-end in a single document. This is faster and more efficient because the GraphQL can perform the complex aggregation of data on more powerful systems – unlike running this on the front-end client, such as your mobile phone with limited bandwidth.
Using GraphQL also guarantees that you won’t have unused data sent to the front-end, which shrinks the payload and the size of the aggregated data being sent back. This is much harder to control with REST APIs.
The benefits from a maintenance standpoint are twofold – GraphQL provides a better employee experience for front-end developers, and increases efficiency for the business. Front-end developers will no longer have to go searching for each individual data point and determine the correct source of truth. Take inventory for example, should that come from the ecommerce platform or the OMS? With GraphQL, the source of truth is baked into the business logic so that the developer doesn’t have to go hunting and possibly end up with the incorrect source.
Not only is this a more pleasant experience for the employee, it’s also a lot more efficient for the business. Because the logic used to call on data sources doesn’t need to be replicated across front-ends, there’s less code to maintain and any changes needed can be made in just one location.
Evaluating GraphQL for your business
While GraphQL is definitely a highly technical solution, its benefits are not limited to the technical team. If performance and maintainability are priorities for your business, then GraphQL is worth exploring. Talk to the team that manages your decoupled storefront (whether that’s internal, a storefront solution provider, or a systems integrator) to discuss the potential upsides of leveraging GraphQL as a part of your ecommerce business.