diff --git a/backend/src/db/graphql/groups.js b/backend/src/db/graphql/groups.js index 2758b5fbf..425cde49f 100644 --- a/backend/src/db/graphql/groups.js +++ b/backend/src/db/graphql/groups.js @@ -122,16 +122,18 @@ export const joinGroupMutation = () => { ` } -export const leaveGroupMutation = gql` - mutation ($groupId: ID!, $userId: ID!) { - LeaveGroup(groupId: $groupId, userId: $userId) { - id - name - slug - myRoleInGroup +export const leaveGroupMutation = () => { + return gql` + mutation ($groupId: ID!, $userId: ID!) { + LeaveGroup(groupId: $groupId, userId: $userId) { + id + name + slug + myRoleInGroup + } } - } -` + ` +} export const changeGroupMemberRoleMutation = gql` mutation ($groupId: ID!, $userId: ID!, $roleInGroup: GroupMemberRole!) { diff --git a/backend/src/schema/resolvers/groups.spec.js b/backend/src/schema/resolvers/groups.spec.js index d1864b58a..6f3fd1fb6 100644 --- a/backend/src/schema/resolvers/groups.spec.js +++ b/backend/src/schema/resolvers/groups.spec.js @@ -2411,7 +2411,7 @@ describe('in mode', () => { describe('unauthenticated', () => { it('throws authorization error', async () => { const { errors } = await mutate({ - mutation: leaveGroupMutation, + mutation: leaveGroupMutation(), variables: { groupId: 'not-existing-group', userId: 'current-user', @@ -2450,7 +2450,7 @@ describe('in mode', () => { authenticatedUser = await pendingMemberUser.toJson() await expect( mutate({ - mutation: leaveGroupMutation, + mutation: leaveGroupMutation(), variables: { ...variables, userId: 'pending-member-user', @@ -2477,7 +2477,7 @@ describe('in mode', () => { authenticatedUser = await usualMemberUser.toJson() await expect( mutate({ - mutation: leaveGroupMutation, + mutation: leaveGroupMutation(), variables: { ...variables, userId: 'usual-member-user', @@ -2504,7 +2504,7 @@ describe('in mode', () => { authenticatedUser = await adminMemberUser.toJson() await expect( mutate({ - mutation: leaveGroupMutation, + mutation: leaveGroupMutation(), variables: { ...variables, userId: 'admin-member-user', @@ -2528,7 +2528,7 @@ describe('in mode', () => { it('throws authorization error', async () => { authenticatedUser = await ownerMemberUser.toJson() const { errors } = await mutate({ - mutation: leaveGroupMutation, + mutation: leaveGroupMutation(), variables: { ...variables, userId: 'owner-member-user', @@ -2542,7 +2542,7 @@ describe('in mode', () => { it('throws authorization error', async () => { authenticatedUser = await secondOwnerMemberUser.toJson() const { errors } = await mutate({ - mutation: leaveGroupMutation, + mutation: leaveGroupMutation(), variables: { ...variables, userId: 'second-owner-member-user', @@ -2556,7 +2556,7 @@ describe('in mode', () => { it('throws authorization error', async () => { authenticatedUser = await noMemberUser.toJson() const { errors } = await mutate({ - mutation: leaveGroupMutation, + mutation: leaveGroupMutation(), variables: { ...variables, userId: 'none-member-user', @@ -2570,7 +2570,7 @@ describe('in mode', () => { it('throws authorization error', async () => { authenticatedUser = await ownerMemberUser.toJson() const { errors } = await mutate({ - mutation: leaveGroupMutation, + mutation: leaveGroupMutation(), variables: { ...variables, userId: 'usual-member-user', @@ -2584,7 +2584,7 @@ describe('in mode', () => { it('throws authorization error', async () => { authenticatedUser = await usualMemberUser.toJson() const { errors } = await mutate({ - mutation: leaveGroupMutation, + mutation: leaveGroupMutation(), variables: { ...variables, userId: 'admin-member-user', diff --git a/webapp/components/Button/JoinLeaveButton.vue b/webapp/components/Button/JoinLeaveButton.vue index f3e1c0afd..6aa4a398d 100644 --- a/webapp/components/Button/JoinLeaveButton.vue +++ b/webapp/components/Button/JoinLeaveButton.vue @@ -108,7 +108,7 @@ export default { }, async joinLeave() { const join = !this.isMember - const mutation = join ? joinGroupMutation() : leaveGroupMutation + const mutation = join ? joinGroupMutation() : leaveGroupMutation() this.hovered = false this.$emit('prepare', join) diff --git a/webapp/graphql/groups.js b/webapp/graphql/groups.js index 2bf78bd33..00f847488 100644 --- a/webapp/graphql/groups.js +++ b/webapp/graphql/groups.js @@ -113,16 +113,18 @@ export const joinGroupMutation = () => { ` } -export const leaveGroupMutation = gql` - mutation ($groupId: ID!, $userId: ID!) { - LeaveGroup(groupId: $groupId, userId: $userId) { - id - name - slug - myRoleInGroup +export const leaveGroupMutation = () => { + return gql` + mutation ($groupId: ID!, $userId: ID!) { + LeaveGroup(groupId: $groupId, userId: $userId) { + id + name + slug + myRoleInGroup + } } - } -` + ` +} export const changeGroupMemberRoleMutation = gql` mutation ($groupId: ID!, $userId: ID!, $roleInGroup: GroupMemberRole!) {