Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated chat schema #2466

Open
wants to merge 102 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 97 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
a8c02f8
Updated subscriptions and added mutations for directChat and groupChat
disha1202 Jul 15, 2024
fe6907d
Update index.ts
disha1202 Jul 16, 2024
3a9799d
Update messageSentToDirectChat.ts
disha1202 Jul 16, 2024
2fa65b1
Update createDirectChat.spec.ts
disha1202 Jul 16, 2024
f68bb01
Update createDirectChat.spec.ts
disha1202 Jul 16, 2024
f7089b9
fix: linting errors
disha1202 Jul 16, 2024
2fe5353
fix: lint errors
disha1202 Jul 16, 2024
7e31c14
fix: formatting issues
disha1202 Jul 16, 2024
0bf28a2
Merge branch 'develop' into chat-feature
disha1202 Jul 16, 2024
9c44ea4
fix: formatting issues
disha1202 Jul 16, 2024
fa5f6ec
fix: test cases
disha1202 Jul 16, 2024
3db8381
fix test cases
disha1202 Jul 16, 2024
a1379bf
Update messageSentToDirectChat.ts
disha1202 Jul 18, 2024
bd98a6b
Update messageSentToDirectChat.ts
disha1202 Jul 18, 2024
7ec1773
added test cases for query directChatById
Jul 18, 2024
3781ede
Update directChatById.spec.ts
disha1202 Jul 18, 2024
8aaf5f3
Update directChatById.spec.ts
disha1202 Jul 18, 2024
e83657d
Update directChatById.spec.ts
disha1202 Jul 18, 2024
23a9676
Added test cases
disha1202 Jul 18, 2024
9576d4a
fix: test cases
disha1202 Jul 18, 2024
c2af22d
fix: tests
disha1202 Jul 18, 2024
ad48619
fix test cases
disha1202 Jul 18, 2024
77c7fde
Merge branch 'chat-feature' of https://github.com/disha1202/talawa-ap…
disha1202 Jul 18, 2024
d18843a
added support to reply to direct chat and group chat
disha1202 Jul 24, 2024
cf27ca6
Merge branch 'develop' of https://github.com/disha1202/talawa-api int…
disha1202 Jul 24, 2024
8469653
fix: test cases
disha1202 Jul 24, 2024
87ad70f
updated schema for chat
disha1202 Jul 28, 2024
f936adc
removed console logs
disha1202 Jul 28, 2024
babf1c0
Merge branch 'develop' into reply-functionality
disha1202 Jul 28, 2024
c84f33a
Merge branch 'develop' into reply-functionality
disha1202 Jul 30, 2024
33535ac
Added tests for chat
disha1202 Aug 8, 2024
98d06a7
fix format
disha1202 Aug 8, 2024
5a61b43
fix test cases
disha1202 Aug 8, 2024
a84f1c6
fix tests
disha1202 Aug 8, 2024
4d65b03
fix tests
disha1202 Aug 8, 2024
c23008b
fix: test cases
disha1202 Aug 9, 2024
a539e3e
fix: test cases
disha1202 Aug 9, 2024
074b79c
fix: test cases
disha1202 Aug 10, 2024
9926e63
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
disha1202 Aug 10, 2024
1586732
added test cases
disha1202 Aug 15, 2024
8b873ea
Merge branch 'schema-update' of https://github.com/disha1202/talawa-a…
disha1202 Aug 15, 2024
15d6bed
removed unwanted code
disha1202 Aug 18, 2024
46d4f5f
Removed unwanted code
disha1202 Aug 18, 2024
ce20fe0
Merge branch 'develop' into schema-update
disha1202 Aug 18, 2024
dcd6006
fix: lint errors
disha1202 Aug 18, 2024
ea23279
Merge branch 'schema-update' of https://github.com/disha1202/talawa-a…
disha1202 Aug 18, 2024
ef2d45d
Merge branch 'develop' into reply-functionality
disha1202 Aug 18, 2024
a2ccfb0
Removed unwanted code
disha1202 Aug 18, 2024
52165f1
Merge branch 'reply-functionality' of https://github.com/disha1202/ta…
disha1202 Aug 18, 2024
ff1987f
Merge branch 'develop' into schema-update
disha1202 Aug 21, 2024
369a81d
Merge branch 'develop' into reply-functionality
disha1202 Aug 21, 2024
7cd8040
Merge branch 'develop' into schema-update
disha1202 Aug 21, 2024
979bf37
Merge branch 'develop' into reply-functionality
disha1202 Aug 21, 2024
f29ac65
Merge branch 'develop' into schema-update
disha1202 Aug 23, 2024
dd9120f
Merge branch 'develop' into reply-functionality
disha1202 Aug 23, 2024
a440bad
fix: chat documentation
disha1202 Aug 23, 2024
615a5ac
Merge branch 'schema-update' of https://github.com/disha1202/talawa-a…
disha1202 Aug 23, 2024
5ad1d76
Merge branch 'develop' into schema-update
disha1202 Aug 24, 2024
08a6fed
Merge branch 'develop' into reply-functionality
disha1202 Aug 24, 2024
c2d831a
added test cases
disha1202 Aug 24, 2024
bac5283
Merge branch 'schema-update' of https://github.com/disha1202/talawa-a…
disha1202 Aug 24, 2024
a2e5141
fix: formatting issues
disha1202 Aug 24, 2024
39d9086
fix: failed test cases
disha1202 Aug 24, 2024
b6fa93e
added test cases
disha1202 Aug 24, 2024
0e0b1d3
Merge branch 'reply-functionality' of https://github.com/disha1202/ta…
disha1202 Aug 24, 2024
4f9ea48
removed unwanted comments
disha1202 Aug 24, 2024
d450059
Merge branch 'develop' into schema-update
disha1202 Sep 1, 2024
7baed1d
Merge branch 'develop' into reply-functionality
disha1202 Sep 1, 2024
aad9ea2
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
disha1202 Sep 22, 2024
b5da053
Merge branch 'schema-update' of https://github.com/disha1202/talawa-a…
disha1202 Sep 22, 2024
50d579e
fix: failling tests
disha1202 Sep 22, 2024
99a24c2
removed unwanted code
disha1202 Sep 22, 2024
23ba0b5
Update tests/resolvers/Query/chatById.spec.ts
disha1202 Sep 22, 2024
c4f6cd6
fix: removed ignore statements
disha1202 Sep 22, 2024
3b0f12c
Merge branch 'schema-update' of https://github.com/disha1202/talawa-a…
disha1202 Sep 22, 2024
9f2f12d
Update schema.graphql
disha1202 Sep 22, 2024
b3032db
Merge branch 'develop' into reply-functionality
disha1202 Sep 22, 2024
a6b960f
fix: failing tests
disha1202 Sep 22, 2024
8548f25
Merge branch 'schema-update' of https://github.com/disha1202/talawa-a…
disha1202 Sep 22, 2024
bf38bc6
fix: removed eslint disabled statements
disha1202 Sep 22, 2024
d42aca6
updated tests and helper functions
disha1202 Sep 29, 2024
4124a3a
Merge branch 'develop' into schema-update
disha1202 Oct 6, 2024
7d5667d
reverted: unrelated changes
disha1202 Oct 6, 2024
9911641
Merge branch 'schema-update' of https://github.com/disha1202/talawa-a…
disha1202 Oct 6, 2024
3b4e431
reverted: unrelated changes
disha1202 Oct 6, 2024
d0b54f6
Merge branch 'develop' into reply-functionality
disha1202 Oct 6, 2024
670f79e
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
disha1202 Oct 7, 2024
b66d394
Merge branch 'reply-functionality' of https://github.com/disha1202/ta…
disha1202 Oct 7, 2024
03a26d8
fix: linting errors'
disha1202 Oct 7, 2024
87eea3d
fix: failing tests
disha1202 Oct 8, 2024
de1dea1
fix: failing tests
disha1202 Oct 8, 2024
4050877
Merge branch 'develop' into schema-update
disha1202 Oct 13, 2024
badec95
Merge branch 'reply-functionality' of https://github.com/disha1202/ta…
disha1202 Oct 13, 2024
6a4ea4b
Merge branch 'schema-update' of https://github.com/disha1202/talawa-a…
disha1202 Oct 13, 2024
b625e84
fix: eslint errors
disha1202 Oct 13, 2024
2d49e0a
fix: eslint errors
disha1202 Oct 13, 2024
7d96ccc
fix: eslint errors
disha1202 Oct 13, 2024
7054695
refator: removed parser for graphql files
disha1202 Oct 13, 2024
de2fade
Merge branch 'develop' into schema-update
disha1202 Oct 16, 2024
3f75514
Update eslint.config.mjs
disha1202 Oct 16, 2024
c7fc6e3
fix: formatting issues
disha1202 Oct 16, 2024
63336b2
Merge branch 'develop' into schema-update
DMills27 Oct 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ const config: CodegenConfig = {

Community: "../models/Community#InterfaceCommunity",

DirectChat: "../models/DirectChat#InterfaceDirectChat",
Chat: "../models/Chat#InterfaceChat",

DirectChatMessage:
"../models/DirectChatMessage#InterfaceDirectChatMessage",
ChatMessage: "../models/ChatMessage#InterfaceChatMessage",

Donation: "../models/Donation#InterfaceDonation",

Expand All @@ -75,11 +74,6 @@ const config: CodegenConfig = {

Group: "../models/Group#InterfaceGroup",

GroupChat: "../models/GroupChat#InterfaceGroupChat",

GroupChatMessage:
"../models/GroupChatMessage#InterfaceGroupChatMessage",

// ImageHash: '../models/ImageHash#InterfaceImageHash',

Language: "../models/Language#InterfaceLanguage",
Expand Down
17 changes: 5 additions & 12 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsdoc from "eslint-plugin-tsdoc";
import _import from "eslint-plugin-import";
import { fixupPluginRules } from "@eslint/compat";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import parser from "@graphql-eslint/eslint-plugin";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
import graphqlEslint from "@graphql-eslint/eslint-plugin";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
});

