Graph Query Language, or GraphQL has rapidly grown enormously in popularity, and is now used by teams of all sizes. It is used in many different environments and languages, and powers mobile apps, websites, and APIs. It is currently being used in production by companies like GitHub, Facebook, AirBnB, Shopify, and Bearer, amongst others.
However, it is not a new framework - Instead, GraphQL is a specification and a query language for APIs, and an execution engine that enables sending and processing queries. It was developed in 2012 at Facebook, and then publicly released in 2015 - Yes, its been 5 years on GraphQL!
GraphQL is not just another popular buzzword. It is replacing REST, just like REST replaced SOAP.
Find out more information about GraphQL here
Benefits of GraphQL
Some benefits include:
- Clients receive only the data they ask for - Instead of endpoints that return full objects, the clients in GraphQL can specify just the properties they want. As a bonus, this results in lower bandwidth usage.
- Fetch only required attributes and relationships in a single request - Instead of returning all attributes, as is common in the older REST APIs, GraphQL APIs allow specifying just the required attributes. Additionally, the entire deeply nested relationship hierarchy can also be retrieved if needed. (also known as the relationship graph, hence Graph Query Language) Moreover, multiple, disparate data can be grouped together and fetched in a single request. This has an added bonus of lower bandwidth usage.
- Performance - The GraphQL engine can deliver data by making parallel requests to multiple disparate distributed backend systems. This often results in better performance as multiple requests can be avoided.
- Maintainability - GraphQL provides a single source of truth, single versioned API and a better developer experience for internal as well as 3rd party developers. This also improves business efficiency by allowing rapid prototyping, avoiding duplicated logic replicated in multiple systems, and lesser code maintenance.
How can this help you?
Below are some of the reasons why companies of all sizes are looking at GraphQL over RESTful API technologies -
- It solves real world problems - GraphQL specifically eliminates two critical weaknesses of REST architecture: over-fetching, i.e. transferring data attributes that won’t be used, and under-fetching, i.e. the need for multiple requests to compose the required data.
- Better productivity and modeling - GraphQL allows you to model your business domain as a graph. Graphs are powerful tools for modeling many real-world phenomena because they resemble our natural mental models and verbal descriptions of the underlying process.
- Intuitive Shared Language - Your GraphQL schema is an intuitive and expressive shared language not just for your organisation and your users. It's value gets more pronounced when you open up your APIs to third parties and external developers.
- Deliver long-term, singular API - GraphQL enables implementation of versionless APIs leading to rock-solid long-term, stable APIs that stand the test of time.
Facebook apps from 5 years back still continue to be supported by the same API version, despite the hundreds to thousands of intermediate releases.
Evaluating GraphQL for your business
GraphQL is indeed a highly technical solution, however your entire organisation can stand to benefit by it. Choosing the API strategy is not a one size fits all approach - It depends on your specific project, your needs, and requirements. GraphQL is worth considering, especially if performance and maintainability are your business priorities. Reach out to us to discuss the potential upsides of leveraging GraphQL as a part of your business.