A maintainable application architecture requires that the UI only contain the rendering logic and execute queries and mutations against the underlying data model on the server. A maintainable architecture must not contain any logic for composing "app state" on the client as that would necessarily embed business logic in the client. App state should be persisted to the database and the client projection of it should be composed in the mid tier, and refreshed as mutations occur on the server (and after network interruption) for a highly interactive, realtime UX.
With GraphQL we are able to define an easy-to-change application-level data schema on the server that captures the types and relationships in our data, and wiring it to data sources via resolvers that leverage our db's own query language (or data-oriented, uniform service APIs) to resolve client-specified "queries" and "mutations" against the schema.
We use GraphQL to dyn
In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.
At the moment GraphQL allows 2 types of queries:
query
mutation
Reference implementation also adds the third type: subscription
. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.
// give it a name so it reuses the same window | |
var win = window.open(null, "redux-devtools", "menubar=no,location=no,resizable=yes,scrollbars=no,status=no"); | |
// reload in case it's reusing the same window with the old content | |
win.location.reload(); | |
// wait a little bit for it to reload, then render | |
setTimeout(function() { | |
React.render( | |
<DebugPanel top right bottom left > |
// Written by @iclanzan | |
// All credit goes to him! | |
// You create the reducer like this: | |
// var reducer = createTimelineReducer('someName', someReducer, ['foo', 'bar']); | |
// And then whenever an action of type `foo` or `bar` happens it calls `someReducer` and adds the result to the timeline. | |
// Then to undo/redo you trigger an action of type `someNameUndo`/`someNameRedo`. | |
var defaults = require('lodash/object/defaults'); | |
var capitalize = require('lodash/string/capitalize'); |
- end-of-stream - specify a callback to be called when a stream ends (which is surpsingly hard to get right)
- duplexify - compose a Duplex stream from a Readable and a Writable stream
- pump - pipe streams together and close all of them if one of them closes
- pumpify - combine an array of streams into a single duplex stream using pump and duplexify
- through2 - tools for making Transform streams
- from2 - tools for making Readable streams
// Simple wrapper to use bootstrap's grid system to position elements side-by-side | |
var VerticalFieldsElement = React.createClass({ | |
render: function() { | |
return dom.div( | |
{ className: 'clearfix' }, | |
React.Children.map(this.props.children, function(child) { | |
if(!child) { | |
return child; | |
} |