Implement comment count on person and company (#183)
This commit is contained in:
@ -132,7 +132,6 @@ export type CommentScalarWhereInput = {
|
|||||||
|
|
||||||
export type CommentThread = {
|
export type CommentThread = {
|
||||||
__typename?: 'CommentThread';
|
__typename?: 'CommentThread';
|
||||||
_count: CommentThreadCount;
|
|
||||||
commentThreadTargets?: Maybe<Array<CommentThreadTarget>>;
|
commentThreadTargets?: Maybe<Array<CommentThreadTarget>>;
|
||||||
comments?: Maybe<Array<Comment>>;
|
comments?: Maybe<Array<Comment>>;
|
||||||
createdAt: Scalars['DateTime'];
|
createdAt: Scalars['DateTime'];
|
||||||
@ -141,12 +140,6 @@ export type CommentThread = {
|
|||||||
updatedAt: Scalars['DateTime'];
|
updatedAt: Scalars['DateTime'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CommentThreadCount = {
|
|
||||||
__typename?: 'CommentThreadCount';
|
|
||||||
commentThreadTargets: Scalars['Int'];
|
|
||||||
comments: Scalars['Int'];
|
|
||||||
};
|
|
||||||
|
|
||||||
export type CommentThreadCreateInput = {
|
export type CommentThreadCreateInput = {
|
||||||
commentThreadTargets?: InputMaybe<CommentThreadTargetCreateNestedManyWithoutCommentThreadInput>;
|
commentThreadTargets?: InputMaybe<CommentThreadTargetCreateNestedManyWithoutCommentThreadInput>;
|
||||||
comments?: InputMaybe<CommentCreateNestedManyWithoutCommentThreadInput>;
|
comments?: InputMaybe<CommentCreateNestedManyWithoutCommentThreadInput>;
|
||||||
@ -417,11 +410,12 @@ export enum CommentableType {
|
|||||||
|
|
||||||
export type Company = {
|
export type Company = {
|
||||||
__typename?: 'Company';
|
__typename?: 'Company';
|
||||||
_count: CompanyCount;
|
_commentsCount: Scalars['Int'];
|
||||||
accountOwner?: Maybe<User>;
|
accountOwner?: Maybe<User>;
|
||||||
accountOwnerId?: Maybe<Scalars['String']>;
|
accountOwnerId?: Maybe<Scalars['String']>;
|
||||||
address: Scalars['String'];
|
address: Scalars['String'];
|
||||||
commentThreads: Array<CommentThread>;
|
commentThreads: Array<CommentThread>;
|
||||||
|
comments: Array<Comment>;
|
||||||
createdAt: Scalars['DateTime'];
|
createdAt: Scalars['DateTime'];
|
||||||
deletedAt?: Maybe<Scalars['DateTime']>;
|
deletedAt?: Maybe<Scalars['DateTime']>;
|
||||||
domainName: Scalars['String'];
|
domainName: Scalars['String'];
|
||||||
@ -432,11 +426,6 @@ export type Company = {
|
|||||||
updatedAt: Scalars['DateTime'];
|
updatedAt: Scalars['DateTime'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CompanyCount = {
|
|
||||||
__typename?: 'CompanyCount';
|
|
||||||
people: Scalars['Int'];
|
|
||||||
};
|
|
||||||
|
|
||||||
export type CompanyCreateInput = {
|
export type CompanyCreateInput = {
|
||||||
accountOwner?: InputMaybe<UserCreateNestedOneWithoutCompaniesInput>;
|
accountOwner?: InputMaybe<UserCreateNestedOneWithoutCompaniesInput>;
|
||||||
address: Scalars['String'];
|
address: Scalars['String'];
|
||||||
@ -785,8 +774,10 @@ export type NullableStringFieldUpdateOperationsInput = {
|
|||||||
|
|
||||||
export type Person = {
|
export type Person = {
|
||||||
__typename?: 'Person';
|
__typename?: 'Person';
|
||||||
|
_commentCount: Scalars['Int'];
|
||||||
city: Scalars['String'];
|
city: Scalars['String'];
|
||||||
commentThreads: Array<CommentThread>;
|
commentThreads: Array<CommentThread>;
|
||||||
|
comments: Array<Comment>;
|
||||||
company?: Maybe<Company>;
|
company?: Maybe<Company>;
|
||||||
companyId?: Maybe<Scalars['String']>;
|
companyId?: Maybe<Scalars['String']>;
|
||||||
createdAt: Scalars['DateTime'];
|
createdAt: Scalars['DateTime'];
|
||||||
@ -997,7 +988,6 @@ export type PersonWhereUniqueInput = {
|
|||||||
|
|
||||||
export type Pipeline = {
|
export type Pipeline = {
|
||||||
__typename?: 'Pipeline';
|
__typename?: 'Pipeline';
|
||||||
_count: PipelineCount;
|
|
||||||
createdAt: Scalars['DateTime'];
|
createdAt: Scalars['DateTime'];
|
||||||
deletedAt?: Maybe<Scalars['DateTime']>;
|
deletedAt?: Maybe<Scalars['DateTime']>;
|
||||||
icon: Scalars['String'];
|
icon: Scalars['String'];
|
||||||
@ -1027,15 +1017,8 @@ export type PipelineAssociation = {
|
|||||||
updatedAt: Scalars['DateTime'];
|
updatedAt: Scalars['DateTime'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PipelineCount = {
|
|
||||||
__typename?: 'PipelineCount';
|
|
||||||
pipelineAssociations: Scalars['Int'];
|
|
||||||
pipelineStages: Scalars['Int'];
|
|
||||||
};
|
|
||||||
|
|
||||||
export type PipelineStage = {
|
export type PipelineStage = {
|
||||||
__typename?: 'PipelineStage';
|
__typename?: 'PipelineStage';
|
||||||
_count: PipelineStageCount;
|
|
||||||
color: Scalars['String'];
|
color: Scalars['String'];
|
||||||
createdAt: Scalars['DateTime'];
|
createdAt: Scalars['DateTime'];
|
||||||
deletedAt?: Maybe<Scalars['DateTime']>;
|
deletedAt?: Maybe<Scalars['DateTime']>;
|
||||||
@ -1048,11 +1031,6 @@ export type PipelineStage = {
|
|||||||
updatedAt: Scalars['DateTime'];
|
updatedAt: Scalars['DateTime'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PipelineStageCount = {
|
|
||||||
__typename?: 'PipelineStageCount';
|
|
||||||
pipelineAssociations: Scalars['Int'];
|
|
||||||
};
|
|
||||||
|
|
||||||
export type Query = {
|
export type Query = {
|
||||||
__typename?: 'Query';
|
__typename?: 'Query';
|
||||||
findManyCompany: Array<Company>;
|
findManyCompany: Array<Company>;
|
||||||
@ -1136,7 +1114,6 @@ export type StringNullableFilter = {
|
|||||||
|
|
||||||
export type User = {
|
export type User = {
|
||||||
__typename?: 'User';
|
__typename?: 'User';
|
||||||
_count: UserCount;
|
|
||||||
avatarUrl?: Maybe<Scalars['String']>;
|
avatarUrl?: Maybe<Scalars['String']>;
|
||||||
comments?: Maybe<Array<Comment>>;
|
comments?: Maybe<Array<Comment>>;
|
||||||
companies?: Maybe<Array<Company>>;
|
companies?: Maybe<Array<Company>>;
|
||||||
@ -1166,13 +1143,6 @@ export type UserCompaniesArgs = {
|
|||||||
where?: InputMaybe<CompanyWhereInput>;
|
where?: InputMaybe<CompanyWhereInput>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UserCount = {
|
|
||||||
__typename?: 'UserCount';
|
|
||||||
comments: Scalars['Int'];
|
|
||||||
companies: Scalars['Int'];
|
|
||||||
refreshTokens: Scalars['Int'];
|
|
||||||
};
|
|
||||||
|
|
||||||
export type UserCreateNestedOneWithoutCommentsInput = {
|
export type UserCreateNestedOneWithoutCommentsInput = {
|
||||||
connect?: InputMaybe<UserWhereUniqueInput>;
|
connect?: InputMaybe<UserWhereUniqueInput>;
|
||||||
};
|
};
|
||||||
@ -1309,7 +1279,6 @@ export type UserWhereUniqueInput = {
|
|||||||
|
|
||||||
export type Workspace = {
|
export type Workspace = {
|
||||||
__typename?: 'Workspace';
|
__typename?: 'Workspace';
|
||||||
_count: WorkspaceCount;
|
|
||||||
commentThreads?: Maybe<Array<CommentThread>>;
|
commentThreads?: Maybe<Array<CommentThread>>;
|
||||||
comments?: Maybe<Array<Comment>>;
|
comments?: Maybe<Array<Comment>>;
|
||||||
companies?: Maybe<Array<Company>>;
|
companies?: Maybe<Array<Company>>;
|
||||||
@ -1326,17 +1295,6 @@ export type Workspace = {
|
|||||||
workspaceMember?: Maybe<Array<WorkspaceMember>>;
|
workspaceMember?: Maybe<Array<WorkspaceMember>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type WorkspaceCount = {
|
|
||||||
__typename?: 'WorkspaceCount';
|
|
||||||
commentThreads: Scalars['Int'];
|
|
||||||
comments: Scalars['Int'];
|
|
||||||
companies: Scalars['Int'];
|
|
||||||
people: Scalars['Int'];
|
|
||||||
pipelineStages: Scalars['Int'];
|
|
||||||
pipelines: Scalars['Int'];
|
|
||||||
workspaceMember: Scalars['Int'];
|
|
||||||
};
|
|
||||||
|
|
||||||
export type WorkspaceMember = {
|
export type WorkspaceMember = {
|
||||||
__typename?: 'WorkspaceMember';
|
__typename?: 'WorkspaceMember';
|
||||||
createdAt: Scalars['DateTime'];
|
createdAt: Scalars['DateTime'];
|
||||||
|
|||||||
@ -33,6 +33,6 @@ export class CommentThread {
|
|||||||
@HideField()
|
@HideField()
|
||||||
workspace?: Workspace;
|
workspace?: Workspace;
|
||||||
|
|
||||||
@Field(() => CommentThreadCount, { nullable: false })
|
@HideField()
|
||||||
_count?: CommentThreadCount;
|
_count?: CommentThreadCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,6 +49,6 @@ export class Company {
|
|||||||
@HideField()
|
@HideField()
|
||||||
workspace?: Workspace;
|
workspace?: Workspace;
|
||||||
|
|
||||||
@Field(() => CompanyCount, { nullable: false })
|
@HideField()
|
||||||
_count?: CompanyCount;
|
_count?: CompanyCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,6 +45,6 @@ export class PipelineStage {
|
|||||||
@HideField()
|
@HideField()
|
||||||
workspace?: Workspace;
|
workspace?: Workspace;
|
||||||
|
|
||||||
@Field(() => PipelineStageCount, { nullable: false })
|
@HideField()
|
||||||
_count?: PipelineStageCount;
|
_count?: PipelineStageCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,6 @@ export class Pipeline {
|
|||||||
@HideField()
|
@HideField()
|
||||||
workspace?: Workspace;
|
workspace?: Workspace;
|
||||||
|
|
||||||
@Field(() => PipelineCount, { nullable: false })
|
@HideField()
|
||||||
_count?: PipelineCount;
|
_count?: PipelineCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,6 +65,6 @@ export class User {
|
|||||||
@Field(() => [Comment], { nullable: true })
|
@Field(() => [Comment], { nullable: true })
|
||||||
comments?: Array<Comment>;
|
comments?: Array<Comment>;
|
||||||
|
|
||||||
@Field(() => UserCount, { nullable: false })
|
@HideField()
|
||||||
_count?: UserCount;
|
_count?: UserCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import { Comment } from '../comment/comment.model';
|
|||||||
import { Pipeline } from '../pipeline/pipeline.model';
|
import { Pipeline } from '../pipeline/pipeline.model';
|
||||||
import { PipelineStage } from '../pipeline-stage/pipeline-stage.model';
|
import { PipelineStage } from '../pipeline-stage/pipeline-stage.model';
|
||||||
import { WorkspaceCount } from './workspace-count.output';
|
import { WorkspaceCount } from './workspace-count.output';
|
||||||
|
import { HideField } from '@nestjs/graphql';
|
||||||
|
|
||||||
@ObjectType({})
|
@ObjectType({})
|
||||||
export class Workspace {
|
export class Workspace {
|
||||||
@ -54,6 +55,6 @@ export class Workspace {
|
|||||||
@Field(() => [PipelineStage], { nullable: true })
|
@Field(() => [PipelineStage], { nullable: true })
|
||||||
pipelineStages?: Array<PipelineStage>;
|
pipelineStages?: Array<PipelineStage>;
|
||||||
|
|
||||||
@Field(() => WorkspaceCount, { nullable: false })
|
@HideField()
|
||||||
_count?: WorkspaceCount;
|
_count?: WorkspaceCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import * as TypeGraphQL from '@nestjs/graphql';
|
import * as TypeGraphQL from '@nestjs/graphql';
|
||||||
import { CommentThread } from 'src/api/@generated/comment-thread/comment-thread.model';
|
import { CommentThread } from 'src/api/@generated/comment-thread/comment-thread.model';
|
||||||
|
import { Comment } from 'src/api/@generated/comment/comment.model';
|
||||||
import { Company } from 'src/api/@generated/company/company.model';
|
import { Company } from 'src/api/@generated/company/company.model';
|
||||||
import { User } from 'src/api/@generated/user/user.model';
|
import { User } from 'src/api/@generated/user/user.model';
|
||||||
import { PrismaService } from 'src/database/prisma.service';
|
import { PrismaService } from 'src/database/prisma.service';
|
||||||
@ -40,4 +41,40 @@ export class CompanyRelationsResolver {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TypeGraphQL.ResolveField(() => [Comment], {
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
async comments(@TypeGraphQL.Root() company: Company): Promise<Comment[]> {
|
||||||
|
return this.prismaService.comment.findMany({
|
||||||
|
where: {
|
||||||
|
commentThread: {
|
||||||
|
commentThreadTargets: {
|
||||||
|
some: {
|
||||||
|
commentableId: company.id,
|
||||||
|
commentableType: 'Company',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@TypeGraphQL.ResolveField(() => TypeGraphQL.Int, {
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
async _commentsCount(@TypeGraphQL.Root() company: Company): Promise<number> {
|
||||||
|
return this.prismaService.comment.count({
|
||||||
|
where: {
|
||||||
|
commentThread: {
|
||||||
|
commentThreadTargets: {
|
||||||
|
some: {
|
||||||
|
commentableId: company.id,
|
||||||
|
commentableType: 'Company',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import * as TypeGraphQL from '@nestjs/graphql';
|
import * as TypeGraphQL from '@nestjs/graphql';
|
||||||
import { CommentThread } from 'src/api/@generated/comment-thread/comment-thread.model';
|
import { CommentThread } from 'src/api/@generated/comment-thread/comment-thread.model';
|
||||||
|
import { Comment } from 'src/api/@generated/comment/comment.model';
|
||||||
import { Company } from 'src/api/@generated/company/company.model';
|
import { Company } from 'src/api/@generated/company/company.model';
|
||||||
import { Person } from 'src/api/@generated/person/person.model';
|
import { Person } from 'src/api/@generated/person/person.model';
|
||||||
import { PrismaService } from 'src/database/prisma.service';
|
import { PrismaService } from 'src/database/prisma.service';
|
||||||
@ -38,4 +39,40 @@ export class PersonRelationsResolver {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TypeGraphQL.ResolveField(() => [Comment], {
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
async comments(@TypeGraphQL.Root() person: Person): Promise<Comment[]> {
|
||||||
|
return this.prismaService.comment.findMany({
|
||||||
|
where: {
|
||||||
|
commentThread: {
|
||||||
|
commentThreadTargets: {
|
||||||
|
some: {
|
||||||
|
commentableId: person.id,
|
||||||
|
commentableType: 'Person',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@TypeGraphQL.ResolveField(() => TypeGraphQL.Int, {
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
async _commentCount(@TypeGraphQL.Root() person: Person): Promise<number> {
|
||||||
|
return this.prismaService.comment.count({
|
||||||
|
where: {
|
||||||
|
commentThread: {
|
||||||
|
commentThreadTargets: {
|
||||||
|
some: {
|
||||||
|
commentableId: person.id,
|
||||||
|
commentableType: 'Person',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,12 @@ generator nestgraphql {
|
|||||||
decorate_4_name = "HideField"
|
decorate_4_name = "HideField"
|
||||||
decorate_4_from = "@nestjs/graphql"
|
decorate_4_from = "@nestjs/graphql"
|
||||||
decorate_4_arguments = "[]"
|
decorate_4_arguments = "[]"
|
||||||
|
|
||||||
|
decorate_5_type = "!(*Aggregate*|*GroupBy*|*OrderBy*)"
|
||||||
|
decorate_5_field = "_count"
|
||||||
|
decorate_5_name = "HideField"
|
||||||
|
decorate_5_from = "@nestjs/graphql"
|
||||||
|
decorate_5_arguments = "[]"
|
||||||
}
|
}
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
@ -153,7 +159,7 @@ model RefreshToken {
|
|||||||
|
|
||||||
model CommentThread {
|
model CommentThread {
|
||||||
id String @id
|
id String @id
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
deletedAt DateTime?
|
deletedAt DateTime?
|
||||||
commentThreadTargets CommentThreadTarget[]
|
commentThreadTargets CommentThreadTarget[]
|
||||||
|
|||||||
Reference in New Issue
Block a user