REST Vs GraphQL Vs gRPC
These 3 are the most popular options right now and often when starting a new project there is a problem with what to use?
So, here is a small guide I created from my previous experience on REST Vs GraphQL Vs gRPC and What to use when?
To determine what category of protocol or specification I should investigate, I ask a few core questions, and then I examine the most popular among those categories and find their direct alternatives. The more prolific option within a category I use if I cannot find an alternative that meets both our technical requirements and fits into the existing workflow.
In this post, I discussed some tools that can help you determine the category of web communication that is best for you based on your needs.
If your clients use primarily - or exclusively - web browsers and you want to deliver web pages that can be easily bookmarked and navigated to, then you should continue to use REST.
GraphQL should be used for data-centric clients, that is, those that display data relationships the majority of the time. While GraphQL has a number of competitors, I would say it's the de facto standard for data-driven clients at this point.
There are lots of integration options, a lot of support, and a lot of people who use it... it's really the gold standard in this category.
Asynchronously communicating API-centric services, such as mobile apps and backend services, and those that interact with external sources asynchronously, such as gRPC or JSON-RPC, should consider RPC options such as gRPC or JSON-RPC. gRPC and its direct alternatives are useful if a schema is needed. Including JSON-RPC and direct alternatives to it is essential if the schema is optional.
gRPC is a perfect choice if you are specifically running multiple services on Kubernetes. gRPC is part of CNCF, and many Kubernetes components and frameworks include built-in support for it. For more complex Kubernetes deployments, it appears that gRPC will be the de facto communication protocol.
Whenever possible, I would prefer REST for websites - that is, services that use the browser as their primary, or only, client. I might mix in GraphQL if it is appropriate.