mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Change GQL parameter for 'JoinGroup' from 'id' to 'groupId'
Co-Authored-By: Mogge <moriz.wahl@gmx.de>
This commit is contained in:
parent
826cf5a8e0
commit
813c072dc7
@ -40,8 +40,8 @@ export const createGroupMutation = gql`
|
||||
`
|
||||
|
||||
export const joinGroupMutation = gql`
|
||||
mutation ($id: ID!, $userId: ID!) {
|
||||
JoinGroup(id: $id, userId: $userId) {
|
||||
mutation ($groupId: ID!, $userId: ID!) {
|
||||
JoinGroup(groupId: $groupId, userId: $userId) {
|
||||
id
|
||||
name
|
||||
slug
|
||||
|
||||
@ -408,28 +408,28 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'g0',
|
||||
groupId: 'g0',
|
||||
userId: 'u2',
|
||||
},
|
||||
}),
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'g0',
|
||||
groupId: 'g0',
|
||||
userId: 'u3',
|
||||
},
|
||||
}),
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'g0',
|
||||
groupId: 'g0',
|
||||
userId: 'u4',
|
||||
},
|
||||
}),
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'g0',
|
||||
groupId: 'g0',
|
||||
userId: 'u6',
|
||||
},
|
||||
}),
|
||||
@ -480,35 +480,35 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'g1',
|
||||
groupId: 'g1',
|
||||
userId: 'u1',
|
||||
},
|
||||
}),
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'g1',
|
||||
groupId: 'g1',
|
||||
userId: 'u2',
|
||||
},
|
||||
}),
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'g1',
|
||||
groupId: 'g1',
|
||||
userId: 'u5',
|
||||
},
|
||||
}),
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'g1',
|
||||
groupId: 'g1',
|
||||
userId: 'u6',
|
||||
},
|
||||
}),
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'g1',
|
||||
groupId: 'g1',
|
||||
userId: 'u7',
|
||||
},
|
||||
}),
|
||||
@ -567,28 +567,28 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'g2',
|
||||
groupId: 'g2',
|
||||
userId: 'u4',
|
||||
},
|
||||
}),
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'g2',
|
||||
groupId: 'g2',
|
||||
userId: 'u5',
|
||||
},
|
||||
}),
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'g2',
|
||||
groupId: 'g2',
|
||||
userId: 'u6',
|
||||
},
|
||||
}),
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'g2',
|
||||
groupId: 'g2',
|
||||
userId: 'u7',
|
||||
},
|
||||
}),
|
||||
|
||||
@ -172,7 +172,7 @@ const isAllowedToJoinGroup = rule({
|
||||
cache: 'no_cache',
|
||||
})(async (_parent, args, { user, driver }) => {
|
||||
if (!(user && user.id)) return false
|
||||
const { id: groupId, userId } = args
|
||||
const { groupId, userId } = args
|
||||
// Wolle:
|
||||
// console.log('adminId: ', adminId)
|
||||
// console.log('groupId: ', groupId)
|
||||
|
||||
@ -131,7 +131,7 @@ export default {
|
||||
}
|
||||
},
|
||||
JoinGroup: async (_parent, params, context, _resolveInfo) => {
|
||||
const { id: groupId, userId } = params
|
||||
const { groupId, userId } = params
|
||||
const session = context.driver.session()
|
||||
const writeTxResultPromise = session.writeTransaction(async (transaction) => {
|
||||
const joinGroupCypher = `
|
||||
|
||||
@ -316,11 +316,13 @@ describe('in mode: always clean db', () => {
|
||||
describe('JoinGroup', () => {
|
||||
describe('unauthenticated', () => {
|
||||
it('throws authorization error', async () => {
|
||||
variables = {
|
||||
id: 'not-existing-group',
|
||||
userId: 'current-user',
|
||||
}
|
||||
const { errors } = await mutate({ mutation: joinGroupMutation, variables })
|
||||
const { errors } = await mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
groupId: 'not-existing-group',
|
||||
userId: 'current-user',
|
||||
},
|
||||
})
|
||||
expect(errors[0]).toHaveProperty('message', 'Not Authorised!')
|
||||
})
|
||||
})
|
||||
@ -403,7 +405,7 @@ describe('in mode: always clean db', () => {
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'public-group',
|
||||
groupId: 'public-group',
|
||||
userId: 'owner-of-closed-group',
|
||||
},
|
||||
}),
|
||||
@ -426,7 +428,7 @@ describe('in mode: always clean db', () => {
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'public-group',
|
||||
groupId: 'public-group',
|
||||
userId: 'current-user',
|
||||
},
|
||||
}),
|
||||
@ -451,7 +453,7 @@ describe('in mode: always clean db', () => {
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'closed-group',
|
||||
groupId: 'closed-group',
|
||||
userId: 'current-user',
|
||||
},
|
||||
}),
|
||||
@ -474,7 +476,7 @@ describe('in mode: always clean db', () => {
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'closed-group',
|
||||
groupId: 'closed-group',
|
||||
userId: 'owner-of-closed-group',
|
||||
},
|
||||
}),
|
||||
@ -495,11 +497,13 @@ describe('in mode: always clean db', () => {
|
||||
describe('hidden group', () => {
|
||||
describe('joined by "owner-of-closed-group"', () => {
|
||||
it('throws authorization error', async () => {
|
||||
variables = {
|
||||
id: 'hidden-group',
|
||||
userId: 'owner-of-closed-group',
|
||||
}
|
||||
const { errors } = await query({ query: groupMembersQuery, variables })
|
||||
const { errors } = await query({
|
||||
query: joinGroupMutation,
|
||||
variables: {
|
||||
groupId: 'hidden-group',
|
||||
userId: 'owner-of-closed-group',
|
||||
},
|
||||
})
|
||||
expect(errors[0]).toHaveProperty('message', 'Not Authorised!')
|
||||
})
|
||||
})
|
||||
@ -511,7 +515,7 @@ describe('in mode: always clean db', () => {
|
||||
mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'hidden-group',
|
||||
groupId: 'hidden-group',
|
||||
userId: 'owner-of-hidden-group',
|
||||
},
|
||||
}),
|
||||
@ -622,14 +626,14 @@ describe('in mode: building up – separate for each resolver', () => {
|
||||
await mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'public-group',
|
||||
groupId: 'public-group',
|
||||
userId: 'owner-of-closed-group',
|
||||
},
|
||||
})
|
||||
await mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'public-group',
|
||||
groupId: 'public-group',
|
||||
userId: 'owner-of-hidden-group',
|
||||
},
|
||||
})
|
||||
@ -650,14 +654,14 @@ describe('in mode: building up – separate for each resolver', () => {
|
||||
await mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'closed-group',
|
||||
groupId: 'closed-group',
|
||||
userId: 'current-user',
|
||||
},
|
||||
})
|
||||
await mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'closed-group',
|
||||
groupId: 'closed-group',
|
||||
userId: 'owner-of-hidden-group',
|
||||
},
|
||||
})
|
||||
@ -1158,14 +1162,14 @@ describe('in mode: building up – separate for each resolver', () => {
|
||||
await mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'public-group',
|
||||
groupId: 'public-group',
|
||||
userId: 'owner-of-closed-group',
|
||||
},
|
||||
})
|
||||
await mutate({
|
||||
mutation: joinGroupMutation,
|
||||
variables: {
|
||||
id: 'public-group',
|
||||
groupId: 'public-group',
|
||||
userId: 'owner-of-hidden-group',
|
||||
},
|
||||
})
|
||||
|
||||
@ -115,7 +115,7 @@ type Mutation {
|
||||
DeleteGroup(id: ID!): Group
|
||||
|
||||
JoinGroup(
|
||||
id: ID!
|
||||
groupId: ID!
|
||||
userId: ID!
|
||||
): User
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user