mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Refactor 'groupMembersQuery' to a function that returns GQL
- Toast some Apollo GQL error messages
This commit is contained in:
parent
a85085ca74
commit
6f6dc4e7fd
@ -189,7 +189,8 @@ export const groupQuery = () => {
|
||||
`
|
||||
}
|
||||
|
||||
export const groupMembersQuery = gql`
|
||||
export const groupMembersQuery = () => {
|
||||
return gql`
|
||||
query ($id: ID!) {
|
||||
GroupMembers(id: $id) {
|
||||
id
|
||||
@ -198,4 +199,5 @@ export const groupMembersQuery = gql`
|
||||
myRoleInGroup
|
||||
}
|
||||
}
|
||||
`
|
||||
`
|
||||
}
|
||||
|
||||
@ -1049,7 +1049,7 @@ describe('in mode', () => {
|
||||
variables = {
|
||||
id: 'not-existing-group',
|
||||
}
|
||||
const { errors } = await query({ query: groupMembersQuery, variables })
|
||||
const { errors } = await query({ query: groupMembersQuery(), variables })
|
||||
expect(errors[0]).toHaveProperty('message', 'Not Authorized!')
|
||||
})
|
||||
})
|
||||
@ -1222,7 +1222,7 @@ describe('in mode', () => {
|
||||
|
||||
it('finds all members', async () => {
|
||||
const result = await query({
|
||||
query: groupMembersQuery,
|
||||
query: groupMembersQuery(),
|
||||
variables,
|
||||
})
|
||||
expect(result).toMatchObject({
|
||||
@ -1255,7 +1255,7 @@ describe('in mode', () => {
|
||||
|
||||
it('finds all members', async () => {
|
||||
const result = await query({
|
||||
query: groupMembersQuery,
|
||||
query: groupMembersQuery(),
|
||||
variables,
|
||||
})
|
||||
expect(result).toMatchObject({
|
||||
@ -1288,7 +1288,7 @@ describe('in mode', () => {
|
||||
|
||||
it('finds all members', async () => {
|
||||
const result = await query({
|
||||
query: groupMembersQuery,
|
||||
query: groupMembersQuery(),
|
||||
variables,
|
||||
})
|
||||
expect(result).toMatchObject({
|
||||
@ -1331,7 +1331,7 @@ describe('in mode', () => {
|
||||
|
||||
it('finds all members', async () => {
|
||||
const result = await query({
|
||||
query: groupMembersQuery,
|
||||
query: groupMembersQuery(),
|
||||
variables,
|
||||
})
|
||||
expect(result).toMatchObject({
|
||||
@ -1364,7 +1364,7 @@ describe('in mode', () => {
|
||||
|
||||
it('finds all members', async () => {
|
||||
const result = await query({
|
||||
query: groupMembersQuery,
|
||||
query: groupMembersQuery(),
|
||||
variables,
|
||||
})
|
||||
expect(result).toMatchObject({
|
||||
@ -1396,7 +1396,7 @@ describe('in mode', () => {
|
||||
})
|
||||
|
||||
it('throws authorization error', async () => {
|
||||
const { errors } = await query({ query: groupMembersQuery, variables })
|
||||
const { errors } = await query({ query: groupMembersQuery(), variables })
|
||||
expect(errors[0]).toHaveProperty('message', 'Not Authorized!')
|
||||
})
|
||||
})
|
||||
@ -1407,7 +1407,7 @@ describe('in mode', () => {
|
||||
})
|
||||
|
||||
it('throws authorization error', async () => {
|
||||
const { errors } = await query({ query: groupMembersQuery, variables })
|
||||
const { errors } = await query({ query: groupMembersQuery(), variables })
|
||||
expect(errors[0]).toHaveProperty('message', 'Not Authorized!')
|
||||
})
|
||||
})
|
||||
@ -1429,7 +1429,7 @@ describe('in mode', () => {
|
||||
|
||||
it('finds all members', async () => {
|
||||
const result = await query({
|
||||
query: groupMembersQuery,
|
||||
query: groupMembersQuery(),
|
||||
variables,
|
||||
})
|
||||
expect(result).toMatchObject({
|
||||
@ -1466,7 +1466,7 @@ describe('in mode', () => {
|
||||
|
||||
it('finds all members', async () => {
|
||||
const result = await query({
|
||||
query: groupMembersQuery,
|
||||
query: groupMembersQuery(),
|
||||
variables,
|
||||
})
|
||||
expect(result).toMatchObject({
|
||||
@ -1503,7 +1503,7 @@ describe('in mode', () => {
|
||||
|
||||
it('finds all members', async () => {
|
||||
const result = await query({
|
||||
query: groupMembersQuery,
|
||||
query: groupMembersQuery(),
|
||||
variables,
|
||||
})
|
||||
expect(result).toMatchObject({
|
||||
@ -1539,7 +1539,7 @@ describe('in mode', () => {
|
||||
})
|
||||
|
||||
it('throws authorization error', async () => {
|
||||
const { errors } = await query({ query: groupMembersQuery, variables })
|
||||
const { errors } = await query({ query: groupMembersQuery(), variables })
|
||||
expect(errors[0]).toHaveProperty('message', 'Not Authorized!')
|
||||
})
|
||||
})
|
||||
@ -1550,7 +1550,7 @@ describe('in mode', () => {
|
||||
})
|
||||
|
||||
it('throws authorization error', async () => {
|
||||
const { errors } = await query({ query: groupMembersQuery, variables })
|
||||
const { errors } = await query({ query: groupMembersQuery(), variables })
|
||||
expect(errors[0]).toHaveProperty('message', 'Not Authorized!')
|
||||
})
|
||||
})
|
||||
@ -2428,7 +2428,7 @@ describe('in mode', () => {
|
||||
describe('here "closed-group" for example', () => {
|
||||
const memberInGroup = async (userId, groupId) => {
|
||||
const result = await query({
|
||||
query: groupMembersQuery,
|
||||
query: groupMembersQuery(),
|
||||
variables: {
|
||||
id: groupId,
|
||||
},
|
||||
|
||||
@ -178,7 +178,8 @@ export const groupQuery = (i18n) => {
|
||||
`
|
||||
}
|
||||
|
||||
export const groupMembersQuery = gql`
|
||||
export const groupMembersQuery = () => {
|
||||
return gql`
|
||||
query ($id: ID!) {
|
||||
GroupMembers(id: $id) {
|
||||
id
|
||||
@ -187,4 +188,5 @@ export const groupMembersQuery = gql`
|
||||
myRoleInGroup
|
||||
}
|
||||
}
|
||||
`
|
||||
`
|
||||
}
|
||||
|
||||
@ -580,17 +580,23 @@ export default {
|
||||
// followingCount: this.followingCount,
|
||||
}
|
||||
},
|
||||
error(error) {
|
||||
this.$toast.error(error.message)
|
||||
},
|
||||
fetchPolicy: 'cache-and-network',
|
||||
},
|
||||
GroupMembers: {
|
||||
query() {
|
||||
return groupMembersQuery
|
||||
return groupMembersQuery()
|
||||
},
|
||||
variables() {
|
||||
return {
|
||||
id: this.$route.params.id,
|
||||
}
|
||||
},
|
||||
error(error) {
|
||||
this.$toast.error(error.message)
|
||||
},
|
||||
fetchPolicy: 'cache-and-network',
|
||||
},
|
||||
},
|
||||
|
||||
@ -32,6 +32,7 @@ export default {
|
||||
this.responseGroupListQuery = response.data.Group
|
||||
} catch (error) {
|
||||
this.responseGroupListQuery = []
|
||||
this.$toast.error(error.message)
|
||||
} finally {
|
||||
this.pending = false
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user