diff --git a/backend/src/graphql/messages.ts b/backend/src/graphql/messages.ts index fde45083b..2842c7230 100644 --- a/backend/src/graphql/messages.ts +++ b/backend/src/graphql/messages.ts @@ -27,6 +27,9 @@ export const messageQuery = () => { indexId content senderId + author { + id + } username avatar date diff --git a/backend/src/graphql/rooms.ts b/backend/src/graphql/rooms.ts index 294b50641..a5cd1841b 100644 --- a/backend/src/graphql/rooms.ts +++ b/backend/src/graphql/rooms.ts @@ -9,6 +9,7 @@ export const createRoomMutation = () => { roomName lastMessageAt unreadCount + #avatar users { _id id @@ -29,6 +30,7 @@ export const roomQuery = () => { id roomId roomName + avatar lastMessageAt unreadCount lastMessage { diff --git a/webapp/graphql/Messages.js b/webapp/graphql/Messages.js index 86b9c81ca..01ba413f4 100644 --- a/webapp/graphql/Messages.js +++ b/webapp/graphql/Messages.js @@ -1,5 +1,16 @@ import gql from 'graphql-tag' +export const createMessageMutation = () => { + return gql` + mutation ($roomId: ID!, $content: String!) { + CreateMessage(roomId: $roomId, content: $content) { + id + content + } + } + ` +} + export const messageQuery = () => { return gql` query ($roomId: ID!, $first: Int, $offset: Int) { @@ -23,17 +34,6 @@ export const messageQuery = () => { ` } -export const createMessageMutation = () => { - return gql` - mutation ($roomId: ID!, $content: String!) { - CreateMessage(roomId: $roomId, content: $content) { - id - content - } - } - ` -} - export const markMessagesAsSeen = () => { return gql` mutation ($messageIds: [String!]) { diff --git a/webapp/graphql/Rooms.js b/webapp/graphql/Rooms.js index 68baccf3f..a7414ecb7 100644 --- a/webapp/graphql/Rooms.js +++ b/webapp/graphql/Rooms.js @@ -1,5 +1,14 @@ import gql from 'graphql-tag' +export const createRoom = () => gql` + mutation ($userId: ID!) { + CreateRoom(userId: $userId) { + id + roomId + } + } +` + export const roomQuery = () => gql` query Room($first: Int, $offset: Int, $id: ID) { Room(first: $first, offset: $offset, id: $id, orderBy: createdAt_desc) { @@ -7,6 +16,20 @@ export const roomQuery = () => gql` roomId roomName avatar + lastMessageAt + unreadCount + lastMessage { + _id + id + content + senderId + username + avatar + date + saved + distributed + seen + } users { _id id @@ -19,15 +42,6 @@ export const roomQuery = () => gql` } ` -export const createRoom = () => gql` - mutation ($userId: ID!) { - CreateRoom(userId: $userId) { - id - roomId - } - } -` - export const unreadRoomsQuery = () => { return gql` query {