![npm version](https://camo.githubusercontent.com/4c47d1591f880f689ef80eda0ade241ee3bff7d7a37c1141571c84ed96376b08/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f72656c61792d73696e6b2e7376673f7374796c653d666c61742d737175617265)
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
});
}}/>