Relay and GraphQL [architect]

posted in: API, Architecture, JavaScript, React | 0

Will Relay be compatible with standard RESTful APIs? Does it have a preference for synchronous side-loaded association data or async association data?

Relay depends on GraphQL as the query language and assumes your app will talk to an endpoint that speaks GraphQL, but the underlying implementation of the endpoint can be anything you want (including talking to other services which may or may not be RESTful). This means that at the application layer you are no longer thinking in terms of individual “resources” but rather the entire hierarchy of data that your application is going to need (ie. not resources, but trees of resources).

Each component specifies the bit of data that it will need in the form of a query fragment, and the framework takes care of composing all of the fragments into a larger hierarchy that represents the entire query. Because all of this is centralized in the framework, even dealing with massive queries (ie. all the data your entire application needs to render a complex, nested view hierarchy) can be made efficient through caching, batching, re-use, and other means to reduce the size of queries.

https://gist.github.com/wincent/598fa75e22bdfa44cf47

http://facebook.github.io/react/blog/2015/02/20/introducing-relay-and-graphql.html

Leave a Reply