Upgrade to Pro — share decks privately, control downloads, hide ads and more …

From Flux to Relay and GraphQL: a short story

From Flux to Relay and GraphQL: a short story

While Flux was slowly catching up as the defacto pattern for "not-so-simple" React applications, Facebook announced Relay and GraphQL this January as a simple plug-and-play framework to make life easier for developers. In this slide deck we will have a look at the ideas behind Flux, how they evolved to Relay and GraphQL, and how easy will it be to switch an application to using this kind of technologies.

Mihai Cîrlănaru

May 20, 2015
Tweet

More Decks by Mihai Cîrlănaru

Other Decks in Technology

Transcript

  1. Flux explained View <Statement ...> <StatementUserHeader ... /> <StatementBody ...

    /> <StatementActionBar ... /> <Respond ...> <Restate ...> <WellSaid ...> </StatementActionBar> </Statement>
  2. Flux explained Action var StatementActions = createActions([ 'endorse', ... ]);

    ... _clickHandler: function(){ StatementActions.endorse( this.props.statementId ); } <WellSaid onClick={ this._clickHandler } />
  3. Flux explained Store var ResourceStore = createStore({ init: function(){ this.data

    = {}; this.listenTo(StatementActions.endorse, this.toggleEndorsement); }, ... toggleEndorsement: function(id) { // Update this.data[id].endorsement_count ... this.triggerAsync(this.data); } });
  4. Relay way Action Dispatcher Store* View** Server Action * managed

    by the framework ** Relay wrapped components
  5. Relay way Relay Store Component Server GraphQL write GraphQL query

    GraphQL response props Optimistic update Action* * description on how data should change
  6. Relay is a new framework from Facebook that provides data-fetching

    functionality for React applications. ” facebook.github.io/react/blog
  7. GraphQL is a data querying language designed to describe the

    complex, nested data dependencies of modern applications. ” facebook.github.io/react/blog
  8. Relay and GraphQL explained Relay container * props with query

    results Relay.createContainer(Statement, { queries: { statement: graphql` Statement { creator { name, picture }, body { text, opinions } } ` } }); props* GraphQL