Thursday, September 5, 2019

First Post!

GraphQL

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.

Resources:
https://blog.apollographql.com/facebook-grants-full-patent-rights-to-all-graphql-users-2c41abc6df66#targetText=MIT%20license%20for%20GraphQL.js&targetText=Part%20of%20today's%20announcement%20is,Apollo%20GraphQL%20open%20source%20tools.

https://graphql.org/learn/

https://earthquake.usgs.gov/fdsnws/event/1/

No comments:

Post a Comment

Contains Duplicate (Leetcode)

I wrote a post  roughly 2/3 years ago regarding data structures and algorithms. I thought I'd follow up with some questions I'd come...