Relay.js - Not receiving props, only __dataId__
Asked Answered
S

0

6

So I'm trying to figure out Relay.js. I conjured simple app that basically imitates example on Relay's website. However although I've managed to get rid of errors in both consoles (node and chrome), my component doesn't receive fragments I specified in Raley.Container. I have no idea, where the problem could be, as my app looks pretty much like Relay's example.

Note that map method on this.props.companies isn't available as it is an object, with 1 property, that is __dataId__.

First Component

class App extends React.Component {
  render() {
    return (
      <div>
        {this.props.companies.map((comapny => <Company company={company} />))}
      </div>
    );
  }
}

export default Relay.createContainer(App, {
  fragments: {
    companies: () => Relay.QL`
      fragment on Companies {
        companies { ${Company.getFragment('company')} }
      }
    `,
  },
});

Second component

class Company extends React.Component {
  render() {
    return (
      <div>
        <h1>{this.props.comapany.name}</h1>
      </div>
    );
  }
}

export default Relay.createContainer(Company, {
  fragments: {
    company: () => Relay.QL`
      fragment on Company {
        __id,
        name
      }
    `,
  },
});

And my Route

class AppHomeRoute extends Relay.Route {
  static routeName = 'Comapnies';
  static queries = {
    companies: (Component) => Relay.QL`
      query {
        companies { ${Component.getFragment('companies')} }
      }
    `,
  };
}

Any ideas?

Sulfonate answered 10/10, 2016 at 13:45 Comment(3)
I'm having a similar issue. I have a list of events that I fetch with artists playing at that event, I tap on an artist, it shows the artist info and the events that that artist will be playing in, but the first event I tap on won't show up as the artist's event since it only returns __dataID__.Battlefield
Any solution to this?Goudy
@ChrisHarrison I managed to get one occurrence of this solved, but I can't fix another one that popped up.. have you?Battlefield

© 2022 - 2024 — McMap. All rights reserved.