Menu

React, etc. Tech Stack

React, Flux, GraphQL, Hack, HHVM...? All of this and more!

GraphQL is SQL for Knowledge, not Data

Graph Databases are becoming more common place in social media, dta processing, content management and other applications developed by millions of people around the world. There are query languages like Cypher for Neo4j, etc. But who does Graphs better than Facebook? Arguably no-body. This is why GraphQL, now Open Sourced by Facebook could be the SQL of Knowledge.

When Facebook built their mobile applications for Windows, iOS and Android, they needed a powerful data fetching API. This API needed to describe all of the content at Facebook, but be simple to learn and use by developers working on the Facebook product on UI and Backend levels with languages like JavaScript, PHP and now Hack.

Facebook filled the void by developing GraphQL around three years ago. In the finest Facebook tradition it is already live and powering billions of requests daily over at various Facebook web properties. How about that for dogfooding your APIs? Today Facebook announced Open Sourcing GraphQL, starting with a draft specification, a reference implementation at GraphQL.org.

What is GraphQL?

GraphQL is a data query language and runtime designed and used at Facebook to request and deliver data to mobile and web apps since 2012. A GraphQL query is a string that is sent to a server to be interpreted and fulfilled, which then returns JSON back to the client.

It has three principles:

Being Declarative means that responses are decided by the client, not the server. A query returns exactly what the client requested and nothing more.

Being Compositional means that the queriest themselves are a hierarchical set of fields. The response to your request will be shaped just like the response. This makes data formats predictable and eliminate the need for separate specifications for data returns.

Being Strong-typed means that a query can be ensured to be valid by the built in type system at development time. This eliminates uncertainties of types and enables easy construction of high-quality applications consuming GraphQL.

While it's early days for GraphQL, it could hold prospect for being a universal query language for Graph Databases, such as SQL (Structured Query Language) has been for Relational Databases. Having a common lingua franca for querying Content Graphs in CMSes, for example, would unlock new possibilities in the long term.

Learn more at the GraphQL website and Facebook's post: GraphQL: A data query language

Written by Jorgé on Tuesday September 15, 2015

Permalink - Tags: graphql, sql, facebook, cockroachdb, cms

« React lazy loading - Flow is a type checker for JavaScript, so what is it? »