In the following code, updateQuery
is provided by an npm module I'm using, so I can't modify it. I'd like to attach some info to an object, newsMsg
, that is going to be returned via updateQuery
. I have to use a promise to get that info.
Is there an approach to do something like this?
subscribe(fromID, toID, updateQuery) {
this.subscriptionObserver = this.props.client.subscribe({
query: IM_SUBSCRIPTION_QUERY,
variables: { fromID: this.fromID, toID: this.toID },
}).subscribe({
next(data) {
const newMsg = data.IMAdded;
//ATTACH INFO TO newMsg HERE VIA A PROMISE?
updateQuery((previousResult) => {
return update(
previousResult,
{
instant_message: {
$push: [newMsg],
},
}
);
});
},
error(err) {
console.error('err', err); },
});
}