Facebook takes Relay JavaScript framework open source

Company engineers see the community potentially extending it beyond its links to React JavaScript technology

Facebook takes Relay JavaScript framework open source
opensource.com (CC BY-SA 2.0)

Facebook this week is open-sourcing Relay, which provides data-fetching for React JavaScript applications. The move could open up new possibilities for the technology, Facebook engineers said.

Accessible on GitHub, Relay is a JavaScript framework for developing data-driven applications with React, Facebook's JavaScript library for building user interfaces. "Relay is actually intended to build and do for data-fetching what React does for the user interface rendering," said Tom Occhino, Facebook engineering manager, in an interview at this week's @scale conference in San Jose, Calif.

The technology, which also works with Facebook's React Native framework, makes it easier to build "performant," applications, Joseph Savona, Facebook engineer, said at the conference. "Relay batches queries together," he said.

By open-sourcing Relay and making it available to the community at large, Facebook engineers envision new possibilities, such as Relay being extended beyond working with only React technologies. "There's obviously going to be use cases that we don't anticipate but the community does anticipate," Savona said.

Relay is declarative, in which there is no need for communication with a data store using an imperative API. With Relay, data requirements are declared using GraphQL, and Relay then figures out how and when to fetch data. GraphQL, for its part, is a Facebook-developed query language for describing data requirements for complex application data models. GraphQL was made open source in July.

Relay also provides colocation, in which queries live next to the views that rely on them, with queries aggregated into efficient network requests. And it features mutations, in which data can be mutated on the client and server using GraphQL, providing data consistency, updates, and error-handling.

Copyright © 2015 IDG Communications, Inc.