BT

Facilitating the spread of knowledge and innovation in professional software development

Contribute

Topics

Choose your language

InfoQ Homepage Articles GraphQL Reference Guide: Building Flexible and Understandable APIs

GraphQL Reference Guide: Building Flexible and Understandable APIs

This item in japanese

Bookmarks

Key Takeaways

  • GraphQL is both an open source query language for an API and a server-side runtime for executing queries. It enables the use of a type system that developers define for their data. 
  • GraphQL is rapidly becoming a popular alternative to REST and gRPC, particularly for exposing data at the edge of systems
  • Clients can define the structure of the data required with GraphQL, which can be implemented to provide a common abstraction (schema) between the frontend and backend
  • GraphQL has clearly crossed the diffusion of innovation chasm, with the only debate in the InfoQ 2020 Architecture and Design trend report being how widely it is adopted within organisations that have large existing SOAP and REST API deployments. 
  • There is still innovation occurring within this space, specifically in relation to scaling and federating GraphQL schema, and making it ubiquitous and general-purpose for large enterprises.

Introduction

GraphQL is both an open source query language for an API and a server-side runtime for executing queries. It enables the use of a type system that developers define for their data.

GraphQL supports reading, writing, and subscribing to changes to data, and SDKs and servers are available for multiple languages, including JavaScript, Python, Ruby, Java, C#, Go, Rust, PHP, and more.

GraphQL is rapidly becoming a popular alternative to REST and gRPC, particularly for exposing data at the edge of systems. According to the GraphQL homepage, "GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools."

 
GraphQL query and type system (Image courtesy of Goodbye REST APIs. Hello GraphQL!)

GraphQL was developed internally by Facebook in 2012 before being publicly released in 2015 Similar projects also coevolved at the time, such as Netflix’s Falcor, but did not see as much adoption, particularly outside of Netflix.

On 7 November 2018, the GraphQL project was moved from Facebook to the newly-established GraphQL Foundation, hosted by the non-profit Linux Foundation.

Why Would You Use GraphQL?

GraphQL provides an approach to developing web APIs and is often compared with REST, and to a lesser extent gRPC-web and other web service architectures.

GraphQL allows clients to define the structure of the data required, which can be implemented to provide a common abstraction (schema) between the frontend and backend, and also to reduce the size of payloads sent from the server. According to the Wikipedia entry for GraphQL, "the flexibility and richness of the query language also adds complexity that may not be worthwhile for simple APIs."

As with all architectural considerations, there are inherent benefits and tradeoffs with using GraphQL.

Why Should You Pay Attention to GraphQL Now?

GraphQL has clearly crossed the diffusion of innovation chasm, with the only debate in the InfoQ 2020 Architecture and Design trend report being how widely it is adopted within organisations that have large existing SOAP and REST API deployments.

There is still innovation occurring within this space, specifically in relation to scaling and federating GraphQL schema, and making it ubiquitous and general-purpose for large enterprises.

GraphQL on the InfoQ Architecture and Design Trends Report 2020 graph.

Getting Started with GraphQL

For architects and developers researching and exploring GraphQL, we recommend the following content:

Introducing GraphQL into Your Tech Stack

For engineerings teams that are exploring the introduction and integration of GraphQL into their tech stack, we recommend the following:

Data Modelling in the Enterprise: How GraphQL Can Help

Data modelling is a perennially difficult change, particularly at scale. GraphQL provides different options and implementations than REST or traditional SOA approaches, with a focus on modularity. The early approach of "schema stitching" has now evolved into "federation".

This content is a good primer to the benefits and challenges of data modelling with GraphQL:

GraphQL Case Studies

The following GraphQL case studies provide best practices and warning of "gotchas" that early adopters discovered:

Advanced Use Case: Netflix’s GraphQL Federation

Netflix have been early adopters of GraphQL and have recently begun to publicly discuss how they have scaled their implementation of this. The following content provides deeper insight into their approach and also the lessons learned:

About the Author

Daniel Bryant is leading change within organisations and technology. His current technical expertise focuses on ‘DevOps’ tooling, cloud/container platforms and microservice implementations. Daniel is a leader within the London Java Community (LJC), contributes to several open source projects, writes for well-known technical websites such as InfoQ, DZone and Voxxed, and regularly presents at international conferences such as QCon, JavaOne and Devoxx.

We need your feedback

How might we improve InfoQ for you

Thank you for being an InfoQ reader.

Each year, we seek feedback from our readers to help us improve InfoQ. Would you mind spending 2 minutes to share your feedback in our short survey? Your feedback will directly help us continually evolve how we support you.

Take the Survey

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.