Refresh comments threads and count on new comment (#276)
* Refresh comments threads and count on new comment * Fix tests
This commit is contained in:
@ -1,43 +1,12 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
import {
|
||||
useGetCompanyCommentsCountQuery,
|
||||
useGetPeopleCommentsCountQuery,
|
||||
} from '../../../generated/graphql';
|
||||
|
||||
export const GET_COMPANY_COMMENT_COUNT = gql`
|
||||
query GetCompanyCommentsCount($where: CompanyWhereInput) {
|
||||
companies: findManyCompany(where: $where) {
|
||||
commentsCount: _commentCount
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const useCompanyCommentsCountQuery = (companyId: string) => {
|
||||
const { data, ...rest } = useGetCompanyCommentsCountQuery({
|
||||
variables: { where: { id: { equals: companyId } } },
|
||||
});
|
||||
return { ...rest, data: data?.companies[0].commentsCount };
|
||||
};
|
||||
|
||||
export const GET_PEOPLE_COMMENT_COUNT = gql`
|
||||
query GetPeopleCommentsCount($where: PersonWhereInput) {
|
||||
people: findManyPerson(where: $where) {
|
||||
commentsCount: _commentCount
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const usePeopleCommentsCountQuery = (personId: string) => {
|
||||
const { data, ...rest } = useGetPeopleCommentsCountQuery({
|
||||
variables: { where: { id: { equals: personId } } },
|
||||
});
|
||||
return { ...rest, data: data?.people[0].commentsCount };
|
||||
};
|
||||
|
||||
export const GET_COMMENT_THREADS_BY_TARGETS = gql`
|
||||
query GetCommentThreadsByTargets($commentThreadTargetIds: [String!]!) {
|
||||
query GetCommentThreadsByTargets(
|
||||
$commentThreadTargetIds: [String!]!
|
||||
$orderBy: [CommentThreadOrderByWithRelationInput!]
|
||||
) {
|
||||
findManyCommentThreads(
|
||||
orderBy: $orderBy
|
||||
where: {
|
||||
commentThreadTargets: {
|
||||
some: { commentableId: { in: $commentThreadTargetIds } }
|
||||
|
||||
Reference in New Issue
Block a user