Skip to content

Commit 24ec7ab

Browse files
committed
converted to single mutation
1 parent 5a050d5 commit 24ec7ab

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

src/components/Vote.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ const Vote = (props) => {
4747
setVoted(false)
4848
setVotes((votes) => votes - 1)
4949
} else {
50-
const response = await userStory.updateStoryVote(
51-
story.id,
52-
followers,
53-
userId
54-
)
55-
const updatedFollowerIds = response.data.data.updateUserStory.userStory.followers.map(
50+
followers.push(JSON.stringify(userId))
51+
let updatedFollowerIds = followers
52+
const response = await userStory.updateVotes(story.id, updatedFollowerIds)
53+
updatedFollowerIds = response.data.data.updateUserStory.userStory.followers.map(
5654
(follower) => JSON.stringify(follower.id)
5755
)
5856
setFollowers(updatedFollowerIds)

src/services/user_story.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -442,22 +442,6 @@ const userStory = {
442442
`
443443
}
444444
return apiCall('/graphql', updateVotesQuery)
445-
},
446-
updateStoryVote: (storyId, followers, userId) => {
447-
const updateStoryVoteQuery = {
448-
query: `
449-
mutation {
450-
updateUserStory(input: {where: {id: "${storyId}"} data: {followers: [${followers}, "${userId}"]}}){
451-
userStory{
452-
followers {
453-
id
454-
}
455-
}
456-
}
457-
}
458-
`
459-
}
460-
return apiCall('/graphql', updateStoryVoteQuery)
461445
}
462446
}
463447

0 commit comments

Comments
 (0)