VOOZH about

URL: https://thenewstack.io/rest-vs-graphql-solving-api-challenges-in-modern-data-transfers/

⇱ REST vs. GraphQL: Solving API Challenges in Modern Data Transfers - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2024-10-24 10:00:45
REST vs. GraphQL: Solving API Challenges in Modern Data Transfers
contributed,
API Management / Backend development / Data

REST vs. GraphQL: Solving API Challenges in Modern Data Transfers

While REST has been the go-to for many APIs, GraphQL shines in scenarios requiring dynamic, complex data transfers across multiple sources.
Oct 24th, 2024 10:00am by Pete Crocker
👁 Featued image for: REST vs. GraphQL: Solving API Challenges in Modern Data Transfers
Photo by AltumCode on Unsplash.

GraphQL is a relatively new method for creating APIs that offers advantages in efficiency, error handling, and backward compatibility compared to REST. GraphQL provides a great alternative to REST in use cases where the need to deal with complexity in data exchanges outstrips the need for simplicity in the API.

I had my first significant touchpoints with GraphQL when working on the Infrahub project from OpsMill. In context, Infrahub is open source infrastructure automation software that includes novel ways of combining diverse data (asset management, configuration management data, etc.) into a single schema to abstract service definitions for whatever IT or OT infrastructure you want.

For example, suppose you’re building a new AI data center filled with super-expensive GPUs, and you want to turn that data center into a fully automated service where you can update use cases and automate configuration changes so you don’t suffer any downtime of all that capital. In that case, this is an example of what the Infrahub project is meant to make possible. That involves combining disparate data, creating a complex data management challenge. As a result, the project uses a graph database (a technology different from GraphQL), which allows for a lot of schema flexibility. In fact, unlike a lot of automation projects, the Infrahub schema is wholly user-defined.

GraphQL comes into play because you need tremendous flexibility to exchange data with this graph database built custom to every deployment. GraphQL provides flexibility and efficiency to make it possible to automate large-scale infrastructures promptly. It has been fascinating to work on this sort of project, and it has illustrated the power of GraphQL in a way that I wouldn’t have grasped as thoroughly before.

GraphQL Origins and History

GraphQL was initially created and used internally by Facebook in 2012 while developing the News Feed section of their IOS application. In 2015, it was released as an open source project, and in 2018, the project was moved from Facebook to the GraphQL Foundation, which the Linux Foundation hosts.

GraphQL and REST are complementary and share common API architecture characteristics. Both use a client-server model with stateless servers and communicate via HTTP. They both support similar data formats, such as JSON, and can work with any database and programming language.

Limitations in REST That GraphQL Is Designed To Solve

The main reason for GraphQL’s development at Facebook was to overcome the challenge that REST-based APIs were too lengthy and rigid to produce news feeds efficiently. While this was the origin use case, GraphQL brings advantages for any API use case requiring high volume, variable, and complex data interactions.

Here are some of the critical limitations of REST that GraphQL addresses:

  • Fixed structures for data exchange and over fetching: REST APIs use pre-defined data structures for exchanging data. This simplifies things, but even if you need one piece of data from a data structure, you must always receive the whole thing.
  • Multiple endpoints for different data resources and under fetching: If you need two different types of data, you need numerous REST API requests.
  • Weak data typing and limited error checking: REST data does not enforce typing, meaning the client must figure out how to interpret the formatted data when returned. In addition, weak typing makes error checking more difficult and leaves it to the client. This is fine with simple data sources where resources are easily defined. Still, in cases with complex data sources, this ambiguity and difficulty in error handling is a significant disadvantage.

How GraphQL Solves These Limitations

Where REST is a set of rules to define structured data exchange between a client and a server, GraphQL encompasses a query language, schema-driven architecture, and tools.

  • Mandatory schema: GraphQL defines a schema for queries.
  • Single URL endpoint: GraphQL utilizes a single URL endpoint for all data exchanges rather than separate URLs for different resources.
  • Flexible, client-defined data exchanges: Unlike REST, where you request a resource and get all of it whether you want it or not, GraphQL allows you to create flexible and precise queries to fetch just the data you want.
  • Strong typing: GraphQL data is strongly typed, so the client will continuously receive data in a predefined format that is well understood.
  • Error handling: Due to its predefined schema and strong data typing, invalid requests can be elegantly rejected, and an automated error message can be served.

GraphQL Is Powerful for Complex Data Exchanges

When you need to execute complex data exchanges across multiple data sources and where there may be a high degree of variability in client requests, GraphQL offers a significant efficiency advantage regarding the number of queries needed and the amount of data fetched. These complex use cases also benefit from better data typing and error checking, which are available in GraphQL.

Here are some practical examples of where GraphQL brings advantages to data exchanges:

  • For mobile applications where bandwidth constraints mean that multiple queries to fetch required data are undesirable, GraphQL can help by batching multiple requests together into a single query across the network.
  • In situations involving a collection of newer and legacy systems, there may be a need to query multiple sources to get the required data. GraphQL provides more control over how that data is obtained.
  • Aggregating APIs also benefits. GraphQL allows teams to combine multiple APIs into a single API endpoint, simplifying API versioning.
  • GraphQL helps with fetching nested data. Sometimes, queries require fetching primary and related nested data sets. An example is fetching blog posts and associated comments.
  • Finally, GraphQL is useful for querying network and infrastructure automation data. Service delivery across networks and other complex IT infrastructure involves multiple devices related by topology or other relationships. GraphQL makes it easier to fetch configuration or state data from a series of linked data objects for monitoring, security, and auditing purposes.

GraphQL offers significant flexibility and efficiency benefits to API data transfers with greater complexity, variability, latency, or bandwidth constraints. While REST remains the default API for many applications, GraphQL is a powerful option in the API developer’s toolkit.

TRENDING STORIES
Pete Crocker currently serves as the Director of Solution Engineering at OpsMill, where he is actively involved in the creation of the Infrahub platform. Prior to OpsMill, Pete held leadership roles at IP Fabric and NVIDIA, where he specialized in...
Read more from Pete Crocker
SHARE THIS STORY
TRENDING STORIES
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.