EMZETT.
Login

GraphQL and gRPC

In short: GraphQL and gRPC are alternatives to classic REST interfaces. GraphQL lets clients request exactly the fields they need, gRPC uses a compact binary format.

In more detail: With GraphQL the client sends a query describing which data it needs and receives exactly that in one request. With gRPC you define functions and messages in a schema file (Protocol Buffers), from which code for many languages is generated.

In Depth

  • GraphQL: one endpoint, one schema, less overfetching and fewer requests. Drawbacks: caching is harder, queries can become expensive (depth limits needed).
  • gRPC: fast, strictly typed, streaming possible, ideal between services. In the browser only usable with an add-on.
  • REST: simple, widespread, easily cached (HTTP caching).
  • Choice: public interface: often REST. Internal services: gRPC. Many changing clients: GraphQL.

See also: REST, Microservices