3 ms·
I love it. It provides a set of strongly typed, canonical resources, built-in documentation via schema reflection, granular authorization (which is a huge comfo
by cheald 4y ago
I love it. It provides a set of strongly typed, canonical resources, built-in documentation via schema reflection, granular authorization (which is a huge comfort in large systems!), and a bunch of other stuff. For marrying to a front end, the strong typing implied by the interface (and ability to generate Typescript types) are invaluable; a change in my backend server code that breaks front-end code is immediately caught and surfaced by my compiler.
REST is still great, and it's hard to beat for simplicity, but I also don't consider it to be XOR with GQL. In systems that I already have GQL set up for and for which REST is appropriate, I like to actually build REST APIs as convenience wrappers on top of my GQL underpinnings - rather than a controller action being a set of authorizations, record loads, and transformations to JSON, I just execute a GQL query (in server code) against my schema and consume the result to transform it to the desired output. In practice, this is often what REST APIs are doing ad hoc, but being able to leverage all the guarantees provided by the GQL schema results in very simple, straightforward, flexible implementations.
GQL represents a large shift in how you think about the structuring of an application's API, but done well I consider it flatly superior for systems beyond the trivial because of the reduction in maintenance friction.