Trusted answers to developer questions

GraphQL vs. REST

Get Started With Machine Learning

Learn the fundamentals of Machine Learning with this free course. Future-proof your career by adding ML skills to your toolkit — or prepare to land a job in AI or Data Science.

Introduction

REST has been the long-reigning king in the realm of web application architecture. It provides a comprehensive set of rules and constraints that can deliver fully functioning web services. However, those rules and constraints can quickly become problematic as well.

Using REST to its full potential requires an extremely high level of familiarity with its complexities, which is just not feasible for every developer. This has given rise to “so-called REST” APIs which do not actually conform with RESTful rules.

svg viewer

GraphQL makes API development easier and more accessible to a larger population. Clients that lack the time and money needed to work with REST love the simplicity of GraphQL.

Query Complexity

In a REST API, fetching multiple resources requires making multiple requests to the server. However, with GraphQL, this can be done with just a single query.

svg viewer
svg viewer

Over/Under-fetching Information

GraphQL also solves the problem of over/under-fetching data. A REST call can often retrieve a lot of extra or incomplete information. On the other hand, GraphQL queries are very specific and return exactly what we need.

svg viewer

REST does have its own advantages. Performance optimization is pre-defined in the protocol. It is also a highly scalable technology. These functionalities do exist in GraphQL, but it is entirely up to the client to implement them.

svg viewer
svg viewer

RELATED TAGS

graphql
rest
client-server
query
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?