Another con of GraphQL (and probably GRPC) is caching. You basically get it for free with REST. REST can also return protobufs, with content type application/x-protobuf. Heck, it can return any Content-Type. It doesn't have to be confined to JSON. GRPC needs to support the language you're using. It does support a lot of the popular languages now. But most languages have some sort of http server or client to handle RE…
We solve the cacheability part by supporting aliases for queries by extended the GraphQL console to support saving a query with an alias. Also, with gzip, the size of json is not a big deal given redundant fields compress well.
REST vs GraphQL vs gRPC
151–160 of 168 posts
Re: REST vs GraphQL vs gRPC
#152I feel like this is rather shallow, and, by focusing so heavily on just the transport protocol, misses a lot of more important details. For starters, REST and "JSON over HTTP/1.1" are not necessarily synonyms. This description conflates them, when really there are three distinct ways to use JSON over HTTP/1.1: Actual REST (including HATEOAS), the "openAPI style" (still resource-oriented, but without HATEOAS), and JSO…
Re: REST vs GraphQL vs gRPC
#153> Easily discoverable data, e.g. user ID 3 would be at /users/3. All of the CRUD (Create Read Update Delete) operations below can be applied to this path Strictly speaking, that's not what REST considers "easily discoverable data". That endpoint would need to have been discovered by navigating the resource tree, starting from the root resource. Roy Fielding (author of the original REST dissertation): "A REST API must…
You are quite correct, but by this stage the original definition of REST to include HATEOAS has pretty much been abandoned by most people. Edit: Pretty much every REST API I see these days explains how to construct your URLs to do different things - rather than treating all URLs as opaque. Mind you having tried to create 'pure' HATEOAS REST API I think I prefer the contemporary approach!
Re: REST vs GraphQL vs gRPC
#154Earlier quoted context omitted.
> Personally I prefer to have explicit control over the caching mechanism rather than leaving it to network elements or browser caching. I'm not talking about browser caching, I'm talking about the reverse proxy that fronts your ("backend") service to the internet. High traffic global/unauthenticated reads, especially those that never change, should get cached by the frontend (of the "backend", not the SPA) reverse p…
I am sure you have good reasons for your concrete design but in the general case: Why not simply build the caching into your backend services rather than having a proxy do it based on the specifics of http protocol? It would be simpler and far more powerful.
Re: REST vs GraphQL vs gRPC
#155I think for people who didnt try GRPC yet, this is for me the winner feature: "Generates client and server code in your programming language. This can save engineering time from writing service calling code" It saves around 30% development time on features with lots of API calls. And it grows better since there is a strict contract. Human readability is over-rated for API's.
On the GraphQL side you can use gqless[0] (or the improved fork I helped sponsor, here[1]). It's by far the best DX I've had for any data fetching library: fully typed calls, no strings at all, no duplication of code or weird importing, no compiler, and it resolves the entire tree and creates a single fetch call. [0] https://github.com/gqless/gqless [1] https://github.com/PabloSzx/new_gqless
I guess the big advantage is that when you write a manual query you can still pull down more data than you need by accident. Whereas this approach only pulls down what you need.
Re: REST vs GraphQL vs gRPC
#156Am I the only who simply does remote procedure calling over http(s) via JSON? Not REST as in resource modelling but simply sending a request serialized as a JSON object and getting a response back as a JSON object.
Re: REST vs GraphQL vs gRPC
#157Additional GraphQL con: it requires some thought and planning in order to ensure data is cacheable in CDNs and other reverse proxies. This is generally simpler in REST because the APIs tend to be more single use. In GraphQL you have to essentially predefine all the queries in order to achieve the same cache-ability of responses. Then identify those, essentially, over REST.
1. Hashes queries and uses GET requests.
2. If missing, sends a standard graphql as POST
Re: REST vs GraphQL vs gRPC
#158I am totally expecting the next fad in web development to be just exposing a raw SQL interface to the front-end...
We have added so many layers and translations between our frontend and database.
Graphql brought us closer and it starts to run into some of the security concerns already.
What if someone just made this direct sql interface safe/restricted?
Re: REST vs GraphQL vs gRPC
#159I wish gRPC was bidirectional For now I will stick to SignalR
It supports bidi, and also single request, multiple responses, or multiple requests, single response - https://grpc.io/docs/what-is-grpc/core-concepts/#bidirection...
Sounds like write it yourself using two streams
Re: REST vs GraphQL vs gRPC
#160Earlier quoted context omitted.
You are quite correct, but by this stage the original definition of REST to include HATEOAS has pretty much been abandoned by most people. Edit: Pretty much every REST API I see these days explains how to construct your URLs to do different things - rather than treating all URLs as opaque. Mind you having tried to create 'pure' HATEOAS REST API I think I prefer the contemporary approach!
I don't understand why the original dissertation is treated like gospel
However, in retrospect, it might have been an idea to give what developed from Fielding's original work a clearly different name.