diff --git a/backend/src/graphql/messages.ts b/backend/src/graphql/messages.ts index fde45083be..2842c7230f 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 b35a3e9993..7612641f3e 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 13d27ac58f..e6292c5098 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 chatMessageAdded = () => { return gql` subscription chatMessageAdded($userId: ID!) { diff --git a/webapp/graphql/Rooms.js b/webapp/graphql/Rooms.js index bbdd95a048..757a6cfa47 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: lastMessageAt_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 {