Skip to content
Use Relay to fetch and store data outside of a React component
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data
scripts
src
.babelrc
.eslintrc
.gitignore
.npmignore
.travis.yml
README.md
babelRelayPlugin.js
karma.conf.js
package.json

README.md

relay-sink

build status npm version

Usage

import { createSink } from 'relay-sink';

const TyrionSink = createSink({
  // Normal Relay Container configuration
  fragments: {
    tyrion: () => Relay.QL`
      fragment on Character {
        name,
        house
      }
    `
  }
});

// A sink is a Relay Container. Compose with parent Relay containers like
// normal. Note that `this.props.tyrion` and `fragments.tyrion` below are not
// the same value — the former points to a value inside Relay's global store,
// while the latter is the actual unwrapped data.
<TyrionSink tyrion={this.props.tyrion} onFragmentUpdate={fragments => {
  expect(fragments.tyrion.name).to.equal('Tyrion');
  expect(fragments.tyrion.house).to.equal('Lannister');

  // Do whatever you want with the data — e.g. dispatch it to a Flux store
  store.dispatch({
    type: UPDATE_TYRION,
    payload: fragments.tyrion
  });
}}/>
You can’t perform that action at this time.