Skip to content

Commit

Permalink
fix merged moderation queue filter types
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-funk committed Oct 7, 2024
1 parent a6a8f38 commit 169eab4
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions server/src/core/server/graph/resolvers/ModerationQueues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,29 @@ const mergeModerationInputFilters =
filter: FilterQuery<Comment>,
selector: keyof CommentModerationCountsPerQueue
) =>
(input: ModerationQueuesInput): ModerationQueueInput => ({
selector,
connection: {
...input.connection,
filter: {
...input.connection.filter,
...filter,
(input: ModerationQueuesInput): ModerationQueueInput => {
// this is merging multiple fitler types together
// Mongo types really don't like this, but it has worked
// for years, because when TS compiles to JS, it has no
// concept of "data types", it just knows filters.
//
// If we merge this down into an object, it's the same as
// it was prior to upgrading our TS Mongo types to be more
// picky.
const mergedFilter: object = {
...input.connection.filter,
...filter,
};

return {
selector,
connection: {
...input.connection,
filter: mergedFilter,
},
},
count: input.counts ? input.counts[selector] : null,
});
count: input.counts ? input.counts[selector] : null,
};
};

/**
* siteModerationInputResolver can be used to retrieve the moderationQueue for
Expand Down

0 comments on commit 169eab4

Please sign in to comment.