The repository I chose for my first blog post is called GraphQL, it is a query language API developed by Facebook and an alternative to REST APIs that is widely used in today's web architecture. One of the major differences between GraphQL and traditional query languages is the ability to define structures for data and also the data to be returned, this allows for users to be able to reduce the amount of data they receive back from the service.
For example USGS maintains a earthquake catalog of all earthquakes that have occurred ever since they could be tracked properly.
They have an API that returns the following data.
This data is great... for a geologist who wants to know all aspects of the incident. However as a person who is just curious about:
- the magnitude of the earthquake
- location of the earthquake
- link to the incident
I don't need the rest of the information, and that is an issue to itself. I don't imagine there being too many people wanting to know about earthquakes. But imagine there are millions of people like me who are just curious about three bits of information I listed above. Anytime they request for any earthquake, information in the form of that image will also be returned, meaning that is wasted bandwidth the server is sending, because none of us are interested in it. Unless there was another endpoint on the site that can send less data, any users requesting data on earthquakes will always receive information more than just the magnitude, location and link to the earthquake info.
Since it is newer technology, adoption, tools and integration are not as widely available, although it is improving. Another downside to GraphQL, is ironically its strength. It allows users to define structures for their data, however this freedom also presents a downside. If the user creates a query that's too open, like retrieving friends of friends of friends of friends and so forth, one could severely affect the server's performance or worse just take it down completely.
The reference implementation of GraphQL, GraphQL.js is licensed under the MIT license allowing users to almost freely use the downloaded source code.