News for hackers. Stuff that matters.
Re:REST vs GraphQL vs gRPC by meowzero on Monday March 15, 2021 @11:28AM (#26467124)
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 REST.

Re:REST vs GraphQL vs gRPC by tlrobinson on Monday March 15, 2021 @11:53AM (#26467464)
I think the benefits of HTTP caching are often exaggerated, especially for APIs and single page applications.

Often I’ll want much more control over caching and cache invalidation than what you can do with HTTP caching.

I’d be interested to see an analysis of major websites usage of HTTP caching on non-static (i.e. not images, JS, etc) resources. I bet it’s pretty minimal.

Re:REST vs GraphQL vs gRPC by jayd16 on Monday March 15, 2021 @12:13PM (#26467796)
You can put a RESTful response on S3 (or even stub a whole service) but AFAIK you can't do that for gRPC or GraphQL.
Re:REST vs GraphQL vs gRPC by dathinab on Monday March 15, 2021 @07:10PM (#26470524)
GraphQl queries are often send over an HTTP endpoint. This allows you to take advantage of caching where necessary (but then enough apps don't cache HTTP either).

For example you want to make sure large resource blobs (e.g. pictures are cached).

In this case you can decide to not put them in the GraphQl response but instead put a REST uri of them there and then have a endpoint like `/blobs/<some-kind-of-uid>` or `/blobs/pictures/<id>` or similar.

The same endpoints also can be used for pushing new resources (GraphQl creates a "empty" `/blobs/<id>` entry to which you than can push).

While this entails an additional round-trip and is properly not the best usage for some cases for others like e.g. (not small) file up-/down-load it is quite nice as this is a operation often explicitly triggered by a user in a way where the additional roundtrip time doesn't matter at all. An additional benefit is that it can make thinks like halting and resuming downloads and similar easier.

Re:REST vs GraphQL vs gRPC by ec109685 on Monday March 15, 2021 @11:32AM (#26467177)
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.

Re:REST vs GraphQL vs gRPC by pavel_lishin on Monday March 15, 2021 @10:41PM (#26472282)
Cacheability isn't just about the transfer, it's also about decreasing server load in a lot of applications. An expensive query might return a few bytes of JSON, but may be something you want to avoid hitting repeatedly.
Re:REST vs GraphQL vs gRPC by ec109685 on Tuesday March 16, 2021 @08:39PM (#26485138)
Sorry, they were addressing the two points from the comment above. I agree cacheability and transfer size are two separate aspects.
Re:REST vs GraphQL vs gRPC by phaedryx on Monday March 15, 2021 @11:53AM (#26467462)
I believe that GraphQL handles this with "persisted queries." Basically, you ask the server to "run standard query 'queryname'." Since it is a standard, predefined query you can cache the results.

Apollo support link: https://www.apollographql.com/docs/apollo-server/performance...

Re:REST vs GraphQL vs gRPC by thinkingkong on Monday March 15, 2021 @12:03PM (#26467644)
The browser supports built in caching without requiring a specific library; additionally the infrastructure of the web provides this as well.
Re:REST vs GraphQL vs gRPC by Mandatum on Monday March 15, 2021 @08:43PM (#26471491)
That sounds like RPC with extra steps..
Re:REST vs GraphQL vs gRPC by cogman10 on Monday March 15, 2021 @11:43AM (#26467322)
What popular languages aren't supported by GRPC?
Re:REST vs GraphQL vs gRPC by meowzero on Monday March 15, 2021 @11:49AM (#26467404)
Scala, Swift, Rust, C, etc. I guess with Scala you can probably use the Java one. But they have one for Kotlin...
Re:REST vs GraphQL vs gRPC by chills on Monday March 15, 2021 @11:55AM (#26467499)
Scala has several (approximately one per effect library): https://scalapb.github.io/docs/grpc/
Re:REST vs GraphQL vs gRPC by meowzero on Monday March 15, 2021 @12:00PM (#26467592)
That's actually cool. It's been a while since I worked on GRPC with Scala. Back then we only had that thin wrapper around Java.
Re:REST vs GraphQL vs gRPC by LawnGnome on Monday March 15, 2021 @05:26PM (#26469306)
Rust has tonic, which I've used to good effect as both as a client and server.
Re:REST vs GraphQL vs gRPC by onei on Monday March 15, 2021 @05:46PM (#26469583)
I'll second that. Using prost directly was a little rough, but with tonic on top it's been a dream
Re:REST vs GraphQL vs gRPC by sshb on Monday March 15, 2021 @11:53AM (#26467479)
Swift is at least supported via Objective-C, and swift-grpc looks solid https://github.com/grpc/grpc-swift
Re:REST vs GraphQL vs gRPC by rhacker on Monday March 15, 2021 @11:48AM (#26467382)
Well actually, it can actually be more advanced with GraphQL. In fact GQL clients have the ability to invalidate caches if it knows the same ID has been deleted or edited and can in some cases even avoid a new fetch.

That being said some of those advanced use cases may be off by default in Apollo.

Re:REST vs GraphQL vs gRPC by codegladiator on Monday March 15, 2021 @12:07PM (#26467701)
How will the client know ?