-
-
Notifications
You must be signed in to change notification settings - Fork 749
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
base: develop
Are you sure you want to change the base?
Updated chat schema #2466
Changes from all commits
a8c02f8
fe6907d
3a9799d
2fa65b1
f68bb01
f7089b9
2fe5353
7e31c14
0bf28a2
9c44ea4
fa5f6ec
3db8381
a1379bf
bd98a6b
7ec1773
3781ede
8aaf5f3
e83657d
23a9676
9576d4a
c2af22d
ad48619
77c7fde
d18843a
cf27ca6
8469653
87ad70f
f936adc
babf1c0
c84f33a
33535ac
98d06a7
5a61b43
a84f1c6
4d65b03
c23008b
a539e3e
074b79c
9926e63
1586732
8b873ea
15d6bed
46d4f5f
ce20fe0
dcd6006
ea23279
ef2d45d
a2ccfb0
52165f1
ff1987f
369a81d
7cd8040
979bf37
f29ac65
dd9120f
a440bad
615a5ac
5ad1d76
08a6fed
c2d831a
bac5283
a2e5141
39d9086
b6fa93e
0e0b1d3
4f9ea48
d450059
7baed1d
aad9ea2
b5da053
50d579e
99a24c2
23ba0b5
c4f6cd6
3b0f12c
9f2f12d
b3032db
a6b960f
8548f25
bf38bc6
d42aca6
4124a3a
7d5667d
9911641
3b4e431
d0b54f6
670f79e
b66d394
03a26d8
87eea3d
de1dea1
4050877
badec95
6a4ea4b
b625e84
2d49e0a
7d96ccc
7054695
de2fade
3f75514
c7fc6e3
63336b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -40,7 +40,6 @@ input ActionItemWhereInput { | |||||
assigneeName: String | ||||||
categoryName: String | ||||||
event_id: ID | ||||||
is_active: Boolean | ||||||
is_completed: Boolean | ||||||
} | ||||||
|
||||||
|
@@ -191,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!]! | ||||||
} | ||||||
|
||||||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Define the enum MessageType {
TEXT
IMAGE
VIDEO
FILE
} Update the 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! | ||||||
|
@@ -551,26 +576,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! | ||||||
|
@@ -934,26 +939,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!]! | ||||||
|
@@ -1050,16 +1035,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! | ||||||
|
@@ -1086,9 +1061,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! | ||||||
|
@@ -1102,18 +1075,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! | ||||||
|
@@ -1148,13 +1119,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! | ||||||
|
@@ -1163,16 +1132,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! | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Include 'type' parameter in 'sendMessageToChat' mutation Adding a 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
Suggested change
|
||||||
signUp(data: UserInput!, file: String): AuthData! | ||||||
togglePostPin(id: ID!, title: String): Post! | ||||||
unassignUserTag(input: ToggleUserTagAssignInput!): User | ||||||
|
@@ -1500,12 +1467,11 @@ type Query { | |||||
agendaItemByEvent(relatedEventId: ID!): [AgendaItem] | ||||||
agendaItemByOrganization(organizationId: ID!): [AgendaItem] | ||||||
agendaItemCategoriesByOrganization(organizationId: ID!): [AgendaCategory] | ||||||
chatById(id: ID!): Chat! | ||||||
chatsByUserId(id: ID!): [Chat] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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
+}
|
||||||
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] | ||||||
|
@@ -1533,8 +1499,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] | ||||||
|
@@ -1635,9 +1599,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 | ||||||
} | ||||||
|
||||||
|
@@ -2054,16 +2016,14 @@ enum WeekDays { | |||||
WEDNESDAY | ||||||
} | ||||||
|
||||||
input createChatInput { | ||||||
input chatInput { | ||||||
image: String | ||||||
isGroup: Boolean! | ||||||
name: String | ||||||
Comment on lines
+2019
to
+2022
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure 'organizationId' is required when 'isGroup' is true in 'chatInput' For group chats associated with an organization, making Consider updating the 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.
|
||||||
organizationId: ID | ||||||
userIds: [ID!]! | ||||||
} | ||||||
|
||||||
type createDirectChatPayload { | ||||||
directChat: DirectChat | ||||||
userErrors: [CreateDirectChatError!]! | ||||||
} | ||||||
|
||||||
input createGroupChatInput { | ||||||
organizationId: ID! | ||||||
title: String! | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 fromString
toID
.Apply this diff:
📝 Committable suggestion
🛠️ 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: