GraphQL: an opportunity for cross-vendor APIs
I’ve been recently learning about GraphQL. I haven’t done anything serious yet with it but it’s already clear to me that it’s way superior than REST. Any GraphQL service implements a GraphQL spec that defines the available information and mutations in the service. The GraphQL engine ensures that the spec is implemented correctly for both the client and the backend.
There’s not a good way to write a spec of a REST service and there are no widely used tools to validate that both the client and the backend implement the spec. There are some initiatives but more focused on generating documentation than on validating the implementation.
With a well defined spec you open the door for implementing tools based on it:
- GraphiQL: An interactive query builder.
- Documentation generator
- Code generators: think about automatically generating SDKs for GraphQL APIs.
So with these capabilities I think. Wouldn’t it be great to have GraphQL schemas implemented not only by one vendor/website, but having common GraphSQL schemas for specific things?
- Amazon, Digital Ocean, Linode, etc. implemented a common GraphQL service for handling server instances.
- Any social network implemented a GraphQL API for changing your avatar.
- Any SaaS service implemented a GraphQL to download invoices.
- GitHub, Bitbucket and others implemented a common GraphQL for the things they have in common.
- Bot platforms (Telegram, Facebook, etc) implemented a common GraphQL API.
- Payment gateways (Stripe, PayPal, Braintree) implemented a common GraphQL API.
I’m not saying these services should only implement the common API. They could implement the common API and their custom ones as extensions in a different but similar GraphQL schema. But it is clear to me that having common APIs for most of the things would allow many more apps and services integrated with them.
And finally another interesting use case is going to be: webhooks. If I’m a service supporting webhooks I can define a GraphQL schema that I expect webhook consumers to implement.
Do you remember RSS? Well, I think this is a bit the same. A huge number of apps and utilities appeared thanks to a common format implemented by many websites. But adoption depends on many things so… we will see, but the opportunity is there.