Hacker News new | ask | show | jobs
by rco8786 3346 days ago
does graphql come with its own serialization protocol? I would have thought that the comparison of gRPC to GraphQL is apples/oranges.
2 comments

GraphQL defaults to JSON over HTTP, but you can funnel it through sockets or protobuf or anything else. The conflict here is that gRPC goes beyond a serialization protocol - it's a full strongly typed RPC layer. You define your objects, methods, fields, types, relationships, data resolvers, execution pathways, etc. Just like GraphQL.

I see no meaningful advantage in binary serialization - JSON is fast enough not to be an issue, and HTTP2/GZIP minimize any bandwidth advantage. I do see a bit advantage of GraphQL in tooling and query composition, but I gRPC provides the building blocks required to rebuild that. gRPC-web is GraphQL of 12 months ago - it's definitely on the right path to help with complex data wrangling. My question is - does it do something important better/differently to GraphQL to warrant new players to enter the game and catch up to make it a strong competitor?

it uses json ? so you compare it to that
The default is JSON, but the spec doesn't mandate that it be JSON over the wire, or that even that it be over HTTP.
Also in the Json the "query" is actually a string that is in GraphQL language. So GraphQL is an encoded format embedded inside Json.

{ "query": "mutation Foo() { ... }" }

As such type safety is dependent on the query langauge (graphQL) not Json. As far as the Json goes, it might as well be multi-part form encoded.