Reputation: 7986
I'm getting Invariant Violation: RelayQL: Invalid fragment composition, use `${Child.getFragment('name')}`.
in the following. I've no idea why, and nothing seems to fix it. My component contains:
fragments: {
album: () => Relay.QL`
fragment on Album {
${AlbumMutation.getFragment('album')}
}
`,
},
AlbumMutation contains:
static fragments = {
album: () => Relay.QL`
fragment on Album {
id
}
`,
}
Upvotes: 2
Views: 408
Reputation: 1743
I was able to fix this in ES6 by removing my React/Relay imports from the component.
import React from 'react';
import Relay from 'react-relay';
class ...
Upvotes: 0
Reputation: 111
To anybody who runs into this, its probably due to the examples loading the React, Relay, and ReactDOM libs in the public/index.html
file, instead of using the webpack import X from 'y';
. If you are attempting to use the react-relay-router library, you have to use the latter, but having two copies of Relay will cause this error to occur.
I was able to fix this by removing the references in public/index.html
, but its good to know that double-importing relay does seem to break this!
Upvotes: 2