sdy

update subscription

......@@ -15,7 +15,9 @@ export default withRouter(({ location }) => {
const { pathname } = location;
const roomName = pathname.slice(1, pathname.length);
const [createMsg] = useMutation(CREATE_MESSAGE);
const { data: subScription } = useSubscription(SUBSCRIPTION_MSG);
const { data: subMessage } = useSubscription(SUBSCRIPTION_MSG);
console.log("subMessage : ", subMessage);
const message = useInput("");
......@@ -46,18 +48,16 @@ export default withRouter(({ location }) => {
let testObj;
testObj = subscribeToMore({
document: SUBSCRIPTION_MSG,
document: subMessage,
updateQuery: (prev, { subscriptionData }) => {
console.log("prev : ", prev);
console.log("subscriptionData : ", subscriptionData);
if (!subscriptionData.data) return prev;
const newFeedItem = subscriptionData.data.subMessage;
console.log("newFeedItem : ", newFeedItem);
return Object.assign({}, prev, {
seeAllMessage: {
id,
},
});
return {
seeAllMessage: [
...prev.seeAllMessage,
subscriptionData.data.subMessage,
],
};
},
});
console.log(testObj);
......