export default [{
Expand All @@ -35,12 +33,8 @@ export default [{
},

languageOptions: {
env: {
node: true,
parser: tsParser,
},
parser: tsParser,
}
,

rules: {
"no-restricted-imports": ["error", {
Expand All @@ -50,7 +44,6 @@ export default [{
"import/no-duplicates": "error",
"tsdoc/syntax": "error",
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
Expand Down Expand Up @@ -117,11 +110,11 @@ export default [{
files: ["./src/typeDefs/**/*.graphql"],

plugins: {
"@graphql-eslint": graphqlEslint,
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
parser: parser,
parser: tsParser,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Incorrect parser specified for GraphQL files

The tsParser (TypeScript parser) is set as the parser for .graphql files:

languageOptions: {
    parser: tsParser,
},

Using tsParser for GraphQL files may not be appropriate because .graphql files are not written in TypeScript. This could result in parsing errors or incorrect linting results. Consider using a GraphQL-specific parser or removing the parser specification for this file type if it's not needed.

Apply this diff to correct the parser configuration:

 languageOptions: {
-    parser: tsParser,
 },

},
}, {
files: ["tests/**/*"],
Expand Down
109 changes: 35 additions & 74 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,32 @@ input CampaignWhereInput {
organizationId: ID
}

type Chat {
_id: ID!
admins: [User]
createdAt: DateTime!
creator: User
image: String
isGroup: Boolean!
lastMessageId: String
messages: [ChatMessage]
name: String
organization: Organization
updatedAt: DateTime!
users: [User!]!
}
Comment on lines +193 to +206
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Change 'lastMessageId' field type from 'String' to 'ID'

The lastMessageId field represents the ID of the last message in the chat. For consistency and better type safety, consider changing its type from String to ID.

Apply this diff:

 type Chat {
   _id: ID!
   admins: [User]
   createdAt: DateTime!
   creator: User
   image: String
   isGroup: Boolean!
-  lastMessageId: String
+  lastMessageId: ID
   messages: [ChatMessage]
   name: String
   organization: Organization
   updatedAt: DateTime!
   users: [User!]!
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
type Chat {
_id: ID!
admins: [User]
createdAt: DateTime!
creator: User
image: String
isGroup: Boolean!
lastMessageId: String
messages: [ChatMessage]
name: String
organization: Organization
updatedAt: DateTime!
users: [User!]!
}
type Chat {
_id: ID!
admins: [User]
createdAt: DateTime!
creator: User
image: String
isGroup: Boolean!
lastMessageId: ID
messages: [ChatMessage]
name: String
organization: Organization
updatedAt: DateTime!
users: [User!]!
}

🛠️ Refactor suggestion

Implement pagination for the 'messages' field in 'Chat' type

Fetching all messages in a chat at once can lead to performance issues, especially for chats with a large number of messages. Consider implementing pagination to improve scalability and efficiency.

Apply this diff to modify the messages field:

 type Chat {
   _id: ID!
   admins: [User]
   createdAt: DateTime!
   creator: User
   image: String
   isGroup: Boolean!
   lastMessageId: ID
-  messages: [ChatMessage]
+  messages(first: Int, after: String): ChatMessageConnection
   name: String
   organization: Organization
   updatedAt: DateTime!
   users: [User!]!
 }
 
+type ChatMessageConnection {
+  edges: [ChatMessageEdge]
+  pageInfo: PageInfo!
+}
+
+type ChatMessageEdge {
+  cursor: String!
+  node: ChatMessage
+}

Committable suggestion was skipped due to low confidence.


type ChatMessage {
_id: ID!
chatMessageBelongsTo: Chat!
createdAt: DateTime!
deletedBy: [User]
messageContent: String!
replyTo: ChatMessage
disha1202 marked this conversation as resolved.
Show resolved Hide resolved
sender: User!
updatedAt: DateTime!
}
Comment on lines +208 to +217
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adding a 'type' field to 'ChatMessage' for message categorization

Including a type field in the ChatMessage type can help categorize messages (e.g., TEXT, IMAGE, VIDEO). This enhances flexibility and allows clients to handle different message types appropriately.

Define the MessageType enum:

enum MessageType {
  TEXT
  IMAGE
  VIDEO
  FILE
}

Update the ChatMessage type:

 type ChatMessage {
   _id: ID!
   chatMessageBelongsTo: Chat!
   createdAt: DateTime!
   deletedBy: [User]
   messageContent: String!
   replyTo: ChatMessage
   sender: User!
   updatedAt: DateTime!
+  type: MessageType!
 }


type CheckIn {
_id: ID!
createdAt: DateTime!
Expand Down Expand Up @@ -549,26 +575,6 @@ type DeletePayload {
success: Boolean!
}

type DirectChat {
_id: ID!
createdAt: DateTime!
creator: User
messages: [DirectChatMessage]
organization: Organization
updatedAt: DateTime!
users: [User!]!
}

type DirectChatMessage {
_id: ID!
createdAt: DateTime!
directChatMessageBelongsTo: DirectChat!
messageContent: String!
receiver: User!
sender: User!
updatedAt: DateTime!
}

type Donation {
_id: ID!
amount: Float!
Expand Down Expand Up @@ -932,26 +938,6 @@ type Group {
updatedAt: DateTime!
}

type GroupChat {
_id: ID!
createdAt: DateTime!
creator: User
messages: [GroupChatMessage]
organization: Organization!
title: String!
updatedAt: DateTime!
users: [User!]!
}

type GroupChatMessage {
_id: ID!
createdAt: DateTime!
groupChatMessageBelongsTo: GroupChat!
messageContent: String!
sender: User!
updatedAt: DateTime!
}

type InvalidCursor implements FieldError {
message: String!
path: [String!]!
Expand Down Expand Up @@ -1044,16 +1030,6 @@ type Message {
videoUrl: URL
}

type MessageChat {
_id: ID!
createdAt: DateTime!
languageBarrier: Boolean
message: String!
receiver: User!
sender: User!
updatedAt: DateTime!
}

input MessageChatInput {
message: String!
receiver: ID!
Expand All @@ -1080,9 +1056,7 @@ type Mutation {
addPledgeToFundraisingCampaign(campaignId: ID!, pledgeId: ID!): FundraisingCampaignPledge!
addUserCustomData(dataName: String!, dataValue: Any!, organizationId: ID!): UserCustomData!
addUserImage(file: String!): User!
addUserToGroupChat(chatId: ID!, userId: ID!): GroupChat!
addUserToUserFamily(familyId: ID!, userId: ID!): UserFamily!
adminRemoveGroup(groupId: ID!): GroupChat!
assignUserTag(input: ToggleUserTagAssignInput!): User
blockPluginCreationBySuperadmin(blockUser: Boolean!, userId: ID!): AppUserProfile!
blockUser(organizationId: ID!, userId: ID!): User!
Expand All @@ -1096,18 +1070,16 @@ type Mutation {
createAgendaCategory(input: CreateAgendaCategoryInput!): AgendaCategory!
createAgendaItem(input: CreateAgendaItemInput!): AgendaItem!
createAgendaSection(input: CreateAgendaSectionInput!): AgendaSection!
createChat(data: chatInput!): Chat
createComment(data: CommentInput!, postId: ID!): Comment
createDirectChat(data: createChatInput!): DirectChat!
createDonation(amount: Float!, nameOfOrg: String!, nameOfUser: String!, orgId: ID!, payPalId: ID!, userId: ID!): Donation!
createEvent(data: EventInput!, recurrenceRuleData: RecurrenceRuleInput): Event!
createEventVolunteer(data: EventVolunteerInput!): EventVolunteer!
createEventVolunteerGroup(data: EventVolunteerGroupInput!): EventVolunteerGroup!
createFund(data: FundInput!): Fund!
createFundraisingCampaign(data: FundCampaignInput!): FundraisingCampaign!
createFundraisingCampaignPledge(data: FundCampaignPledgeInput!): FundraisingCampaignPledge!
createGroupChat(data: createGroupChatInput!): GroupChat!
createMember(input: UserAndOrganizationInput!): CreateMemberPayload!
createMessageChat(data: MessageChatInput!): MessageChat!
createNote(data: NoteInput!): Note!
createOrganization(data: OrganizationInput, file: String): Organization!
createPlugin(pluginCreatedBy: String!, pluginDesc: String!, pluginName: String!, uninstalledOrgs: [ID!]): Plugin!
Expand Down Expand Up @@ -1142,13 +1114,11 @@ type Mutation {
removeAgendaItem(id: ID!): AgendaItem!
removeAgendaSection(id: ID!): ID!
removeComment(id: ID!): Comment
removeDirectChat(chatId: ID!, organizationId: ID!): DirectChat!
removeEvent(id: ID!, recurringEventDeleteType: RecurringEventMutationType): Event!
removeEventAttendee(data: EventAttendeeInput!): User!
removeEventVolunteer(id: ID!): EventVolunteer!
removeEventVolunteerGroup(id: ID!): EventVolunteerGroup!
removeFundraisingCampaignPledge(id: ID!): FundraisingCampaignPledge!
removeGroupChat(chatId: ID!): GroupChat!
removeMember(data: UserAndOrganizationInput!): Organization!
removeOrganization(id: ID!): UserData!
removeOrganizationCustomField(customFieldId: ID!, organizationId: ID!): OrganizationCustomField!
Expand All @@ -1157,16 +1127,14 @@ type Mutation {
removeSampleOrganization: Boolean!
removeUserCustomData(organizationId: ID!): UserCustomData!
removeUserFamily(familyId: ID!): UserFamily!
removeUserFromGroupChat(chatId: ID!, userId: ID!): GroupChat!
removeUserFromUserFamily(familyId: ID!, userId: ID!): UserFamily!
removeUserImage: User!
removeUserTag(id: ID!): UserTag
resetCommunity: Boolean!
revokeRefreshTokenForUser: Boolean!
saveFcmToken(token: String): Boolean!
sendMembershipRequest(organizationId: ID!): MembershipRequest!
sendMessageToDirectChat(chatId: ID!, messageContent: String!): DirectChatMessage!
sendMessageToGroupChat(chatId: ID!, messageContent: String!): GroupChatMessage!
sendMessageToChat(chatId: ID!, messageContent: String!, replyTo: ID): ChatMessage!
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Include 'type' parameter in 'sendMessageToChat' mutation

Adding a type parameter to the sendMessageToChat mutation allows specifying the message type, aligning with the updated ChatMessage structure.

Update the mutation signature:

 type Mutation {
-  sendMessageToChat(chatId: ID!, messageContent: String!, replyTo: ID): ChatMessage!
+  sendMessageToChat(chatId: ID!, messageContent: String!, replyTo: ID, type: MessageType!): ChatMessage!
   ...
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sendMessageToChat(chatId: ID!, messageContent: String!, replyTo: ID): ChatMessage!
sendMessageToChat(chatId: ID!, messageContent: String!, replyTo: ID, type: MessageType!): ChatMessage!

signUp(data: UserInput!, file: String): AuthData!
togglePostPin(id: ID!, title: String): Post!
unassignUserTag(input: ToggleUserTagAssignInput!): User
Expand Down Expand Up @@ -1493,12 +1461,11 @@ type Query {
agendaItemByEvent(relatedEventId: ID!): [AgendaItem]
agendaItemByOrganization(organizationId: ID!): [AgendaItem]
agendaItemCategoriesByOrganization(organizationId: ID!): [AgendaCategory]
chatById(id: ID!): Chat!
chatsByUserId(id: ID!): [Chat]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Implement pagination in 'chatsByUserId' query to enhance performance

Fetching all chats for a user at once can lead to performance bottlenecks, especially for users with many chats. Implementing pagination improves scalability and user experience.

Modify the chatsByUserId query:

 type Query {
-  chatsByUserId(id: ID!): [Chat]
+  chatsByUserId(id: ID!, first: Int, after: String): ChatConnection
   ...
 }

+type ChatConnection {
+  edges: [ChatEdge]
+  pageInfo: PageInfo!
+}
+
+type ChatEdge {
+  cursor: String!
+  node: Chat
+}

Committable suggestion was skipped due to low confidence.

checkAuth: User!
customDataByOrganization(organizationId: ID!): [UserCustomData!]!
customFieldsByOrganization(id: ID!): [OrganizationCustomField]
directChatById(id: ID!): DirectChat
directChatsByUserID(id: ID!): [DirectChat]
directChatsMessagesByChatID(id: ID!): [DirectChatMessage]
event(id: ID!): Event
eventVolunteersByEvent(id: ID!): [EventVolunteer]
eventsByOrganization(id: ID, orderBy: EventOrderByInput): [Event]
Expand Down Expand Up @@ -1526,8 +1493,6 @@ type Query {
getUserTagAncestors(id: ID!): [UserTag]
getVenueByOrgId(first: Int, orderBy: VenueOrderByInput, orgId: ID!, skip: Int, where: VenueWhereInput): [Venue]
getlanguage(lang_code: String!): [Translation]
groupChatById(id: ID!): GroupChat
groupChatsByUserId(id: ID!): [GroupChat]
hasSubmittedFeedback(eventId: ID!, userId: ID!): Boolean
isSampleOrganization(id: ID!): Boolean!
joinedOrganizations(id: ID): [Organization]
Expand Down Expand Up @@ -1628,9 +1593,7 @@ enum Status {
}

type Subscription {
directMessageChat: MessageChat
messageSentToDirectChat(userId: ID!): DirectChatMessage
messageSentToGroupChat(userId: ID!): GroupChatMessage
messageSentToChat(userId: ID!): ChatMessage
disha1202 marked this conversation as resolved.
Show resolved Hide resolved
onPluginUpdate: Plugin
}

Expand Down Expand Up @@ -2047,16 +2010,14 @@ enum WeekDays {
WEDNESDAY
}

input createChatInput {
input chatInput {
image: String
isGroup: Boolean!
name: String
Comment on lines +2019 to +2022
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ensure 'organizationId' is required when 'isGroup' is true in 'chatInput'

For group chats associated with an organization, making organizationId mandatory when isGroup is true ensures data consistency and proper linkage.

Consider updating the chatInput definition:

 input chatInput {
   image: String
   isGroup: Boolean!
   name: String
-  organizationId: ID
+  organizationId: ID  # Consider making this non-nullable when isGroup is true
   userIds: [ID!]!
 }

Implement validation logic to enforce this constraint during mutation processing.

Committable suggestion was skipped due to low confidence.

organizationId: ID
userIds: [ID!]!
}

type createDirectChatPayload {
directChat: DirectChat
userErrors: [CreateDirectChatError!]!
}

input createGroupChatInput {
organizationId: ID!
title: String!
Expand Down
7 changes: 7 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ export const CHAT_NOT_FOUND_ERROR = Object.freeze({
PARAM: "chat",
});

export const MESSAGE_NOT_FOUND_ERROR = Object.freeze({
DESC: "Message not found",
CODE: "message.notFound",
MESSAGE: "message.notFound",
PARAM: "message",
});

export const VENUE_ALREADY_EXISTS_ERROR = Object.freeze({
DESC: "Venue already exists",
CODE: "venue.alreadyExists",
Expand Down
Loading
Loading