I'm trying to use forceFetch() to update the UI upon receiving a server-side push notification, but I'm getting the following error in the browser console (no actual graphql query on the network EDIT: the query actually reached the server):
Server request for query Main failed for the following reasons:
1. args is not defined
query Main{node(id:"QWNjb3VudDow"){...F1}} fragment F0 on Si
^^^
Here's the simplified portion of code:
@relayContainer({
fragments: {
account: () => Relay.QL` fragment on Account {
id
userInSite {
id
site {
id
name
}
}
}`,
},
})
class SiteSettings extends Component {
render() {
return <div>
{this.props.account.userInSite.site.name}
</div>;
}
componentWillMount() {
setTimeout(() => this.props.relay.forceFetch(), 2000);
}
}
I'm not sure what that args
refers to. I tried passing parameters to forceFetch
, but none of my attempts worked.
What am I doing wrong?
It turns out I was looking in the wrong place (the browser), when really the error was coming from the server.
It was pointed out to me (thanks Discord user group!) that errors presented in this form always come from the server.
Specifically, args
is the second parameter to the resolve
functions in the GraphQL schema. It turns out that my globalID to object function (nodeDefinitions
imported from graphql-relay
) had an error due to bad copy and paste from a resolve function, where there was indeed an args
parameter that was now missing instead.