7 ms·
Relay: Declarative data for React applications
- ZitchDog 11y agoBetween relay and react-native, we have the potential for a game-change in application architecture. A single repository could easily host frontends for each application target, (iOS, Android, web) along with a backend written in Relay/GraphQL. What's more, static analysis using flow/TypeScript could provide type checking across all applications, all the way back to the storage backend. Exciting stuff.
- chairleader 11y agoI see a lot of promise here as well. I'm not sure if the world is ready to express everything in terms of graphs, though.
- vog 11y agoI recently noticed that I want something like a graph database for an application that screams for an SQL database, a strict schema and strict constraints. The reason: SQL, even PostgreSQL with userdefined functions, is not strict enough for me. As soon as a consistency rule involves multiple tables, things. There are some nice SQL tricks with duplicating columns across those tables, whose consistency is ensured by putting them as additional columns into foreign keys. But for my taste this is too much trickery, and this approach has its limits as well. I hope that one day the Graph databases will be combined with strict schemas that go far beyond XML schema, JSON schema and SQL database constraints. Also I hope that expressing those constraints should be easier, not harder, to read when applied to a graph database.
- manx 11y agoRecently I'm experimenting a lot with Strict graph database schemas. This resulted in this library: https://github.com/renesca/renesca-magic https://github.com/renesca/renesca-magic , supporting multiple inheritance, hyperrelations and some more features.
- dragonwriter 11y ago> I hope that one day the Graph databases will be combined with strict schemas that go far beyond XML schema, JSON schema and SQL database constraints. The graph database model is driven largely by a desire for better navigational convenience at the expense of weaker schemas compared to RDBMS models. So, while you can wish for anything, I don't see that that's likely to happen. RDBMSs start ahead of graph databases when it comes to stronger schemas, and there's no reason that any stronger schema techniques would be more applicable to graph databases than to RDBMSs.
- vog 11y agoGood points, but note that I came from the other side: I drafted a concept of how to formulate the strictest schemas that I would like to apply in the application. Then I realized that the underlying model resembles much more a graph model than a relational model. I agree that today's graph databases are meant to be used for weaker schemas, I believe that they are conceptually a better fit for strict schemas than relational databases are. But probably we need a third term for those ultra-strict databases. From the "look and feel", this new type would almost certainly look more similar to a graph db than a relational db.
- idibidiart 11y agoI thought the purpose of Relay is to get you to use a graph db. I think of GraphQL as a layer that sits between the REST API and web application, allowing you to specify custom queries that interact with the REST API behind the scene, so your REST layer can be application agnostic and you won't have to hardcode any application specific transformations between your REST API and your web or mobile or xbox etc app.
- RedCrowbar 11y ago> I recently noticed that I want something like a graph database for an application that screams for an SQL database, a strict schema and strict constraints. You may be interested in (soon to be released) EdgeDB: http://edgedb.com/ http://edgedb.com/ (Disclaimer: I'm one of the devs behind it).
- robertfw 11y agoThis looks excellent! Signed up for the newsletter. Can't wait to hear more. Do you have any other available info beyond what is on the site?
- 1st1 11y agoGreat to hear that :) We plan on writing a series of blog posts to cover EdgeDB and some of the concepts behind it.
- vog 11y agoLooks great! Alas, there is no RSS/Atom feed. If that site had one, I would have thrown it into my RSS reader. (I hesitate to throw my email address into such sites, sorry.) BTW, will there be an Open Source version of the DB?
- 1st1 11y agoYes, it will be open source. As for emails - we won't disclose them to anyone, or fire emails more often than 1 in 3-4 weeks.
- dustingetz 11y agoAll the business web apps I've worked on that use relational databases with an ORM layer, are already modeling the world as a half-baked graph. I'm reminded of https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule.
- amelius 11y agoAs long as it doesn't result in a monolithic "framework" that is difficult to replace or modularize.
- misiti3780 11y agoI havnt really spent too much time looking at Relay, so forgive me if this is a dumb question, but if you want to use the Relay paradigm do you not have to change your backend-apis to return GraphQL formatted JSON ?
- dominotw 11y agoyes
- RussianCow 11y agoYes, you do. Facebook wrote an example GraphQL server[0] on top of Express. [0]: https://github.com/graphql/express-graphql https://github.com/graphql/express-graphql
- hueyp 11y agoYes, but GraphQL is just a thin layer so you can call your existing API's from GraphQL. For example you could start with GraphQL calling an existing HTTP service and go from there. A nice talk / use case given here: https://www.youtube.com/watch?v=S0s935RKKB4 https://www.youtube.com/watch?v=S0s935RKKB4
- graffitici 11y agoBut Relay was already announced a few weeks ago, right? What's new with this blog post now,?
- aikah 11y agoSo there is no code sample only marketing fluff. How does it work , like flex "fx" namespace where web-services are declared in the xml ?
- archinal 11y agoMaybe they changed the blog post after you read it, but they link to their github repo (https://github.com/facebook/relay https://github.com/facebook/relay) and the NPM registry (https://www.npmjs.com/package/react-relay/ https://www.npmjs.com/package/react-relay/)
- techman9 11y agoWow, two independent pieces of web technology called Relay made it to the top of of Hacker News in the same day.
- ChronosKey 11y agoAnd then of course, the recent winner of MHacks 6 https://twitter.com/mhacks/status/643194428975390720 https://twitter.com/mhacks/status/643194428975390720
- mst 11y agoThe sheer amount of code required here just to get the trivial example set up is ... a little daunting. I mean, if facebook are using it heavily, then one can presume it works nicely at scale, but they don't seem to be doing amazingly well at the "make the easy things easy" side of things (yet).
- andreamazz 11y agoYeah, I wanted to try Relay for a small project a month ago, but getting started seems really time consuming, and the documentation was pretty poor, with just a contrived sample. The architecture seems great, I hope they improve the doc now that it's out of the tech preview.
- 6t6t6 11y agoThis is unsettling: class Score extends React.Component { render() { var {initials, score} = this.props.score; return ( <li key={initials}> <strong>{initials}</strong> {score} </li> ); } } Score = Relay.createContainer(Score, { fragments: { score: () => Relay.QL` fragment on Score { initials, score, } `, }, }); Soo, if I understood well, first they create a class and then they create a global variable reusing the same name of the class, in order to create and object that expands the class? This Facebook people know how to make me uncomfortable. But I guess I could get used, the same way I got used to JSX...
- anarchy8 11y agoIf I recall correctly, this is simply a decorator. Using ES7, you could write the createContainer call using the new decorator syntax and avoid this uncomfortableness.
- mst 11y agoThey create a class, then they wrap the class in a class. A class in javascript is just a variable, after all. I think, personally, I'd've called the initial class ScoreGuts or something, or gone with a different syntax that returned the class as a value, but ... eh. It's really not that big a deal.
- 6t6t6 11y agoNow I understand. Thank you! > I think, personally, I'd've called the initial class ScoreGuts or something Well, maybe the point is that the original class becomes "useless" once it has been "decorated"; so it doesn't make sense that it has its own name. But it's is also true that, once you get used to program using FP style, mutating variables like this feels "weird".
- mst 11y agoYeah, that would seem like the motivation, but it feels a bit weird to me too. It occurs to me that you could probably do something like Score = do_the_decoration((function () { class Score ... { ... } return Score; )()); but that's not exactly 100% better, just weird to a different subset of people :)
- xiaoma 11y agoI've really been starting to love fb in this past year in a way I never thought I'd love any big company.
- ergo14 11y agoStill, you should read additional patents clause in their projects - not only license terms.
- estefan 11y agoI'm just finishing my first relay/react app. This stack is amazing. It will blow REST away. This time next year I'd be surprised if people are still creating REST servers for greenfield projects. Seriously, it's a game changer. The speed of iteration is fantastic since you don't need to constantly create new endpoints/fiddle with the data your server provides every time you want to pull in a little extra data. You also get pagination basically for free. I can recommend sangria for the graphql server - a strongly typed language gives you better confidence, and it's built on akka-http so it'll be performant too.
- jondubois 11y agoI feel that client-side pub/sub over WebSockets is a more natural solution to the problem of binding front-end views to server-side data. For browser compatibility reasons, I do see the necessity for Relay (HTTP being much more widely supported than WebSockets) but Relay is definitely not the end-game.
- PudgePacket 11y agoIs it possible to use relay without graphql or are they baked together?
- rafalsobota 11y agoRelay is much more than GraphQL and GraphQL will be optional in the future.