React, etc. Tech Stack

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

Beyond REST: GraphQL vs. Falcor

XML has largely been ousted by JSON as the de-facto format for transferring data. XML remains a valid format for document annotations, but RESTful APIs serving lean JSON is where the action has been for a number of years.

JSON itself will continue to be around, but the REST API has some new alternatives: Falcor from Netflix and GraphQL from Facebook. Both retain JSON as the base format of communication, but the idea behind the scenes is to change how these structures are used.

Both of these technologies are referenced with the word Graph, which might lead people to believe that Falcor and GraphQL are languages similar to SQL, but for Graph Databases. But this is not the case, neither of these languages is an alternative Graph Database Query Languages like  OpenCypher, Gremlin or SPARQL.

Falcor and GraphQL are both high level abstractions of some type of data store for web APIs. The system underneath a GraphQL/Falcor front end can be a CMS or a real Query database. These are technically communication level protocols for web applications, which abstract the underlying database.

Falcor's direct counterpart to GraphQL is JSON Graph

Out of the two, Falcor is a larger undertaking. Falcor is an entire data platform that powers user interfaces at Netflix. It's a tool that allows you to model all of your data to a single virtual JSON object on a server running Node.js. On the clientside you're working with this remote object using JavaScript operations such as set and get.

GraphQL itself is just a language specification. It is now Open Sourced and free to use outside of Facebook. Facebook itself has released a reference implementation of a GraphQL capable server written in JavaScript for Node.js.

Both of the technologies are largely seen from outside as interfaces to interact with data. GraphQL is the obvious one, where the language is front and center. For Falcor the language is not so prominent as it's simply a part of the larger stack. The Falcor JSON object is known simply as JSON Graph, which you interact with.

The JSON Graph can contain internal references to other values within the same JSON object, so repeating a single value is eliminated completely. This leads to simpler use and higher efficiency - similar to when the web development community largely moved from XML to JSON.

The advantage over custom built REST APIs having this kind of standards is obviously interoperability between servers and clients. With both technologies being developed and used by tech giants, even though the technologies have been published in 2015 they can be considered production ready.

See these links for more information on GraphQL and Falcor here:

Written by Jorgé on Thursday June 9, 2016

Permalink - Tags: falcor, graphql, javascript, rest

« Trivago is building their own Virtual DOM library - Apollo offers data abstraction for Angular 2, React and Redux using GraphQL »