REST vs. gRPC vs. GraphQL

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • json-api

    A specification for building JSON APIs

    There are a variety of tricks to solve the over/under-fetching problems of REST. My personal preference is JSON:API, which defines standard query parameters for clients to ask the server return just a subset of fields or to traverse references and return complete copies of others resources.

    https://jsonapi.org/

  • webrpc

    webrpc is a schema-driven approach to writing backend services for modern Web apps and networks

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

  • graphql-code-generator

    A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.

    For REST OpenAPI/Swagger has a very large ecosystem, but does depend on the API author making one.

    [1] https://graphql-code-generator.com/

  • grpc-over-webrtc

    gRPC over WebRTC

    https://github.com/jsmouret/grpc-over-webrtc is another way to get into the browser.

    It's nice that you don't have to do any translation. Just gRPC in/out of the browser.

  • grpc-swift

    The Swift language implementation of gRPC.

    Swift is at least supported via Objective-C, and swift-grpc looks solid https://github.com/grpc/grpc-swift

  • gqless

    a GraphQL client without queries

    On the GraphQL side you can use gqless[0] (or the improved fork I helped sponsor, here[1]). It's by far the best DX I've had for any data fetching library: fully typed calls, no strings at all, no duplication of code or weird importing, no compiler, and it resolves the entire tree and creates a single fetch call.

    [0] https://github.com/gqless/gqless

    [1] https://github.com/PabloSzx/new_gqless

  • grpc-web

    gRPC for Web Clients

    I adore gRPC but figuring out how to use it from browser JavaScript is painful. The official grpc-web [1] client requires envoy on the server which I don't want. The improbable-eng grpc-web [2] implementation has a native Go proxy you can integrate into a server, but seems riddled with caveats and feels a bit immature overall.

    Does grpc-web work well? Is there a way to skip the proxy layer and use protobufs directly if you use websockets?

    [1]: https://github.com/grpc/grpc-web

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

  • grpcurl

    Like cURL, but for gRPC: Command-line tool for interacting with gRPC servers

    > unless you have Google's size microservices and infrastructure gRPC (with protocol buffers) is just tedious

    Having used gRPC in very small teams (<5 engineers touching backend stuff) I had a very different experience from yours.

    > need an extra step when doing protoc compilation of your models

    For us this was hidden by our build systems. In one company we used Gradle and then later Bazel. In both you can set it up so you plop a .proto into a folder and everything "works" with autocompletes and all.

    > cannot easily inspect and debug your messages across your infrastructure without a proper protobuf decoder/encoder

    There's a lot of tooling that has recently been developed that makes all of this much easier.

    - https://github.com/fullstorydev/grpcurl

    - https://github.com/uw-labs/bloomrpc

    - https://kreya.app/

    You can also use grpc-web as a reverse proxy to expose normal REST-like endpoints for debugging as well.

    > If you talk with other non-Go services then a JSON or XML transport encoding will do the job too (JSON rpc).

    The benefit of protos is they're a source of truth across multiple languages/projects with well known ways to maintain backwards comparability.

    You can even build tooling to automate very complex things:

    - Breaking Change Detector: https://docs.buf.build/breaking-usage/

    - Linting (Style Checking): https://docs.buf.build/lint-usage/

    There's many more things that can be done but you get the idea.

    On top of this you get something else that is way better: Relatively fast server that's configured & interfaces with the same way in every programming language. This has been a massive time sink in the past where you have to investigate nginx/*cgi, sonic/flask/waitress/wsgi, rails, and hundreds of other things for every single language stack each with their own gotchas. gRPC's ecosystem doesn't really have that pain point.

  • hasura-cms

    Automatically exposed GraphQL API via Hasura with schema + permissions for GraphCMS-like handling of content types

    Hasura makes that pretty easy as can be seen here: https://github.com/firatoezcan/hasura-cms

    This is also easy to do with self-written servers, maybe take a look at the metadata folder to get a gist of what Hasura would be doing behind the scenes (running a query and then checking the claim for the condition for the given field that permission wants to be requested for)

    (Just a repo I started one evening, it doesn't do much but the concept of projects with owners and collaborators should work)

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts