sdy

update subscription

...@@ -15,7 +15,9 @@ export default withRouter(({ location }) => { ...@@ -15,7 +15,9 @@ export default withRouter(({ location }) => {
15 const { pathname } = location; 15 const { pathname } = location;
16 const roomName = pathname.slice(1, pathname.length); 16 const roomName = pathname.slice(1, pathname.length);
17 const [createMsg] = useMutation(CREATE_MESSAGE); 17 const [createMsg] = useMutation(CREATE_MESSAGE);
18 - const { data: subScription } = useSubscription(SUBSCRIPTION_MSG); 18 + const { data: subMessage } = useSubscription(SUBSCRIPTION_MSG);
19 +
20 + console.log("subMessage : ", subMessage);
19 21
20 const message = useInput(""); 22 const message = useInput("");
21 23
...@@ -46,18 +48,16 @@ export default withRouter(({ location }) => { ...@@ -46,18 +48,16 @@ export default withRouter(({ location }) => {
46 48
47 let testObj; 49 let testObj;
48 testObj = subscribeToMore({ 50 testObj = subscribeToMore({
49 - document: SUBSCRIPTION_MSG, 51 + document: subMessage,
50 updateQuery: (prev, { subscriptionData }) => { 52 updateQuery: (prev, { subscriptionData }) => {
51 console.log("prev : ", prev); 53 console.log("prev : ", prev);
52 console.log("subscriptionData : ", subscriptionData); 54 console.log("subscriptionData : ", subscriptionData);
53 - if (!subscriptionData.data) return prev; 55 + return {
54 - const newFeedItem = subscriptionData.data.subMessage; 56 + seeAllMessage: [
55 - console.log("newFeedItem : ", newFeedItem); 57 + ...prev.seeAllMessage,
56 - return Object.assign({}, prev, { 58 + subscriptionData.data.subMessage,
57 - seeAllMessage: { 59 + ],
58 - id, 60 + };
59 - },
60 - });
61 }, 61 },
62 }); 62 });
63 console.log(testObj); 63 console.log(testObj);
......