The choice of API architectural style depends on the type of consumers, data volume, requirements for interface development speed, and scalability.
Example of REST controller (Node.js/Express):
app.get('/api/users/:id', function(req, res) { // ... res.json(user); });
Example of gRPC service definition (protobuf):
service UserService { rpc GetUser (UserRequest) returns (UserResponse); }
Example of a GraphQL query:
query { user(id: "123") { id name posts { title } } }
Key features:
Can GraphQL be used for any corporate APIs?
Not always! GraphQL is good for complex aggregated data, but for simple CRUD interfaces and high load, REST is often simpler and more effective.
Is gRPC suitable for mobile/web clients?
Usually no, gRPC requires support for HTTP/2 and does not integrate with browsers without special proxies, so it is rarely used on the frontend.
Is REST API always easier to version than others?
Not necessarily. Versioning in GraphQL is handled at the schema level, while REST is usually done through changing URIs or headers, which isn’t always convenient for the evolution of complex data schemas.