trying last message prop in room

This commit is contained in:
Moriz Wahl 2023-07-14 09:11:32 +02:00
parent 032bca1b64
commit 5376e171bd
2 changed files with 7 additions and 1 deletions

View File

@ -131,13 +131,17 @@ describe('Message', () => {
})
describe('room is updated as well', () => {
it('has last message at set', async () => {
it('has last message set', async () => {
await expect(query({ query: roomQuery() })).resolves.toMatchObject({
errors: undefined,
data: {
Room: [
expect.objectContaining({
lastMessageAt: expect.any(String),
lastMessage: expect.objectContaining({
id: expect.any(String),
content: 'Some nice message to other chatting user',
})
}),
],
},

View File

@ -17,6 +17,8 @@ type Room {
avatar: String! @cypher(statement: "MATCH (this)<-[:CHATS_IN]-(user:User) WHERE NOT user.id = $cypherParams.currentUserId RETURN user.avatar.url")
lastMessageAt: String
lastMessage: Message @cypher(statement: "MATCH (this)<-[:INSIDE]-(message:Message) RETURN message ORDER BY message.createdAt DESC LIMIT 1")
}
type Mutation {