Skip to content

Instantly share code, notes, and snippets.

@nickretallack
Last active October 13, 2015 08:14
Show Gist options
  • Save nickretallack/66ebbfdc920393bcf649 to your computer and use it in GitHub Desktop.
Save nickretallack/66ebbfdc920393bcf649 to your computer and use it in GitHub Desktop.
Why can't I put more than one level of
Uncaught Error: Invariant Violation: Relay.QL: Expected query `viewer` to be empty. For example, use `node(id: $id)`, not `node(id: $id) { ... }`.
import 'babel/polyfill';
class App extends React.Component {
render() {
return (
<div>
<h1>Widget list</h1>
<ul>
{this.props.edges.map(edge =>
<li>{edge.node.name} (ID: {edge.node.id})</li>
)}
</ul>
</div>
);
}
}
export default Relay.createContainer(App, {
fragments: {
edges: () => Relay.QL`
fragment on WidgetEdge {
node {
id,
name,
},
}
`,
},
});
export default class extends Relay.Route {
static queries = {
edges: () => Relay.QL`
query {
viewer {
widgets(first: 10) {
edges
}
}
}
`,
};
static routeName = 'AppHomeRoute';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment