-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add resolvers for DSA deports associated to a notification
also adds loaders for DSA reports
- Loading branch information
Showing
7 changed files
with
108 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import DataLoader from "dataloader"; | ||
|
||
import { find } from "coral-server/models/dsaReport/report"; | ||
|
||
import GraphContext from "../context"; | ||
import { createManyBatchLoadFn } from "./util"; | ||
|
||
export interface FindDSAReportInput { | ||
id: string; | ||
} | ||
|
||
export default (ctx: GraphContext) => ({ | ||
find: new DataLoader( | ||
createManyBatchLoadFn((input: FindDSAReportInput) => | ||
find(ctx.mongo, ctx.tenant, input) | ||
), | ||
{ | ||
cacheKeyFn: (input: FindDSAReportInput) => `${input.id}`, | ||
cache: !ctx.disableCaching, | ||
} | ||
), | ||
}); |
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
27 changes: 27 additions & 0 deletions
27
server/src/core/server/graph/resolvers/NotificationDSAReportDetails.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,27 @@ | ||
import { DSAReport } from "coral-server/models/dsaReport/report"; | ||
|
||
import { GQLNotificationDSAReportDetailsTypeResolver } from "coral-server/graph/schema/__generated__/types"; | ||
|
||
export const NotificationDSAReportDetailsResolver: Required< | ||
GQLNotificationDSAReportDetailsTypeResolver<DSAReport> | ||
> = { | ||
id: ({ id }) => id, | ||
publicID: ({ publicID }) => publicID, | ||
comment: async ({ commentID }, input, ctx) => { | ||
if (!commentID) { | ||
return null; | ||
} | ||
|
||
return await ctx.loaders.Comments.comment.load(commentID); | ||
}, | ||
user: async ({ userID }, input, ctx) => { | ||
if (!userID) { | ||
return null; | ||
} | ||
|
||
return await ctx.loaders.Users.user.load(userID); | ||
}, | ||
lawBrokenDescription: ({ lawBrokenDescription }) => lawBrokenDescription, | ||
additionalInformation: ({ additionalInformation }) => additionalInformation, | ||
submissionID: ({ submissionID }) => submissionID, | ||
}; |
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
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