REST

  • Best if you have CRUD operations, and the operations are data centric
  • client-server interactions:
    • Traditional request-response interactions
  • Most popular

GraphQL

  • Best if you need to fetch data, and need to give ability to the client to select what is needed
  • client-server interactions:
    • Queries (used to request data from the server)
    • Mutations (used to modify the data on the server)
    • Subscriptions (used to get live updates when data changes)
  • Provides detailed error descriptions for debugging purposes
  • Autogenerates documentation

gRPC

  • Best to use for communication between microservices
  • Binary format using Protobuf (most efficient)
  • By requiring HTTP 2 and TLS/SSL, gRPC provides better security defaults
  • built-in support for streaming
  • client-server interactions:
    • Traditional request-response interactions
    • Server streaming, where one request from the client may yield multiple responses
    • Client streaming, where multiple requests from the client result in a single response
  • Debugging can be a little difficult

References

TypeCouplingChattinessPerformanceComplexityCachingCodegenDiscoverabilityVersioning
RESTLowHighGoodMediumGreatBadGoodEasy
GraphQLMediumLowGoodHighCustomGoodGoodCustom
gRPCHighMediumGreatLowCustomGreatBadHard