My components have query fragments of the following form:
initialVariables : {
type : 'videos',
pageSize : 10,
community : 3
},
fragments: {
viewer: () => Relay.QL`
fragment on Viewer {
id,
newItemsAvailable(type : $type, community : $community),
newsFeedItems(first : $pageSize, type : $type, community : $community) {
pageInfo {
hasNextPage
},
edges {
cursor,
node {
...
}
}
}
}
`
},
I want to subscribe to changes in the field newItemsAvailable. To do so I would need the following getSubscription function:
getSubscription() {
return Relay.QL`
subscription {
newsFeedItemsAvailableSubscription(input: $input) {
viewer {
newItemsAvailable(type : $type, community : $community)
}
}
}
`;
}
I can't omit (type : $type, community : $community) from here since that would give an error. In the worst case I would have to send dummy hardcoded values.
I guess
subscriptions: [
({ viewer, type, community }) => new NewsFeedItemsAvailableSubscription({ viewer, type, community }),
]
and
getVariables() {
return {
id: this.props.viewer.id,
type: this.props.type,
community: this.props.community
};
}
feed the values of type and community into $input through ...subscription.getVariables(). However, how can I make them available in newItemsAvailable(type : $type, community : $community). I haven't looked into the source code of Relay so have no clue of how all this generally works.
My components have query fragments of the following form:
I want to subscribe to changes in the field
newItemsAvailable. To do so I would need the following getSubscription function:I can't omit
(type : $type, community : $community)from here since that would give an error. In the worst case I would have to send dummy hardcoded values.I guess
and
feed the values of type and community into $input through
...subscription.getVariables(). However, how can I make them available innewItemsAvailable(type : $type, community : $community). I haven't looked into the source code of Relay so have no clue of how all this generally works.