How and why GraphQL will influence the Sourcehut alpha
So I&#x27;ve now had the opportunity to use both GraphQL and protocol buffers (&quot;protobufs&quot; is the more typical term) professionally and I have some thoughts on this.<p>1. Protobufs use integer IDs for fields. GraphQL uses string names. IMHO this is a clear win for protobufs. Changing the name of a field of GraphQL is essentially impossible. Once a name is there it&#x27;s there forever (eg mobile client versions are out there forever) so you&#x27;re going to have to return null from it and create a new one. In protobufs, the name you see in code is nothing more than the client&#x27;s bindings. Get a copy of the .proto file, change a name (but not the ID number) and recompile and everything will work. The wire format is the same;<p>2. People who talk about auto-generating GraphQL wrappers for Postgres database schemas (not the author of this post, to be clear, but it&#x27;s common enough) are missing the point entirely. The whole point of GraphQL is to span heterogeneous  and independent data sources;<p>3. Protobuf&#x27;s notions of required vs optional fields was a design mistake that&#x27;s now impossible to rectify without breaking changes. Maybe protobuf v3&#x2F;gRPC did this. I&#x27;m honestly not sure.<p>4. Protobuf is just a wire format plus a way of generating language bindings for it. There are RPC extensions for this (Stubby internally at Google; gRPC externally and no they&#x27;re not the same thing). GraphQL is a query language. I do think it&#x27;s better than protobufs in this regard;<p>5. GraphQL fragments are one of these things that are probably a net positive but they aren&#x27;t as good as they might appear. You will find in any large codebase that there are key fragments that if you change in any way you&#x27;ll generate a massive recompile across hundreds or thousands of callsites. And if just one caller uses one of the fields in that fragment, you can&#x27;t remove it;<p>6. GraphQL does kind of support union types (eg foo as Bar1, foo as Bar2) but it&#x27;s awkward and my understanding is the mobile code generated is... less than ideal. Still, it&#x27;s better than not having it. The protobuf equivalent is to have many optional submessages and there&#x27;s no way to express that only one of them will be popualated;<p>7. Under the hood I believe the GraphQL query is stored on the server and identified by ID but the bindings for it are baked into the client. Perhaps this is just how FB uses it? It always struck me as somewhat awkward. Perhaps certain GraphQL queries are particularly large? I never bothered to look into the reason for this but given that the bindings are baked into the code it doesn&#x27;t seem to gain you much;<p>8. GraphQL usage in Facebook is pervasive and it has first class support in iOS, Android and React. This is in stark contrast to protobufs where protobuf v2 in Google is probably there forever and protobuf v3&#x2F;gRPC is largely for the outsiders. It&#x27;s been several years now since I worked at Google but I would be shocked if this had changed or there was even an intention of changing it at this point;<p>9. The fact that you can do a GraphQL mutation and declare what fields are returned is, IMHO, very nice. It saves really awkward create&#x2F;update then re-query hops.<p>10. This is probably a problem only for Google internally but another factor on top of protobuf version was the API version. Build artifacts were declared with this API version, which was actually a huge headache if you wanted to bring in dependencies, some of which were Java APIv1 and others Java APIv2. I don&#x27;t really understand why you had to make this kind of decision in creating build artifacts. Again, maybe this has improved. I would be surprised however.<p>Lastly, as for Sourcehut, I had a look at their home page. I&#x27;m honestly still not exactly sure what they are or what value they create. There are 3 pricing plans that provide access to all features so I&#x27;d have to dig in to find the difference (hint: I didn&#x27;t). So it&#x27;s hard for me to say if GraphQL is an appropriate choice for them. At least their pages loaded fast. That&#x27;s a good sign.