Re: Thoughts on Facebook's GraphQL?

On 02/12/2015 03:04 PM, Nate Otto wrote:
> https://www.youtube.com/watch?v=9sc8Pyc51uU and 
> http://hueypetersen.com/posts/2015/02/02/first-thoughts-on-graph-ql/
> 
> I've been working with Facebook's ReactJS framework, so I was paying 
> attention to the recent ReactJS Conf where they announced GraphQL and
> Relay as a method of composing complex API queries that return data
> in the requested format.

Interesting, first time I've heard about it... scanned through the video
and the blog post. I think I have a basic idea of what's going on, but
certainly am fuzzy on most of the details.

> React lets you build up interfaces out of components that each have 
> their own properties and state. Relay lets you compose 
> representations of the data each component (and its children (and its
> children)...) need from the server. It uses a system of labeled node
> IDs to distinguish the different items from one another and to define
> relationships between them.

The query/result mechanism reminds me of SPARQL.

The composition mechanism reminds me of JSON-LD Framing.

> I was wondering if any of the folks on this list have tried to
> attack this problem of composing complex requests for linked data
> using a JSON-LD format.

Yeah, we do this for the Web Payments work at Digital Bazaar, but our
approach is a bit different. We tend to fetch objects from the database,
compose them together, and build a frame for the things we want to see
in the output objects. It's a bit specialized to JSON, and we use
MongoDB on the back-end. Dave Longley or Dave Lehn could probably go
into more detail on this. The general approach is:

1. Normalize all incoming data to some JSON-LD compact form you're
   comfortable with storing in your document-based database
   by expanding and compacting using your application's JSON-LD Context.
2. Perform query-by-example (like via MongoDB) to fetch data into a
   larger JSON-LD object.
3. Use a JSON-LD Frame to reframe only the data you want, or let your
   clients provide a frame with the query so you can re-frame on
   the server side. Optionally, you can re-frame on the client-side
   if you need to.

This is an alternative approach to SPARQL, which requires some sort of
graph store and SPARQL query engine to run against the graph store (big
investments in developer retraining, but a more generalized solution to
the problem space).

-- manu

-- 
Manu Sporny (skype: msporny, twitter: manusporny, G+: +Manu Sporny)
Founder/CEO - Digital Bazaar, Inc.
blog: The Marathonic Dawn of Web Payments
http://manu.sporny.org/2014/dawn-of-web-payments/

Received on Friday, 13 February 2015 04:13:36 UTC