GraphQL the future for APIs?

 

There has been a lot of buzz about GraphQL recently. GraphQL name rings bell in most of conferences around the world. There were a number of GraphQL sessions in the recent ReactEurope tour. This post throws insights on why GraphQL is the future for APIs.

GraphQL is a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data. GraphQL isn’t tied to any specific database or storage engine and is instead backed by your existing code and data.

GraphQL is internally developed by Facebook in 2012 before being publicly released in 2015. GraphQL is a new way to think about building and querying APIs. Rather than construct several REST requests to fetch data that you’re interested in, you can often make a single call to fetch the information you need.

Why GraphQL?

There are a number of reasons you might use GraphQL in your product or project.

  • You are planning to serve APIs to your customers and becomes little complicated after scaling.
  • You have to serve a large number of clients like Web, Mobile, Tablet, Watch, TV, etc.
  • Your client requests only what information it wants, nothing more nothing less.
  • Your client requests data in one request even in slow mobile network connections.
  • You want to leverage your existing data and code.
  • You are moving to Microservices architecture.

GraphQL’s query has exactly the same shape as the response.

Graphs are powerful tools for modeling many real-world phenomena because they resemble our natural mental models and verbal descriptions of the underlying process.

GraphQL suggests to model your business domain as a graph by defining a schema and within that schema define your nodes and relationship between them.

GraphQL Design Principles

  • Hierarchical: A GraphQL query itself is structured hierarchically.
  • Product centric: GraphQL is driven by the requirements of views and the front-end engineers that write them.
  • Strongly typed: Every GraphQL server defines an application specific type system.
  • Introspective: A GraphQL server is queryable by the GraphQL language.
  • Version free: GraphQL removes the need for an incrementing version number.

Who is using GraphQL?

GraphQL is used by big companies and teams of all sizes.

  • Facebook
  • Github
  • Pinterest
  • Intuit
  • Shopify
  • Coursera

Learn GraphQL properly

There are various resources out in the Web to learn GraphQL. Start learning from the official GraphQL website. Learn GraphQL by Arunoda Susiripala is an excellent 10-part tutorial that teaches you the basics of GraphQL.

Looking for documentation on how to build a GraphQL service? There are libraries to help you implement GraphQL in many different languages. GraphQL makes it easy to build powerful tools like GraphiQL by leveraging your API’s type system.

Graph-based solutions are great opportunities to think about redesigning your API. We think though GraphQL is backed by big companies, thinking in Graphs seems to be good fit for your data and kind of topology. We need to start thinking above REST APIs to solve our business problems.

That’s it for now. Let us know what you think about GraphQL. If you have already tried out or plan to use in the next project?

Visit www.ideas2it.com to learn more the services we offer.

Leave a Reply

Your email address will not be published. Required fields are marked *