From 90bf1881f7b58766d3c3822e26b62b4a6fca538b Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 15 Jun 2023 16:45:38 +0200 Subject: [PATCH] message query is working --- backend/src/schema/resolvers/messages.spec.ts | 25 ++++++++++++++++--- backend/src/schema/resolvers/messages.ts | 9 +++---- backend/src/schema/types/type/Room.gql | 1 - 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/backend/src/schema/resolvers/messages.spec.ts b/backend/src/schema/resolvers/messages.spec.ts index e95d5d256..803418aad 100644 --- a/backend/src/schema/resolvers/messages.spec.ts +++ b/backend/src/schema/resolvers/messages.spec.ts @@ -183,8 +183,7 @@ describe('Message', () => { }) describe('room exists with authenticated user chatting', () => { - it('returns null', async () => { - console.log(roomId) + it('returns the messages', async () => { await expect(query({ query: messageQuery(), variables: { @@ -203,7 +202,27 @@ describe('Message', () => { }, }) }) - }) + }) + + describe('room exists, authenticated user not in room', () => { + beforeAll(async () => { + authenticatedUser = await notChattingUser.toJson() + }) + + it('returns null', async () => { + await expect(query({ + query: messageQuery(), + variables: { + roomId, + }, + })).resolves.toMatchObject({ + errors: undefined, + data: { + Message: [], + }, + }) + }) + }) }) }) }) diff --git a/backend/src/schema/resolvers/messages.ts b/backend/src/schema/resolvers/messages.ts index ac090e78f..b03b5e648 100644 --- a/backend/src/schema/resolvers/messages.ts +++ b/backend/src/schema/resolvers/messages.ts @@ -5,18 +5,15 @@ import Resolver from './helpers/Resolver' export default { Query: { Message: async (object, params, context, resolveInfo) => { - console.log('message query', params) const { roomId } = params - // if (!params.filter) params.filter = {} - /* + delete params.roomId + if (!params.filter) params.filter = {} params.filter.room = { - id_in: [roomId], + id: roomId, users_some: { id: context.user.id, }, } - */ - console.log(params.filter) return neo4jgraphql(object, params, context, resolveInfo) }, }, diff --git a/backend/src/schema/types/type/Room.gql b/backend/src/schema/types/type/Room.gql index 0cff02a32..c228c3a74 100644 --- a/backend/src/schema/types/type/Room.gql +++ b/backend/src/schema/types/type/Room.gql @@ -2,7 +2,6 @@ input _RoomFilter { AND: [_RoomFilter!] OR: [_RoomFilter!] id: ID - id_in: [ID!] users_some: _UserFilter }