Sunday, August 28, 2022

gRPC vs REST vs GraphQL

๐—š๐—ฟ๐—ฎ๐—ฝ๐—ต๐—น๐—ค๐—Ÿ is a data query language that uniquely allows clients to request any specific data that they need. As opposed to RESTโ€™s HTTP methods, GraphQL uses queries, mutations, and subscriptions for sourcing and manipulating data. Queries request data from the server while mutations send data to and modify data gated by the server. Subscriptions get live updates when data changes, usually through Websockets. ๐—ฅ๐—˜๐—ฆ๐—ง The most popular and most used API format on the list is REST, which stands for representational state transfer. REST APIs use HTTP methods like GET, POST, PUT, and DELETE to access and manipulate data within uniform resource identifiers (URIs). ๐—ด๐—ฅ๐—ฃ๐—– is a high-performance, open source remote procedural call (RPC) framework created by Google. In gRPC, protocol buffers make API requests to the server. These API requests and responses are protocol buffer messages, and each one must have its own type defined using the protocol buffers language. So, ๐˜„๐—ต๐—ถ๐—ฐ๐—ต ๐—ผ๐—ป๐—ฒ ๐—ถ๐˜€ ๐˜๐—ต๐—ฒ ๐—ฏ๐—ฒ๐˜€๐˜? - The winner is, of course, โ€œ๐—ถ๐˜ ๐—ฑ๐—ฒ๐—ฝ๐—ฒ๐—ป๐—ฑ๐˜€.โ€ Each technology has strong benefits, but those come with trade-offs. Your needs may best be served by a combination of technologies. - ๐—ฅ๐—˜๐—ฆ๐—ง, ๐—ผ๐—ฟ ๐—ฎ๐˜ ๐—น๐—ฒ๐—ฎ๐˜€๐˜ ๐—๐—ฆ๐—ข๐—ก ๐—ผ๐˜ƒ๐—ฒ๐—ฟ ๐—›๐—ง๐—ง๐—ฃ, is the most ubiquitous standard for web-based APIs. This means itโ€™s easy to get started, you can use a wide variety of languages, and it works natively with web browsers. - In their own way, ๐—š๐—ฟ๐—ฎ๐—ฝ๐—ต๐—ค๐—Ÿ ๐—ฎ๐—ป๐—ฑ ๐—ด๐—ฅ๐—ฃ๐—– address some of the limitations of REST. - ๐—š๐—ฟ๐—ฎ๐—ฝ๐—ต๐—ค๐—Ÿ allows a client to specify just the information they need, which can greatly reduce duplicate or unnecessary data being transmitted. But, it requires additional setup and training. - ๐—ด๐—ฅ๐—ฃ๐—– is built for fast transport, leveraging HTTP/2. This requires a well known contract, typically using Protocol Buffers, that is shared by the client and server.