diff --git a/subscriptions-with-apollo-worldchat/package.json b/subscriptions-with-apollo-worldchat/package.json index 4bde689..0403971 100755 --- a/subscriptions-with-apollo-worldchat/package.json +++ b/subscriptions-with-apollo-worldchat/package.json @@ -19,7 +19,8 @@ "react-apollo": "^2.0.0", "react-dom": "^16.0.0", "react-google-maps": "^9.2.1", - "sillyname": "^0.1.0" + "sillyname": "^0.1.0", + "subscriptions-transport-ws": "^0.9.7" }, "scripts": { "start": "react-scripts start", diff --git a/subscriptions-with-apollo-worldchat/src/components/Chat.js b/subscriptions-with-apollo-worldchat/src/components/Chat.js index 7bf5e40..dba60ef 100755 --- a/subscriptions-with-apollo-worldchat/src/components/Chat.js +++ b/subscriptions-with-apollo-worldchat/src/components/Chat.js @@ -63,7 +63,7 @@ class Chat extends Component { } `, updateQuery: (previousState, {subscriptionData}) => { - const newMessage = subscriptionData.Message.node + const newMessage = subscriptionData.data.Message.node const messages = previousState.allMessages.concat([newMessage]) return { allMessages: messages diff --git a/subscriptions-with-apollo-worldchat/src/components/WorldChat.js b/subscriptions-with-apollo-worldchat/src/components/WorldChat.js index 59417e6..ceab2a9 100755 --- a/subscriptions-with-apollo-worldchat/src/components/WorldChat.js +++ b/subscriptions-with-apollo-worldchat/src/components/WorldChat.js @@ -132,16 +132,16 @@ class WorldChat extends Component { `, variables: null, updateQuery: (previousState, {subscriptionData}) => { - if (subscriptionData.Location.mutation === 'CREATED') { - const newLocation = subscriptionData.Location.node + if (subscriptionData.data.Location.mutation === 'CREATED') { + const newLocation = subscriptionData.data.Location.node const locations = previousState.allLocations.concat([newLocation]) return { allLocations: locations, } } - else if (subscriptionData.Location.mutation === 'UPDATED') { + else if (subscriptionData.data.Location.mutation === 'UPDATED') { const locations = previousState.allLocations.slice() - const updatedLocation = subscriptionData.Location.node + const updatedLocation = subscriptionData.data.Location.node const oldLocationIndex = locations.findIndex(location => { return updatedLocation.id === location.id }) @@ -369,4 +369,4 @@ export default compose( graphql(allLocations, {name: 'allLocationsQuery'}), graphql(createLocationAndTraveller, {name: 'createLocationAndTravellerMutation'}), graphql(updateLocation, {name: 'updateLocationMutation'}) -)(withApollo(WorldChat)) \ No newline at end of file +)(withApollo(WorldChat))