I am trying to perform a subscription for my query. So my suspicion is that the connection (from the ConnectionHandler) is not working. I cannot find any proper documentation on this one.
My subscription looks like:
const LinkSubscription = graphql`
subscription LinkSubscription {
Link(filter:{
mutation_in:[CREATED]
}){
node{
id
}
}
}
`;
export default () => {
const subscriptionConfig = {
subscription: LinkSubscription,
variables: {},
onCompleted: () => { alert('done!'); },
updater: (Store, data) => {
const newLink = Store.getRootField('Link').getLinkedRecord('node');
const allLinks = Store.getRoot();
const edge = ConnectionHandler.createEdge(Store, allLinks, newLink, 'allLinks');
const userId = localStorage.getItem('user_id');
const connection = ConnectionHandler.getConnection(allLinks, newLink, 'allLinks');
if (connection) {
ConnectionHandler.insertEdgeAfter(connection, newLink);
console.log('DONE');
}
console.log('DEBUG', Store);
console.log('DEBUG2', newLink);
console.log('DEBUG3', allLinks);
console.log('DEBUG4', edge);
console.log('DEBUG5', connection);
console.log('DEBUG6', ConnectionHandler);
console.log('DEBUG7', userId);
console.log('Debug8', data);
},
onError: error => console.log('An error occured:', error),
};
requestSubscription(Environment, subscriptionConfig);
};
As you may see in the code i ran a lot of logs to see what i did wrong.
Log DEBUG fires: RelayRecordSourceSelectorProxy
,
Log DEBUG2 fires:RelayRecordProxy
// for the specific id(59f88d417fae441eb567c453) CREATED,
Log DEBUG3 fires: RelayRecordProxy
// for client:root,
Log DEBUG4 fires: RelayRecordProxy
// for client:root:59f88d417fae441eb567c453,
Log DEBUG5: undefined
,
Log DEBUG6: ConnectionHandler
methods,
Log DEBUG7: user.id
who requested the query.
Question1:Can you please help with some connection suggestions?