Part of my route is set up like so:
<Route path=":widgetId" component={Widget} queries={{
viewer: () => Relay.QL`query { viewer }`,
widget: () => Relay.QL`query { widget(widgetId: $widgetId) }`
}}>
<Route
path="details"
component={Details}
queries={{ widget: () => Relay.QL`query { widget(widgetId: $widgetId) }` }}
/>
</Route>
However, I get the following error:
Error: Invariant Violation: Relay(Details).getFragment(): `viewer` is not a valid fragment name. Available fragments names: `widget``.
Is the queries for route :widgetId
valid? If I remove viewer from the top level route, everything works.
EDIT: here is the Details Fragment:
export default Relay.createContainer(Details, {
fragments: {
widget: () => Relay.QL`
fragment on Widget {
id,
}
`
}
});
Edit: here are the Widget Fragments:
export default Relay.createContainer(Details, {
fragments: {
widget: () => Relay.QL`
fragment on Widget {
id,
}
`
viewer: () => Relay.QL`
fragment on Viewer {
id,
}
`
}
});
Note: I am using isomorphic-relay-router
It looks like you need to add a viewer fragment to your Widget class, i.e.: