Web Development

Tech Q&A

When designing client-server web APIs, when might you want to choose REST, REST + GraphQL, or RPC? What are the unique benefits of each style?

TL;DR

First, an overview of each:

REST

In practice it is rare for all of the above guidelines to be followed strictly in an HTTP-based web API (HTTP being the most common protocol in REST or REST-like implementations).

GraphQL

RPC

With that said…

Which APIs might “REST” (or an approximation of it) be best suited for?

In as simple a description as possible: ones prioritizing reliability and broad, long-term compatibility.

Which APIs might benefit most from GraphQL?

In as simple a description as possible: the most complex, resource-intensive ones.

Which APIs might prefer to use RPC?

In as simple a description as possible: ones responsible for private, high-trust actions with a greater priority on performance over broad support. e.g., microservice-based backends.

[1]. The World Wide Web has a distinct meaning from the Internet. The Internet describes the global network of computer networks that use packet-based routing to exhange data; the World Wide Web describes a system of Uniform Resource Identifiers (URIs) that index various data. See https://www.w3.org/help/#webinternet.

[2]. As a side note, a URI is a unique resource identifier, and a URL is a URI that includes the resource’s required access protocol. Since we know the protocol here is HTTP(S), it is most accurate to say “URI.” See https://danielmiessler.com/p/difference-between-uri-url/.

[3]. A subscription is a long-lived request that continues to fetch data automatically in response to each occurrence of a specified event.

see: