diff --git a/backend/src/schema/resolvers/users/blockedUsers.spec.js b/backend/src/schema/resolvers/users/blockedUsers.spec.js new file mode 100644 index 000000000..4a42f1c5c --- /dev/null +++ b/backend/src/schema/resolvers/users/blockedUsers.spec.js @@ -0,0 +1,44 @@ +import { createTestClient } from 'apollo-server-testing' +import createServer from '../../../server' +import { gql } from '../../../jest/helpers' + +describe('blockedUsers', () => { + it.todo('throws permission error') + + describe('authenticated', () => { + it.todo('returns a list of blocked users') + }) +}) + +describe('block', () => { + it.todo('throws permission error') + + describe('authenticated', () => { + it.todo('throws argument error') + + describe('given a to-be-blocked user', () => { + it.todo('blocks a user') + + describe('blocked user writes a post', () => { + it.todo('disappears in the newsfeed of the current user') + }) + + describe('current user writes a post', () => { + it.todo('disappears in the newsfeed of the blocked user') + }) + }) + }) +}) + +describe('unblock', () => { + it.todo('throws permission error') + describe('authenticated', () => { + it.todo('throws argument error') + describe('given a blocked user', () => { + it.todo('unblocks a user') + describe('unblocking twice', () => { + it.todo('has no effect') + }) + }) + }) +}) diff --git a/backend/src/schema/types/type/User.gql b/backend/src/schema/types/type/User.gql index 2534463d1..b58b64ac3 100644 --- a/backend/src/schema/types/type/User.gql +++ b/backend/src/schema/types/type/User.gql @@ -42,6 +42,12 @@ type User { RETURN COUNT(u) >= 1 """ ) + isBlocked: Boolean! @cypher( + statement: """ + MATCH (this)-[:BLOCKED]->(u:User {id: $cypherParams.currentUserId}) + RETURN COUNT(u) >= 1 + """ + ) #contributions: [WrittenPost]! #contributions2(first: Int = 10, offset: Int = 0): [WrittenPost2]! @@ -164,4 +170,9 @@ type Mutation { ): User DeleteUser(id: ID!, resource: [Deletable]): User + + + block(id: ID!): User + unblock(id: ID!): User + blockedUsers: [User] }