I'm trying Relay in my React application, and it uses GraphQL by default. It looks like this (Score
is some React.js component):
Score = Relay.createContainer(Score, {
fragments: {
score: () => Relay.QL`
fragment on Score {
initials,
score,
}
`,
},
});
The question is: can I use custom API functions to return data into fragments? Like this:
Score = Relay.createContainer(Score, {
fragments: {
score: myCustomFunction(), // It will return a dataset.
},
});
No, not yet. Support for augmenting the server schema with "local" data is being discussed in this GitHub issue.
In the meantime, you have two options: