-
Notifications
You must be signed in to change notification settings - Fork 104
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
Migrate support
module to Server Preset (Part 5)
#4956
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/services/api/src/modules/support/module.graphql.mappers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { SupportTicketPriority, SupportTicketStatus } from '../../shared/entities'; | ||
|
||
export type SupportTicketPriorityMapper = SupportTicketPriority; | ||
export type SupportTicketStatusMapper = SupportTicketStatus; |
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
packages/services/api/src/modules/support/resolvers/Mutation/supportTicketCreate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { IdTranslator } from '../../../shared/providers/id-translator'; | ||
import { SupportManager } from '../../providers/support-manager'; | ||
import type { MutationResolvers } from './../../../../__generated__/types.next'; | ||
|
||
export const supportTicketCreate: NonNullable<MutationResolvers['supportTicketCreate']> = async ( | ||
_, | ||
{ input }, | ||
{ injector }, | ||
) => { | ||
const organizationId = await injector.get(IdTranslator).translateOrganizationId(input); | ||
const response = await injector.get(SupportManager).createTicket({ | ||
organizationId, | ||
...input, | ||
}); | ||
|
||
return response; | ||
}; |
17 changes: 17 additions & 0 deletions
17
packages/services/api/src/modules/support/resolvers/Mutation/supportTicketReply.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { IdTranslator } from '../../../shared/providers/id-translator'; | ||
import { SupportManager } from '../../providers/support-manager'; | ||
import type { MutationResolvers } from './../../../../__generated__/types.next'; | ||
|
||
export const supportTicketReply: NonNullable<MutationResolvers['supportTicketReply']> = async ( | ||
_, | ||
{ input }, | ||
{ injector }, | ||
) => { | ||
const organizationId = await injector.get(IdTranslator).translateOrganizationId(input); | ||
const response = await injector.get(SupportManager).replyToTicket({ | ||
organizationId, | ||
...input, | ||
}); | ||
|
||
return response; | ||
}; |
46 changes: 46 additions & 0 deletions
46
packages/services/api/src/modules/support/resolvers/Organization.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { SupportManager } from '../providers/support-manager'; | ||
import type { OrganizationResolvers } from './../../../__generated__/types.next'; | ||
|
||
export const Organization: Pick<OrganizationResolvers, 'supportTicket' | 'supportTickets'> = { | ||
supportTickets: async (org, args, { injector }) => { | ||
const response = await injector.get(SupportManager).getTickets(org.id); | ||
|
||
return { | ||
edges: response.nodes.map(ticket => ({ | ||
node: { | ||
id: String(ticket.id), | ||
status: ticket.status, | ||
priority: ticket.priority, | ||
description: ticket.description, | ||
subject: ticket.subject, | ||
createdAt: ticket.created_at, | ||
updatedAt: ticket.updated_at, | ||
}, | ||
cursor: String(ticket.id), | ||
})), | ||
pageInfo: { | ||
endCursor: String(response.nodes[response.nodes.length - 1]?.id ?? ''), | ||
hasNextPage: response.meta.has_more, | ||
hasPreviousPage: false, | ||
startCursor: String(response.nodes[0]?.id ?? ''), | ||
}, | ||
}; | ||
}, | ||
supportTicket: async (org, args, { injector }) => { | ||
const ticket = await injector.get(SupportManager).getTicket(org.id, args.id); | ||
|
||
if (!ticket) { | ||
return null; | ||
} | ||
|
||
return { | ||
id: String(ticket.id), | ||
status: ticket.status, | ||
priority: ticket.priority, | ||
description: ticket.description, | ||
subject: ticket.subject, | ||
createdAt: ticket.created_at, | ||
updatedAt: ticket.updated_at, | ||
}; | ||
}, | ||
}; |
26 changes: 26 additions & 0 deletions
26
packages/services/api/src/modules/support/resolvers/SupportTicket.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { SupportManager } from '../providers/support-manager'; | ||
import type { SupportTicketResolvers } from './../../../__generated__/types.next'; | ||
|
||
export const SupportTicket: SupportTicketResolvers = { | ||
comments: async (ticket, _args, { injector }) => { | ||
const response = await injector.get(SupportManager).getTicketComments(ticket.id); | ||
|
||
return { | ||
edges: response.nodes.map(comment => ({ | ||
node: { | ||
id: String(comment.id), | ||
body: comment.body, | ||
createdAt: comment.created_at, | ||
fromSupport: comment.fromSupport, | ||
}, | ||
cursor: String(comment.id), | ||
})), | ||
pageInfo: { | ||
endCursor: String(response.nodes[response.nodes.length - 1]?.id ?? ''), | ||
hasNextPage: response.meta.has_more, | ||
hasPreviousPage: false, | ||
startCursor: String(response.nodes[0]?.id ?? ''), | ||
}, | ||
}; | ||
}, | ||
}; |
8 changes: 8 additions & 0 deletions
8
packages/services/api/src/modules/support/resolvers/SupportTicketPriority.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { SupportTicketPriority as SupportTicketPriorityEnum } from '../../../shared/entities'; | ||
import type { SupportTicketPriorityResolvers } from './../../../__generated__/types.next'; | ||
|
||
export const SupportTicketPriority: SupportTicketPriorityResolvers = { | ||
NORMAL: SupportTicketPriorityEnum.NORMAL, | ||
HIGH: SupportTicketPriorityEnum.HIGH, | ||
URGENT: SupportTicketPriorityEnum.URGENT, | ||
}; |
7 changes: 7 additions & 0 deletions
7
packages/services/api/src/modules/support/resolvers/SupportTicketStatus.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { SupportTicketStatus as SupportTicketStatusEnum } from '../../../shared/entities'; | ||
import type { SupportTicketStatusResolvers } from './../../../__generated__/types.next'; | ||
|
||
export const SupportTicketStatus: SupportTicketStatusResolvers = { | ||
OPEN: SupportTicketStatusEnum.OPEN, | ||
SOLVED: SupportTicketStatusEnum.SOLVED, | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The schema for this type is this:
This seems a bit different from other
*Connection
as they are usually non-nullable i.e.*Connection!
.Looking at the implementation, it can never be null. So I think this could be a way to get around having to declare mapper for
SupportTicket
? 🤔Either way, this is part of the migration so we should keep the implementation as-is, however, I think we should change the type to
SupportTicketCommentConnection!
so it correctly reflects the logic.Unless I misunderstood it, then please let me know!
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.
@kamilkisiela Did you think about anything specific when u implemented this?