Multiple Relay Containers And Variables Communication

- 1 answer

I'm trying to change variables of a Relay Container from another Relay Container. They don't have a parent-child relation and both are in two separated Root Containers.

Container = Relay.createContainer(Component, {
  initialVariables: {
    value: 10
  fragments: {
    fragmentOne: () => Relay.QL`
    fragment on Score {
      score(value: $value) 

Assuming the scenario I described: Which is the best way to change $value variable from the Container above, from another Container? There is a way to do only with Relay or I need Redux (or Reflux) to make this work?




I would reconsider the design of your app. The purpose of a root container is to sit at the top and hold your app together.

Once you have two root containers, you are building two apps. If your app really needs to be this way, you may not be out of luck. Multiple apps usually communicate with each-other via an API. With Relay, that API speaks graphql. Normally you would need to go to a server to communicate, but since your apps live on the same page you could circumvent the server with a local graphql api.

Use this solution with caution though, as mentioned in the readme.