├── .env.example ├── src ├── auth │ ├── index.ts │ ├── types │ │ ├── passport-user-fields.ts │ │ ├── session-user-fields.ts │ │ └── index.ts │ ├── auth.module.ts │ ├── session.service.ts │ └── auth.service.spec.ts ├── user │ ├── types │ │ ├── index.ts │ │ └── user-profile-fields.ts │ ├── models │ │ ├── user-login.input.ts │ │ ├── user-create.input.ts │ │ ├── user-update.input.ts │ │ └── user.model.ts │ ├── testing │ │ └── index.ts │ ├── user.module.ts │ ├── user.repository.ts │ └── validators │ │ └── user-exists.validator.ts ├── app_modules │ ├── prisma │ │ ├── testing │ │ │ └── index.ts │ │ ├── index.ts │ │ └── inject-repository.decorator.ts │ ├── README.md │ ├── nestjs-passport-graphql-auth-guard │ │ ├── index.ts │ │ └── optional-graphql-auth.guard.ts │ ├── nestjs-authorization-token │ │ └── index.ts │ ├── nestjs-graphql-fields │ │ └── index.ts │ ├── current-user-decorator │ │ └── index.ts │ └── all-exceptions-filter │ │ └── index.ts ├── article │ ├── models │ │ ├── article.model.ts │ │ ├── article-create.input.ts │ │ └── article-update.input.ts │ ├── types │ │ ├── index.ts │ │ ├── article-author.ts │ │ └── article.ts │ ├── author.guard.spec.ts │ ├── article.repository.ts │ ├── article.module.ts │ ├── testing │ │ └── index.ts │ ├── slug │ │ └── slug.service.spec.ts │ └── author.guard.ts ├── comment │ ├── models │ │ ├── comment.model.ts │ │ └── create-comment.input.ts │ ├── comment.module.ts │ ├── author.guard.ts │ └── comment.service.spec.ts ├── tag │ ├── tag.model.ts │ ├── tag.module.ts │ ├── tag.resolver.ts │ └── tag.service.ts ├── api │ ├── fragments │ │ ├── index.ts │ │ ├── user.ts │ │ ├── comment.ts │ │ └── article.ts │ ├── models │ │ ├── login-user.dto.ts │ │ ├── create-article.dto.ts │ │ ├── create-article-comment.dto.ts │ │ ├── create-user.dto.ts │ │ ├── update-user.dto.ts │ │ └── get-articles.dto.ts │ ├── api.module.ts │ └── tag-list.interceptor.ts ├── @generated │ ├── tag │ │ ├── tag-count.output.ts │ │ ├── delete-many-tag.args.ts │ │ ├── create-one-tag.args.ts │ │ ├── tag-max-aggregate.input.ts │ │ ├── tag-max-aggregate.output.ts │ │ ├── tag-min-aggregate.input.ts │ │ ├── tag-min-aggregate.output.ts │ │ ├── tag-where-unique.input.ts │ │ ├── tag-scalar-field.enum.ts │ │ ├── delete-one-tag.args.ts │ │ ├── tag-update-many-mutation.input.ts │ │ ├── find-unique-tag.args.ts │ │ ├── tag-unchecked-update-many.input.ts │ │ ├── tag-create-without-articles.input.ts │ │ ├── tag-update-without-articles.input.ts │ │ ├── tag-order-by-relation-aggregate.input.ts │ │ ├── tag-unchecked-update-without-articles.input.ts │ │ ├── tag-unchecked-create-without-articles.input.ts │ │ ├── tag-unchecked-update-many-without-tags.input.ts │ │ ├── tag-order-by.input.ts │ │ ├── tag-count-aggregate.input.ts │ │ ├── tag-count-aggregate.output.ts │ │ ├── tag-max-order-by-aggregate.input.ts │ │ ├── tag-min-order-by-aggregate.input.ts │ │ ├── tag-count-order-by-aggregate.input.ts │ │ ├── update-one-tag.args.ts │ │ ├── tag-list-relation-filter.input.ts │ │ ├── update-many-tag.args.ts │ │ ├── tag-update.input.ts │ │ ├── tag-create.input.ts │ │ ├── tag.model.ts │ │ ├── tag-update-many-with-where-without-articles.input.ts │ │ ├── tag-create-or-connect-without-articles.input.ts │ │ ├── tag-update-with-where-unique-without-articles.input.ts │ │ ├── tag-unchecked-update.input.ts │ │ ├── tag-unchecked-create.input.ts │ │ ├── upsert-one-tag.args.ts │ │ ├── aggregate-tag.output.ts │ │ ├── tag-order-by-with-relation.input.ts │ │ ├── tag-scalar-where.input.ts │ │ ├── tag-group-by.output.ts │ │ ├── tag-upsert-with-where-unique-without-articles.input.ts │ │ ├── tag-create-nested-many-without-articles.input.ts │ │ ├── tag-unchecked-create-nested-many-without-articles.input.ts │ │ ├── tag-where.input.ts │ │ ├── tag-scalar-where-with-aggregates.input.ts │ │ ├── find-many-tag.args.ts │ │ ├── find-first-tag.args.ts │ │ └── tag-order-by-with-aggregation.input.ts │ ├── prisma │ │ ├── affected-rows.output.ts │ │ ├── sort-order.enum.ts │ │ ├── int-filter.input.ts │ │ ├── float-filter.input.ts │ │ ├── date-time-filter.input.ts │ │ └── string-filter.input.ts │ ├── comment │ │ ├── comment-where-unique.input.ts │ │ ├── create-one-comment.args.ts │ │ ├── delete-many-comment.args.ts │ │ ├── delete-one-comment.args.ts │ │ ├── find-unique-comment.args.ts │ │ ├── comment-order-by-relation-aggregate.input.ts │ │ ├── comment-scalar-field.enum.ts │ │ ├── comment-update-many-mutation.input.ts │ │ ├── update-one-comment.args.ts │ │ ├── comment-list-relation-filter.input.ts │ │ ├── update-many-comment.args.ts │ │ ├── comment-create-or-connect-without-author.input.ts │ │ ├── comment-create-or-connect-without-article.input.ts │ │ ├── comment-unchecked-create-without-article.input.ts │ │ ├── comment-unchecked-create-without-author.input.ts │ │ ├── comment-unchecked-update-without-article.input.ts │ │ ├── comment-unchecked-update-without-author.input.ts │ │ ├── comment-update-many-with-where-without-article.input.ts │ │ ├── comment-update-many-with-where-without-author.input.ts │ │ ├── comment-update-with-where-unique-without-author.input.ts │ │ ├── comment-unchecked-update-many-without-comments.input.ts │ │ ├── comment-update-with-where-unique-without-article.input.ts │ │ ├── comment-max-aggregate.input.ts │ │ ├── comment-min-aggregate.input.ts │ │ ├── comment-max-aggregate.output.ts │ │ ├── comment-min-aggregate.output.ts │ │ ├── comment-unchecked-create.input.ts │ │ ├── comment-unchecked-update.input.ts │ │ ├── comment-unchecked-update-many.input.ts │ │ ├── upsert-one-comment.args.ts │ │ ├── aggregate-comment.output.ts │ │ ├── comment-count-aggregate.output.ts │ │ ├── comment-count-aggregate.input.ts │ │ ├── comment-order-by.input.ts │ │ ├── comment-update-without-author.input.ts │ │ ├── comment-create-without-article.input.ts │ │ ├── comment-update-without-article.input.ts │ │ ├── comment-create-without-author.input.ts │ │ ├── comment-max-order-by-aggregate.input.ts │ │ ├── comment-min-order-by-aggregate.input.ts │ │ ├── comment-upsert-with-where-unique-without-author.input.ts │ │ ├── comment-count-order-by-aggregate.input.ts │ │ ├── comment-upsert-with-where-unique-without-article.input.ts │ │ ├── comment.model.ts │ │ ├── comment-create-nested-many-without-author.input.ts │ │ ├── comment-create-nested-many-without-article.input.ts │ │ ├── comment-unchecked-create-nested-many-without-author.input.ts │ │ ├── comment-unchecked-create-nested-many-without-article.input.ts │ │ ├── comment-update.input.ts │ │ ├── comment-create.input.ts │ │ ├── find-first-comment.args.ts │ │ ├── find-many-comment.args.ts │ │ ├── comment-group-by.output.ts │ │ └── comment-scalar-where.input.ts │ ├── article │ │ ├── article-avg-aggregate.input.ts │ │ ├── article-sum-aggregate.input.ts │ │ ├── article-sum-aggregate.output.ts │ │ ├── article-avg-aggregate.output.ts │ │ ├── article-where-unique.input.ts │ │ ├── create-one-article.args.ts │ │ ├── delete-many-article.args.ts │ │ ├── article-avg-order-by-aggregate.input.ts │ │ ├── article-sum-order-by-aggregate.input.ts │ │ ├── delete-one-article.args.ts │ │ ├── find-unique-article.args.ts │ │ ├── article-order-by-relation-aggregate.input.ts │ │ ├── article-count.output.ts │ │ ├── article-relation-filter.input.ts │ │ ├── update-one-article.args.ts │ │ ├── article-list-relation-filter.input.ts │ │ ├── update-many-article.args.ts │ │ ├── article-scalar-field.enum.ts │ │ ├── article-create-or-connect-without-tags.input.ts │ │ ├── article-create-or-connect-without-author.input.ts │ │ ├── article-update-many-with-where-without-tags.input.ts │ │ ├── article-update-with-where-unique-without-tags.input.ts │ │ ├── article-update-many-with-where-without-author.input.ts │ │ ├── article-update-with-where-unique-without-author.input.ts │ │ ├── article-create-or-connect-without-comments.input.ts │ │ ├── article-update-many-with-where-without-favorited-by.input.ts │ │ ├── article-create-or-connect-without-favorited-by.input.ts │ │ ├── article-upsert-without-comments.input.ts │ │ ├── article-update-with-where-unique-without-favorited-by.input.ts │ │ ├── upsert-one-article.args.ts │ │ ├── article-upsert-with-where-unique-without-tags.input.ts │ │ ├── article-update-many-mutation.input.ts │ │ ├── article-upsert-with-where-unique-without-author.input.ts │ │ ├── article-unchecked-update-many-without-articles.input.ts │ │ ├── article-create-nested-many-without-tags.input.ts │ │ ├── article-max-aggregate.input.ts │ │ ├── article-min-aggregate.input.ts │ │ ├── article-create-nested-one-without-comments.input.ts │ │ ├── article-upsert-with-where-unique-without-favorited-by.input.ts │ │ ├── article-unchecked-create-nested-many-without-tags.input.ts │ │ ├── article-create-nested-many-without-author.input.ts │ │ ├── article-max-aggregate.output.ts │ │ ├── article-min-aggregate.output.ts │ │ ├── article-unchecked-create-nested-many-without-author.input.ts │ │ ├── article-unchecked-update-many.input.ts │ │ ├── article-create-nested-many-without-favorited-by.input.ts │ │ ├── article-count-aggregate.output.ts │ │ ├── article-count-aggregate.input.ts │ │ ├── article-unchecked-create-nested-many-without-favorited-by.input.ts │ │ ├── article-unchecked-update-many-without-favorite-articles.input.ts │ │ ├── article-order-by.input.ts │ │ ├── aggregate-article.output.ts │ │ ├── find-first-article.args.ts │ │ ├── find-many-article.args.ts │ │ ├── article-max-order-by-aggregate.input.ts │ │ ├── article-min-order-by-aggregate.input.ts │ │ └── article-count-order-by-aggregate.input.ts │ └── user │ │ ├── create-one-user.args.ts │ │ ├── delete-many-user.args.ts │ │ ├── delete-one-user.args.ts │ │ ├── find-unique-user.args.ts │ │ ├── user-order-by-relation-aggregate.input.ts │ │ ├── user-where-unique.input.ts │ │ ├── user-relation-filter.input.ts │ │ ├── user-scalar-field.enum.ts │ │ ├── update-one-user.args.ts │ │ ├── user-list-relation-filter.input.ts │ │ ├── update-many-user.args.ts │ │ ├── user-count.output.ts │ │ ├── user-update-many-with-where-without-followers.input.ts │ │ ├── user-update-many-with-where-without-following.input.ts │ │ ├── user-create-or-connect-without-articles.input.ts │ │ ├── user-create-or-connect-without-comments.input.ts │ │ ├── user-create-or-connect-without-followers.input.ts │ │ ├── user-create-or-connect-without-following.input.ts │ │ ├── user-update-many-with-where-without-favorite-articles.input.ts │ │ ├── user-update-with-where-unique-without-followers.input.ts │ │ ├── user-update-with-where-unique-without-following.input.ts │ │ ├── user-upsert-without-articles.input.ts │ │ ├── user-upsert-without-comments.input.ts │ │ ├── user-max-aggregate.input.ts │ │ ├── user-min-aggregate.input.ts │ │ ├── user-max-aggregate.output.ts │ │ ├── user-min-aggregate.output.ts │ │ ├── upsert-one-user.args.ts │ │ ├── user-create-or-connect-without-favorite-articles.input.ts │ │ ├── user-update-many-mutation.input.ts │ │ ├── user-unchecked-update-many.input.ts │ │ ├── user-update-with-where-unique-without-favorite-articles.input.ts │ │ ├── aggregate-user.output.ts │ │ ├── user-unchecked-update-many-without-favorited-by.input.ts │ │ ├── user-count-aggregate.output.ts │ │ ├── user-count-aggregate.input.ts │ │ ├── user-order-by.input.ts │ │ ├── user-max-order-by-aggregate.input.ts │ │ ├── user-min-order-by-aggregate.input.ts │ │ ├── user-count-order-by-aggregate.input.ts │ │ ├── user-upsert-with-where-unique-without-followers.input.ts │ │ ├── user-upsert-with-where-unique-without-following.input.ts │ │ ├── user-create-nested-one-without-articles.input.ts │ │ ├── user-create-nested-one-without-comments.input.ts │ │ ├── user-create-nested-many-without-followers.input.ts │ │ ├── user-create-nested-many-without-following.input.ts │ │ ├── user-upsert-with-where-unique-without-favorite-articles.input.ts │ │ ├── user-unchecked-create-nested-many-without-followers.input.ts │ │ ├── user-unchecked-create-nested-many-without-following.input.ts │ │ ├── user-create-nested-many-without-favorite-articles.input.ts │ │ ├── user-unchecked-create-nested-many-without-favorite-articles.input.ts │ │ ├── find-many-user.args.ts │ │ ├── find-first-user.args.ts │ │ ├── user-scalar-where.input.ts │ │ ├── user-group-by.output.ts │ │ └── user.model.ts └── types │ └── index.ts ├── .remarkrc.js ├── nest-cli.json ├── logo.png ├── prisma ├── migrations │ └── migration_lock.toml └── data.db ├── favicon.ico ├── .dockerignore ├── tsconfig.build.json ├── .editorconfig ├── .prettierrc.js ├── .releaserc.js ├── test ├── run-api-tests.sh └── jest-e2e.config.js ├── tsconfig.json ├── Dockerfile ├── jest.config.js └── LICENSE /.env.example: -------------------------------------------------------------------------------- 1 | DATABASE_URL=file:data.db 2 | JWT_SECRET_KEY= 3 | -------------------------------------------------------------------------------- /src/auth/index.ts: -------------------------------------------------------------------------------- 1 | export { PassportUserFields } from './types'; 2 | -------------------------------------------------------------------------------- /.remarkrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [['toc'], ['license']], 3 | }; 4 | -------------------------------------------------------------------------------- /src/user/types/index.ts: -------------------------------------------------------------------------------- 1 | export { UserProfileFields } from './user-profile-fields'; 2 | -------------------------------------------------------------------------------- /nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /src/app_modules/prisma/testing/index.ts: -------------------------------------------------------------------------------- 1 | export { DummyRepository } from './dummy.repository'; 2 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unlight/nestjs-graphql-prisma-realworld-example-app/HEAD/logo.png -------------------------------------------------------------------------------- /prisma/migrations/migration_lock.toml: -------------------------------------------------------------------------------- 1 | # Please do not edit this file manually 2 | provider = "sqlite" -------------------------------------------------------------------------------- /src/article/models/article.model.ts: -------------------------------------------------------------------------------- 1 | export { Article } from '@generated/article/article.model'; 2 | -------------------------------------------------------------------------------- /src/comment/models/comment.model.ts: -------------------------------------------------------------------------------- 1 | export { Comment } from '@generated/comment/comment.model'; 2 | -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unlight/nestjs-graphql-prisma-realworld-example-app/HEAD/favicon.ico -------------------------------------------------------------------------------- /prisma/data.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unlight/nestjs-graphql-prisma-realworld-example-app/HEAD/prisma/data.db -------------------------------------------------------------------------------- /src/article/types/index.ts: -------------------------------------------------------------------------------- 1 | export { Article } from './article'; 2 | export { ArticleAuthor } from './article-author'; 3 | -------------------------------------------------------------------------------- /src/auth/types/passport-user-fields.ts: -------------------------------------------------------------------------------- 1 | export interface PassportUserFields { 2 | id: string; 3 | email: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/auth/types/session-user-fields.ts: -------------------------------------------------------------------------------- 1 | export interface SessionTokenFields { 2 | sub: string; 3 | email: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/tag/tag.model.ts: -------------------------------------------------------------------------------- 1 | import { Field, ID, ObjectType } from '@nestjs/graphql'; 2 | 3 | export { Tag } from '@generated/tag/tag.model'; 4 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !/package.json 3 | !/package-lock.json 4 | !/Taskfile 5 | !/tsconfig.json 6 | !/tsconfig.build.json 7 | !/src 8 | !/prisma 9 | -------------------------------------------------------------------------------- /src/auth/types/index.ts: -------------------------------------------------------------------------------- 1 | export { PassportUserFields } from './passport-user-fields'; 2 | export { SessionTokenFields } from './session-user-fields'; 3 | -------------------------------------------------------------------------------- /src/api/fragments/index.ts: -------------------------------------------------------------------------------- 1 | export { articleFields } from './article'; 2 | export { commentFields } from './comment'; 3 | export { userFields } from './user'; 4 | -------------------------------------------------------------------------------- /src/api/models/login-user.dto.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * User submits when login. 3 | */ 4 | export class LoginUserDto { 5 | email: string; 6 | password: string; 7 | } 8 | -------------------------------------------------------------------------------- /src/article/types/article-author.ts: -------------------------------------------------------------------------------- 1 | export interface ArticleAuthor { 2 | username: string; 3 | bio: string; 4 | image: string; 5 | following: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /src/api/models/create-article.dto.ts: -------------------------------------------------------------------------------- 1 | export interface CreateArticleDto { 2 | title: string; 3 | description: string; 4 | body: string; 5 | tagList: string[]; 6 | } 7 | -------------------------------------------------------------------------------- /src/user/types/user-profile-fields.ts: -------------------------------------------------------------------------------- 1 | export interface UserProfileFields { 2 | username: string; 3 | bio: string; 4 | image: string; 5 | following: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /src/api/models/create-article-comment.dto.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Shape of create article data transfer object. 3 | */ 4 | export class CreateArticleCommentDto { 5 | body: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/app_modules/README.md: -------------------------------------------------------------------------------- 1 | # App Modules 2 | 3 | Shared, common, helpers, etc. which can be imported from any part of application. 4 | But app modules cannot import other app modules. 5 | -------------------------------------------------------------------------------- /src/app_modules/nestjs-passport-graphql-auth-guard/index.ts: -------------------------------------------------------------------------------- 1 | export { GraphqlAuthGuard } from './graphql-auth.guard'; 2 | export { OptionalGraphqlAuthGuard } from './optional-graphql-auth.guard'; 3 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": false 5 | }, 6 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /src/api/models/create-user.dto.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Shape of create user data transfer object. 3 | */ 4 | export class CreateUserDto { 5 | email: string; 6 | username: string; 7 | password: string; 8 | } 9 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-count.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class TagCount { 5 | @Field(() => Int, { nullable: false }) 6 | articles?: number; 7 | } 8 | -------------------------------------------------------------------------------- /src/api/fragments/user.ts: -------------------------------------------------------------------------------- 1 | export const userFields = /* GraphQL */ ` 2 | fragment userFields on User { 3 | userId 4 | username: name 5 | email 6 | bio 7 | image 8 | } 9 | `; 10 | -------------------------------------------------------------------------------- /src/@generated/prisma/affected-rows.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class AffectedRows { 5 | @Field(() => Int, { nullable: false }) 6 | count!: number; 7 | } 8 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-where-unique.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentWhereUniqueInput { 5 | @Field(() => String, { nullable: true }) 6 | commentId?: string; 7 | } 8 | -------------------------------------------------------------------------------- /src/api/models/update-user.dto.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * User submits when update. 3 | */ 4 | export class UpdateUserDto { 5 | email?: string; 6 | username?: string; 7 | password?: string; 8 | image?: string; 9 | bio?: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/@generated/article/article-avg-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class ArticleAvgAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | favoritesCount?: true; 7 | } 8 | -------------------------------------------------------------------------------- /src/@generated/article/article-sum-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class ArticleSumAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | favoritesCount?: true; 7 | } 8 | -------------------------------------------------------------------------------- /src/@generated/article/article-sum-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class ArticleSumAggregate { 5 | @Field(() => Int, { nullable: true }) 6 | favoritesCount?: number; 7 | } 8 | -------------------------------------------------------------------------------- /src/@generated/article/article-avg-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Float, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class ArticleAvgAggregate { 5 | @Field(() => Float, { nullable: true }) 6 | favoritesCount?: number; 7 | } 8 | -------------------------------------------------------------------------------- /src/@generated/prisma/sort-order.enum.ts: -------------------------------------------------------------------------------- 1 | import { registerEnumType } from '@nestjs/graphql'; 2 | 3 | export enum SortOrder { 4 | asc = 'asc', 5 | desc = 'desc', 6 | } 7 | 8 | registerEnumType(SortOrder, { name: 'SortOrder', description: undefined }); 9 | -------------------------------------------------------------------------------- /src/@generated/tag/delete-many-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { TagWhereInput } from './tag-where.input'; 4 | 5 | @ArgsType() 6 | export class DeleteManyTagArgs { 7 | @Field(() => TagWhereInput, { nullable: true }) 8 | where?: TagWhereInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/tag/create-one-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { TagCreateInput } from './tag-create.input'; 4 | 5 | @ArgsType() 6 | export class CreateOneTagArgs { 7 | @Field(() => TagCreateInput, { nullable: false }) 8 | data!: TagCreateInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-max-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagMaxAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | tagId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | name?: true; 10 | } 11 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-max-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class TagMaxAggregate { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-min-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagMinAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | tagId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | name?: true; 10 | } 11 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-min-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class TagMinAggregate { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-where-unique.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagWhereUniqueInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/@generated/user/create-one-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { UserCreateInput } from './user-create.input'; 4 | 5 | @ArgsType() 6 | export class CreateOneUserArgs { 7 | @Field(() => UserCreateInput, { nullable: false }) 8 | data!: UserCreateInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/user/delete-many-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { UserWhereInput } from './user-where.input'; 4 | 5 | @ArgsType() 6 | export class DeleteManyUserArgs { 7 | @Field(() => UserWhereInput, { nullable: true }) 8 | where?: UserWhereInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-scalar-field.enum.ts: -------------------------------------------------------------------------------- 1 | import { registerEnumType } from '@nestjs/graphql'; 2 | 3 | export enum TagScalarFieldEnum { 4 | tagId = 'tagId', 5 | name = 'name', 6 | } 7 | 8 | registerEnumType(TagScalarFieldEnum, { 9 | name: 'TagScalarFieldEnum', 10 | description: undefined, 11 | }); 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 4 8 | end_of_line = lf 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [*.{json,yml}] 16 | indent_size = 2 17 | -------------------------------------------------------------------------------- /src/@generated/tag/delete-one-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class DeleteOneTagArgs { 7 | @Field(() => TagWhereUniqueInput, { nullable: false }) 8 | where!: TagWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-update-many-mutation.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagUpdateManyMutationInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/@generated/article/article-where-unique.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class ArticleWhereUniqueInput { 5 | @Field(() => String, { nullable: true }) 6 | articleId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | slug?: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/@generated/article/create-one-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateInput } from './article-create.input'; 4 | 5 | @ArgsType() 6 | export class CreateOneArticleArgs { 7 | @Field(() => ArticleCreateInput, { nullable: false }) 8 | data!: ArticleCreateInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/article/delete-many-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { ArticleWhereInput } from './article-where.input'; 4 | 5 | @ArgsType() 6 | export class DeleteManyArticleArgs { 7 | @Field(() => ArticleWhereInput, { nullable: true }) 8 | where?: ArticleWhereInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/comment/create-one-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { CommentCreateInput } from './comment-create.input'; 4 | 5 | @ArgsType() 6 | export class CreateOneCommentArgs { 7 | @Field(() => CommentCreateInput, { nullable: false }) 8 | data!: CommentCreateInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/comment/delete-many-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { CommentWhereInput } from './comment-where.input'; 4 | 5 | @ArgsType() 6 | export class DeleteManyCommentArgs { 7 | @Field(() => CommentWhereInput, { nullable: true }) 8 | where?: CommentWhereInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/tag/find-unique-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class FindUniqueTagArgs { 7 | @Field(() => TagWhereUniqueInput, { nullable: false }) 8 | where!: TagWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-unchecked-update-many.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagUncheckedUpdateManyInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-create-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagCreateWithoutArticlesInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: false }) 9 | name!: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-update-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagUpdateWithoutArticlesInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/@generated/user/delete-one-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { UserWhereUniqueInput } from './user-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class DeleteOneUserArgs { 7 | @Field(() => UserWhereUniqueInput, { nullable: false }) 8 | where!: UserWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/user/find-unique-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { UserWhereUniqueInput } from './user-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class FindUniqueUserArgs { 7 | @Field(() => UserWhereUniqueInput, { nullable: false }) 8 | where!: UserWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/app_modules/prisma/index.ts: -------------------------------------------------------------------------------- 1 | export { InjectRepository } from './inject-repository.decorator'; 2 | export { PrismaModule } from './prisma.module'; 3 | export { 4 | PrismaModuleAsyncOptions, 5 | PrismaModuleOptions, 6 | PrismaOptionsFactory, 7 | } from './prisma.providers'; 8 | export { PrismaRepository } from './prisma.repository'; 9 | -------------------------------------------------------------------------------- /src/comment/models/create-comment.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | import { IsNotEmpty } from 'class-validator'; 3 | 4 | /** 5 | * Create comment input object. 6 | */ 7 | @InputType() 8 | export class CreateCommentInput { 9 | @IsNotEmpty() 10 | @Field(() => String) 11 | body: string; 12 | } 13 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-order-by-relation-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class TagOrderByRelationAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | _count?: keyof typeof SortOrder; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-unchecked-update-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagUncheckedUpdateWithoutArticlesInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/@generated/user/user-order-by-relation-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class UserOrderByRelationAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | _count?: keyof typeof SortOrder; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/article/article-avg-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class ArticleAvgOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | favoritesCount?: keyof typeof SortOrder; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/article/article-sum-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class ArticleSumOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | favoritesCount?: keyof typeof SortOrder; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/article/delete-one-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class DeleteOneArticleArgs { 7 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 8 | where!: ArticleWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/article/find-unique-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class FindUniqueArticleArgs { 7 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 8 | where!: ArticleWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/comment/delete-one-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class DeleteOneCommentArgs { 7 | @Field(() => CommentWhereUniqueInput, { nullable: false }) 8 | where!: CommentWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/comment/find-unique-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class FindUniqueCommentArgs { 7 | @Field(() => CommentWhereUniqueInput, { nullable: false }) 8 | where!: CommentWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-unchecked-create-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagUncheckedCreateWithoutArticlesInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: false }) 9 | name!: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-unchecked-update-many-without-tags.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagUncheckedUpdateManyWithoutTagsInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/@generated/article/article-order-by-relation-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class ArticleOrderByRelationAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | _count?: keyof typeof SortOrder; 9 | } 10 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-order-by-relation-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class CommentOrderByRelationAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | _count?: keyof typeof SortOrder; 9 | } 10 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | printWidth: 88, 3 | trailingComma: 'all', 4 | tabWidth: 4, 5 | semi: true, 6 | singleQuote: true, 7 | arrowParens: 'avoid', 8 | overrides: [ 9 | { 10 | files: '*.{json,yml}', 11 | options: { 12 | tabWidth: 2, 13 | }, 14 | }, 15 | ], 16 | }; 17 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-order-by.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class TagOrderByInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | tagId?: SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | name?: SortOrder; 12 | } 13 | -------------------------------------------------------------------------------- /src/article/types/article.ts: -------------------------------------------------------------------------------- 1 | import { ArticleAuthor } from './article-author'; 2 | 3 | export interface Article { 4 | slug: string; 5 | title: string; 6 | description: string; 7 | body: string; 8 | tagList: string[]; 9 | createdAt: Date; 10 | updatedAt: Date; 11 | favorited: boolean; 12 | favoritesCount: number; 13 | author: ArticleAuthor; 14 | } 15 | -------------------------------------------------------------------------------- /src/tag/tag.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { PrismaModule } from 'app_modules/prisma'; 3 | 4 | import { TagResolver } from './tag.resolver'; 5 | import { TagService } from './tag.service'; 6 | 7 | @Module({ 8 | imports: [PrismaModule], 9 | providers: [TagResolver, TagService], 10 | exports: [TagService], 11 | }) 12 | export class TagModule {} 13 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-count-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagCountAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | tagId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | name?: true; 10 | 11 | @Field(() => Boolean, { nullable: true }) 12 | _all?: true; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-count-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class TagCountAggregate { 5 | @Field(() => Int, { nullable: false }) 6 | tagId!: number; 7 | 8 | @Field(() => Int, { nullable: false }) 9 | name!: number; 10 | 11 | @Field(() => Int, { nullable: false }) 12 | _all!: number; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/user-where-unique.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class UserWhereUniqueInput { 5 | @Field(() => String, { nullable: true }) 6 | userId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | email?: string; 10 | 11 | @Field(() => String, { nullable: true }) 12 | name?: string; 13 | } 14 | -------------------------------------------------------------------------------- /src/api/fragments/comment.ts: -------------------------------------------------------------------------------- 1 | import { userFields } from './user'; 2 | 3 | export const commentFields = /* GraphQL */ ` 4 | fragment commentFields on Comment { 5 | id: commentId 6 | createdAt 7 | updatedAt 8 | body 9 | author { 10 | ...userFields 11 | following: isFollowing 12 | } 13 | } 14 | ${userFields} 15 | `; 16 | -------------------------------------------------------------------------------- /src/article/author.guard.spec.ts: -------------------------------------------------------------------------------- 1 | import { ArticleService } from './article.service'; 2 | import { AuthorGuard } from './author.guard'; 3 | 4 | describe('AuthorGuard', () => { 5 | it('should be defined', () => { 6 | const { ArticleService } = jest.createMockFromModule('./article.service'); 7 | expect(new AuthorGuard(new ArticleService())).toBeDefined(); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /src/@generated/article/article-count.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class ArticleCount { 5 | @Field(() => Int, { nullable: false }) 6 | tags?: number; 7 | 8 | @Field(() => Int, { nullable: false }) 9 | favoritedBy?: number; 10 | 11 | @Field(() => Int, { nullable: false }) 12 | comments?: number; 13 | } 14 | -------------------------------------------------------------------------------- /src/comment/comment.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | 3 | import { ArticleModule } from '../article/article.module'; 4 | import { CommentResolver } from './comment.resolver'; 5 | import { CommentService } from './comment.service'; 6 | 7 | @Module({ 8 | imports: [ArticleModule], 9 | providers: [CommentService, CommentResolver], 10 | }) 11 | export class CommentModule {} 12 | -------------------------------------------------------------------------------- /src/@generated/user/user-relation-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserWhereInput } from './user-where.input'; 4 | 5 | @InputType() 6 | export class UserRelationFilter { 7 | @Field(() => UserWhereInput, { nullable: true }) 8 | is?: UserWhereInput; 9 | 10 | @Field(() => UserWhereInput, { nullable: true }) 11 | isNot?: UserWhereInput; 12 | } 13 | -------------------------------------------------------------------------------- /src/@generated/user/user-scalar-field.enum.ts: -------------------------------------------------------------------------------- 1 | import { registerEnumType } from '@nestjs/graphql'; 2 | 3 | export enum UserScalarFieldEnum { 4 | userId = 'userId', 5 | email = 'email', 6 | name = 'name', 7 | password = 'password', 8 | bio = 'bio', 9 | image = 'image', 10 | } 11 | 12 | registerEnumType(UserScalarFieldEnum, { 13 | name: 'UserScalarFieldEnum', 14 | description: undefined, 15 | }); 16 | -------------------------------------------------------------------------------- /src/@generated/article/article-relation-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleWhereInput } from './article-where.input'; 4 | 5 | @InputType() 6 | export class ArticleRelationFilter { 7 | @Field(() => ArticleWhereInput, { nullable: true }) 8 | is?: ArticleWhereInput; 9 | 10 | @Field(() => ArticleWhereInput, { nullable: true }) 11 | isNot?: ArticleWhereInput; 12 | } 13 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-max-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class TagMaxOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | tagId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | name?: keyof typeof SortOrder; 12 | } 13 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-min-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class TagMinOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | tagId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | name?: keyof typeof SortOrder; 12 | } 13 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-count-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class TagCountOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | tagId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | name?: keyof typeof SortOrder; 12 | } 13 | -------------------------------------------------------------------------------- /src/user/models/user-login.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | /** 4 | * Credentials DTO object. 5 | */ 6 | @InputType() 7 | export class UserLoginInput { 8 | @Field(() => String, { 9 | description: undefined, 10 | }) 11 | email: string; 12 | 13 | @Field(() => String, { 14 | nullable: false, 15 | description: undefined, 16 | }) 17 | password: string; 18 | } 19 | -------------------------------------------------------------------------------- /.releaserc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | '@semantic-release/commit-analyzer', 4 | '@semantic-release/release-notes-generator', 5 | '@semantic-release/changelog', 6 | [ 7 | '@semantic-release/npm', 8 | { 9 | pkgRoot: 'dist', 10 | }, 11 | ], 12 | '@semantic-release/github', 13 | '@semantic-release/git', 14 | ], 15 | }; 16 | -------------------------------------------------------------------------------- /src/tag/tag.resolver.ts: -------------------------------------------------------------------------------- 1 | import { Query, Resolver } from '@nestjs/graphql'; 2 | 3 | import { Tag } from './tag.model'; 4 | import { TagService } from './tag.service'; 5 | 6 | /** 7 | * Resolves tag object type. 8 | */ 9 | @Resolver() 10 | export class TagResolver { 11 | constructor(private readonly tagService: TagService) {} 12 | 13 | @Query(() => [Tag]) 14 | async tags() { 15 | return this.tagService.findMany(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/user/testing/index.ts: -------------------------------------------------------------------------------- 1 | import { Prisma } from '@prisma/client'; 2 | 3 | type UserPayload = Prisma.UserGetPayload; 4 | 5 | export function createUser(parts: Partial = {}): UserPayload { 6 | return { 7 | userId: 'user_id', 8 | email: 'user_email', 9 | name: 'user_name', 10 | password: 'user_password', 11 | bio: 'user_bio', 12 | image: 'user_image', 13 | ...parts, 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-scalar-field.enum.ts: -------------------------------------------------------------------------------- 1 | import { registerEnumType } from '@nestjs/graphql'; 2 | 3 | export enum CommentScalarFieldEnum { 4 | commentId = 'commentId', 5 | createdAt = 'createdAt', 6 | updatedAt = 'updatedAt', 7 | body = 'body', 8 | authorId = 'authorId', 9 | articleId = 'articleId', 10 | } 11 | 12 | registerEnumType(CommentScalarFieldEnum, { 13 | name: 'CommentScalarFieldEnum', 14 | description: undefined, 15 | }); 16 | -------------------------------------------------------------------------------- /src/@generated/tag/update-one-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { TagUpdateInput } from './tag-update.input'; 4 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 5 | 6 | @ArgsType() 7 | export class UpdateOneTagArgs { 8 | @Field(() => TagUpdateInput, { nullable: false }) 9 | data!: TagUpdateInput; 10 | 11 | @Field(() => TagWhereUniqueInput, { nullable: false }) 12 | where!: TagWhereUniqueInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/update-one-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { UserUpdateInput } from './user-update.input'; 4 | import { UserWhereUniqueInput } from './user-where-unique.input'; 5 | 6 | @ArgsType() 7 | export class UpdateOneUserArgs { 8 | @Field(() => UserUpdateInput, { nullable: false }) 9 | data!: UserUpdateInput; 10 | 11 | @Field(() => UserWhereUniqueInput, { nullable: false }) 12 | where!: UserWhereUniqueInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-list-relation-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { TagWhereInput } from './tag-where.input'; 4 | 5 | @InputType() 6 | export class TagListRelationFilter { 7 | @Field(() => TagWhereInput, { nullable: true }) 8 | every?: TagWhereInput; 9 | 10 | @Field(() => TagWhereInput, { nullable: true }) 11 | some?: TagWhereInput; 12 | 13 | @Field(() => TagWhereInput, { nullable: true }) 14 | none?: TagWhereInput; 15 | } 16 | -------------------------------------------------------------------------------- /src/@generated/tag/update-many-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { TagUpdateManyMutationInput } from './tag-update-many-mutation.input'; 4 | import { TagWhereInput } from './tag-where.input'; 5 | 6 | @ArgsType() 7 | export class UpdateManyTagArgs { 8 | @Field(() => TagUpdateManyMutationInput, { nullable: false }) 9 | data!: TagUpdateManyMutationInput; 10 | 11 | @Field(() => TagWhereInput, { nullable: true }) 12 | where?: TagWhereInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/user-list-relation-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserWhereInput } from './user-where.input'; 4 | 5 | @InputType() 6 | export class UserListRelationFilter { 7 | @Field(() => UserWhereInput, { nullable: true }) 8 | every?: UserWhereInput; 9 | 10 | @Field(() => UserWhereInput, { nullable: true }) 11 | some?: UserWhereInput; 12 | 13 | @Field(() => UserWhereInput, { nullable: true }) 14 | none?: UserWhereInput; 15 | } 16 | -------------------------------------------------------------------------------- /src/@generated/user/update-many-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { UserUpdateManyMutationInput } from './user-update-many-mutation.input'; 4 | import { UserWhereInput } from './user-where.input'; 5 | 6 | @ArgsType() 7 | export class UpdateManyUserArgs { 8 | @Field(() => UserUpdateManyMutationInput, { nullable: false }) 9 | data!: UserUpdateManyMutationInput; 10 | 11 | @Field(() => UserWhereInput, { nullable: true }) 12 | where?: UserWhereInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/article/update-one-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { ArticleUpdateInput } from './article-update.input'; 4 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 5 | 6 | @ArgsType() 7 | export class UpdateOneArticleArgs { 8 | @Field(() => ArticleUpdateInput, { nullable: false }) 9 | data!: ArticleUpdateInput; 10 | 11 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 12 | where!: ArticleWhereUniqueInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-update-many-mutation.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentUpdateManyMutationInput { 5 | @Field(() => String, { nullable: true }) 6 | commentId?: string; 7 | 8 | @Field(() => Date, { nullable: true }) 9 | createdAt?: Date | string; 10 | 11 | @Field(() => Date, { nullable: true }) 12 | updatedAt?: Date | string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | body?: string; 16 | } 17 | -------------------------------------------------------------------------------- /src/@generated/comment/update-one-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { CommentUpdateInput } from './comment-update.input'; 4 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 5 | 6 | @ArgsType() 7 | export class UpdateOneCommentArgs { 8 | @Field(() => CommentUpdateInput, { nullable: false }) 9 | data!: CommentUpdateInput; 10 | 11 | @Field(() => CommentWhereUniqueInput, { nullable: false }) 12 | where!: CommentWhereUniqueInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/api/fragments/article.ts: -------------------------------------------------------------------------------- 1 | import { userFields } from './user'; 2 | 3 | export const articleFields = /* GraphQL */ ` 4 | fragment articleFields on Article { 5 | slug 6 | title 7 | description 8 | body 9 | tags { 10 | name 11 | } 12 | createdAt 13 | updatedAt 14 | favorited 15 | favoritesCount 16 | author { 17 | ...userFields 18 | following: isFollowing 19 | } 20 | } 21 | ${userFields} 22 | `; 23 | -------------------------------------------------------------------------------- /src/@generated/article/article-list-relation-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleWhereInput } from './article-where.input'; 4 | 5 | @InputType() 6 | export class ArticleListRelationFilter { 7 | @Field(() => ArticleWhereInput, { nullable: true }) 8 | every?: ArticleWhereInput; 9 | 10 | @Field(() => ArticleWhereInput, { nullable: true }) 11 | some?: ArticleWhereInput; 12 | 13 | @Field(() => ArticleWhereInput, { nullable: true }) 14 | none?: ArticleWhereInput; 15 | } 16 | -------------------------------------------------------------------------------- /src/@generated/article/update-many-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { ArticleUpdateManyMutationInput } from './article-update-many-mutation.input'; 4 | import { ArticleWhereInput } from './article-where.input'; 5 | 6 | @ArgsType() 7 | export class UpdateManyArticleArgs { 8 | @Field(() => ArticleUpdateManyMutationInput, { nullable: false }) 9 | data!: ArticleUpdateManyMutationInput; 10 | 11 | @Field(() => ArticleWhereInput, { nullable: true }) 12 | where?: ArticleWhereInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-list-relation-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { CommentWhereInput } from './comment-where.input'; 4 | 5 | @InputType() 6 | export class CommentListRelationFilter { 7 | @Field(() => CommentWhereInput, { nullable: true }) 8 | every?: CommentWhereInput; 9 | 10 | @Field(() => CommentWhereInput, { nullable: true }) 11 | some?: CommentWhereInput; 12 | 13 | @Field(() => CommentWhereInput, { nullable: true }) 14 | none?: CommentWhereInput; 15 | } 16 | -------------------------------------------------------------------------------- /src/@generated/comment/update-many-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { CommentUpdateManyMutationInput } from './comment-update-many-mutation.input'; 4 | import { CommentWhereInput } from './comment-where.input'; 5 | 6 | @ArgsType() 7 | export class UpdateManyCommentArgs { 8 | @Field(() => CommentUpdateManyMutationInput, { nullable: false }) 9 | data!: CommentUpdateManyMutationInput; 10 | 11 | @Field(() => CommentWhereInput, { nullable: true }) 12 | where?: CommentWhereInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-update.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleUpdateManyWithoutTagsInput } from '../article/article-update-many-without-tags.input'; 4 | 5 | @InputType() 6 | export class TagUpdateInput { 7 | @Field(() => String, { nullable: true }) 8 | tagId?: string; 9 | 10 | @Field(() => String, { nullable: true }) 11 | name?: string; 12 | 13 | @Field(() => ArticleUpdateManyWithoutTagsInput, { nullable: true }) 14 | articles?: ArticleUpdateManyWithoutTagsInput; 15 | } 16 | -------------------------------------------------------------------------------- /src/@generated/user/user-count.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class UserCount { 5 | @Field(() => Int, { nullable: false }) 6 | following?: number; 7 | 8 | @Field(() => Int, { nullable: false }) 9 | followers?: number; 10 | 11 | @Field(() => Int, { nullable: false }) 12 | favoriteArticles?: number; 13 | 14 | @Field(() => Int, { nullable: false }) 15 | articles?: number; 16 | 17 | @Field(() => Int, { nullable: false }) 18 | comments?: number; 19 | } 20 | -------------------------------------------------------------------------------- /src/@generated/article/article-scalar-field.enum.ts: -------------------------------------------------------------------------------- 1 | import { registerEnumType } from '@nestjs/graphql'; 2 | 3 | export enum ArticleScalarFieldEnum { 4 | articleId = 'articleId', 5 | slug = 'slug', 6 | title = 'title', 7 | description = 'description', 8 | body = 'body', 9 | createdAt = 'createdAt', 10 | updatedAt = 'updatedAt', 11 | favoritesCount = 'favoritesCount', 12 | authorId = 'authorId', 13 | } 14 | 15 | registerEnumType(ArticleScalarFieldEnum, { 16 | name: 'ArticleScalarFieldEnum', 17 | description: undefined, 18 | }); 19 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-create.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateNestedManyWithoutTagsInput } from '../article/article-create-nested-many-without-tags.input'; 4 | 5 | @InputType() 6 | export class TagCreateInput { 7 | @Field(() => String, { nullable: true }) 8 | tagId?: string; 9 | 10 | @Field(() => String, { nullable: false }) 11 | name!: string; 12 | 13 | @Field(() => ArticleCreateNestedManyWithoutTagsInput, { nullable: true }) 14 | articles?: ArticleCreateNestedManyWithoutTagsInput; 15 | } 16 | -------------------------------------------------------------------------------- /src/app_modules/nestjs-authorization-token/index.ts: -------------------------------------------------------------------------------- 1 | import { createParamDecorator, ExecutionContext } from '@nestjs/common'; 2 | import { IncomingMessage } from 'node:http'; 3 | 4 | // tslint:disable-next-line:variable-name 5 | export const AuthorizationToken = createParamDecorator( 6 | (data: unknown, context: ExecutionContext) => { 7 | const request = context.switchToHttp().getRequest(); 8 | const authorization = request.headers.authorization; 9 | const [, token] = String(authorization).split(' '); 10 | return token; 11 | }, 12 | ); 13 | -------------------------------------------------------------------------------- /src/@generated/tag/tag.model.ts: -------------------------------------------------------------------------------- 1 | import { Field, ID, ObjectType } from '@nestjs/graphql'; 2 | 3 | import { Article } from '../article/article.model'; 4 | import { TagCount } from './tag-count.output'; 5 | 6 | @ObjectType() 7 | export class Tag { 8 | @Field(() => ID, { nullable: false }) 9 | tagId!: string; 10 | 11 | @Field(() => String, { nullable: false }) 12 | name!: string; 13 | 14 | @Field(() => [Article], { nullable: true }) 15 | articles?: Array
; 16 | 17 | @Field(() => TagCount, { nullable: false }) 18 | _count?: TagCount; 19 | } 20 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-update-many-with-where-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { TagScalarWhereInput } from './tag-scalar-where.input'; 4 | import { TagUpdateManyMutationInput } from './tag-update-many-mutation.input'; 5 | 6 | @InputType() 7 | export class TagUpdateManyWithWhereWithoutArticlesInput { 8 | @Field(() => TagScalarWhereInput, { nullable: false }) 9 | where!: TagScalarWhereInput; 10 | 11 | @Field(() => TagUpdateManyMutationInput, { nullable: false }) 12 | data!: TagUpdateManyMutationInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-create-or-connect-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { TagCreateWithoutArticlesInput } from './tag-create-without-articles.input'; 4 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 5 | 6 | @InputType() 7 | export class TagCreateOrConnectWithoutArticlesInput { 8 | @Field(() => TagWhereUniqueInput, { nullable: false }) 9 | where!: TagWhereUniqueInput; 10 | 11 | @Field(() => TagCreateWithoutArticlesInput, { nullable: false }) 12 | create!: TagCreateWithoutArticlesInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/user-update-many-with-where-without-followers.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserScalarWhereInput } from './user-scalar-where.input'; 4 | import { UserUpdateManyMutationInput } from './user-update-many-mutation.input'; 5 | 6 | @InputType() 7 | export class UserUpdateManyWithWhereWithoutFollowersInput { 8 | @Field(() => UserScalarWhereInput, { nullable: false }) 9 | where!: UserScalarWhereInput; 10 | 11 | @Field(() => UserUpdateManyMutationInput, { nullable: false }) 12 | data!: UserUpdateManyMutationInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/user-update-many-with-where-without-following.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserScalarWhereInput } from './user-scalar-where.input'; 4 | import { UserUpdateManyMutationInput } from './user-update-many-mutation.input'; 5 | 6 | @InputType() 7 | export class UserUpdateManyWithWhereWithoutFollowingInput { 8 | @Field(() => UserScalarWhereInput, { nullable: false }) 9 | where!: UserScalarWhereInput; 10 | 11 | @Field(() => UserUpdateManyMutationInput, { nullable: false }) 12 | data!: UserUpdateManyMutationInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-update-with-where-unique-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { TagUpdateWithoutArticlesInput } from './tag-update-without-articles.input'; 4 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 5 | 6 | @InputType() 7 | export class TagUpdateWithWhereUniqueWithoutArticlesInput { 8 | @Field(() => TagWhereUniqueInput, { nullable: false }) 9 | where!: TagWhereUniqueInput; 10 | 11 | @Field(() => TagUpdateWithoutArticlesInput, { nullable: false }) 12 | data!: TagUpdateWithoutArticlesInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/user-create-or-connect-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateWithoutArticlesInput } from './user-create-without-articles.input'; 4 | import { UserWhereUniqueInput } from './user-where-unique.input'; 5 | 6 | @InputType() 7 | export class UserCreateOrConnectWithoutArticlesInput { 8 | @Field(() => UserWhereUniqueInput, { nullable: false }) 9 | where!: UserWhereUniqueInput; 10 | 11 | @Field(() => UserCreateWithoutArticlesInput, { nullable: false }) 12 | create!: UserCreateWithoutArticlesInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/user-create-or-connect-without-comments.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateWithoutCommentsInput } from './user-create-without-comments.input'; 4 | import { UserWhereUniqueInput } from './user-where-unique.input'; 5 | 6 | @InputType() 7 | export class UserCreateOrConnectWithoutCommentsInput { 8 | @Field(() => UserWhereUniqueInput, { nullable: false }) 9 | where!: UserWhereUniqueInput; 10 | 11 | @Field(() => UserCreateWithoutCommentsInput, { nullable: false }) 12 | create!: UserCreateWithoutCommentsInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-unchecked-update.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleUncheckedUpdateManyWithoutTagsInput } from '../article/article-unchecked-update-many-without-tags.input'; 4 | 5 | @InputType() 6 | export class TagUncheckedUpdateInput { 7 | @Field(() => String, { nullable: true }) 8 | tagId?: string; 9 | 10 | @Field(() => String, { nullable: true }) 11 | name?: string; 12 | 13 | @Field(() => ArticleUncheckedUpdateManyWithoutTagsInput, { nullable: true }) 14 | articles?: ArticleUncheckedUpdateManyWithoutTagsInput; 15 | } 16 | -------------------------------------------------------------------------------- /src/@generated/user/user-create-or-connect-without-followers.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateWithoutFollowersInput } from './user-create-without-followers.input'; 4 | import { UserWhereUniqueInput } from './user-where-unique.input'; 5 | 6 | @InputType() 7 | export class UserCreateOrConnectWithoutFollowersInput { 8 | @Field(() => UserWhereUniqueInput, { nullable: false }) 9 | where!: UserWhereUniqueInput; 10 | 11 | @Field(() => UserCreateWithoutFollowersInput, { nullable: false }) 12 | create!: UserCreateWithoutFollowersInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/user-create-or-connect-without-following.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateWithoutFollowingInput } from './user-create-without-following.input'; 4 | import { UserWhereUniqueInput } from './user-where-unique.input'; 5 | 6 | @InputType() 7 | export class UserCreateOrConnectWithoutFollowingInput { 8 | @Field(() => UserWhereUniqueInput, { nullable: false }) 9 | where!: UserWhereUniqueInput; 10 | 11 | @Field(() => UserCreateWithoutFollowingInput, { nullable: false }) 12 | create!: UserCreateWithoutFollowingInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/article/article-create-or-connect-without-tags.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateWithoutTagsInput } from './article-create-without-tags.input'; 4 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 5 | 6 | @InputType() 7 | export class ArticleCreateOrConnectWithoutTagsInput { 8 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 9 | where!: ArticleWhereUniqueInput; 10 | 11 | @Field(() => ArticleCreateWithoutTagsInput, { nullable: false }) 12 | create!: ArticleCreateWithoutTagsInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/user-update-many-with-where-without-favorite-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserScalarWhereInput } from './user-scalar-where.input'; 4 | import { UserUpdateManyMutationInput } from './user-update-many-mutation.input'; 5 | 6 | @InputType() 7 | export class UserUpdateManyWithWhereWithoutFavoriteArticlesInput { 8 | @Field(() => UserScalarWhereInput, { nullable: false }) 9 | where!: UserScalarWhereInput; 10 | 11 | @Field(() => UserUpdateManyMutationInput, { nullable: false }) 12 | data!: UserUpdateManyMutationInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/article/article.repository.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { PrismaRepository } from 'app_modules/prisma'; 3 | 4 | /** 5 | * Repository to work with database. 6 | */ 7 | @Injectable() 8 | export class ArticleRepository { 9 | update = this.prisma.article.update; 10 | findUnique = this.prisma.article.findUnique; 11 | findMany = this.prisma.article.findMany; 12 | create = this.prisma.article.create; 13 | count = this.prisma.article.count; 14 | delete = this.prisma.article.delete; 15 | 16 | constructor(private readonly prisma: PrismaRepository) {} 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/user/user-update-with-where-unique-without-followers.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserUpdateWithoutFollowersInput } from './user-update-without-followers.input'; 4 | import { UserWhereUniqueInput } from './user-where-unique.input'; 5 | 6 | @InputType() 7 | export class UserUpdateWithWhereUniqueWithoutFollowersInput { 8 | @Field(() => UserWhereUniqueInput, { nullable: false }) 9 | where!: UserWhereUniqueInput; 10 | 11 | @Field(() => UserUpdateWithoutFollowersInput, { nullable: false }) 12 | data!: UserUpdateWithoutFollowersInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/user-update-with-where-unique-without-following.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserUpdateWithoutFollowingInput } from './user-update-without-following.input'; 4 | import { UserWhereUniqueInput } from './user-where-unique.input'; 5 | 6 | @InputType() 7 | export class UserUpdateWithWhereUniqueWithoutFollowingInput { 8 | @Field(() => UserWhereUniqueInput, { nullable: false }) 9 | where!: UserWhereUniqueInput; 10 | 11 | @Field(() => UserUpdateWithoutFollowingInput, { nullable: false }) 12 | data!: UserUpdateWithoutFollowingInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/article/article-create-or-connect-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateWithoutAuthorInput } from './article-create-without-author.input'; 4 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 5 | 6 | @InputType() 7 | export class ArticleCreateOrConnectWithoutAuthorInput { 8 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 9 | where!: ArticleWhereUniqueInput; 10 | 11 | @Field(() => ArticleCreateWithoutAuthorInput, { nullable: false }) 12 | create!: ArticleCreateWithoutAuthorInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/article/article-update-many-with-where-without-tags.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleScalarWhereInput } from './article-scalar-where.input'; 4 | import { ArticleUpdateManyMutationInput } from './article-update-many-mutation.input'; 5 | 6 | @InputType() 7 | export class ArticleUpdateManyWithWhereWithoutTagsInput { 8 | @Field(() => ArticleScalarWhereInput, { nullable: false }) 9 | where!: ArticleScalarWhereInput; 10 | 11 | @Field(() => ArticleUpdateManyMutationInput, { nullable: false }) 12 | data!: ArticleUpdateManyMutationInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/article/article-update-with-where-unique-without-tags.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleUpdateWithoutTagsInput } from './article-update-without-tags.input'; 4 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 5 | 6 | @InputType() 7 | export class ArticleUpdateWithWhereUniqueWithoutTagsInput { 8 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 9 | where!: ArticleWhereUniqueInput; 10 | 11 | @Field(() => ArticleUpdateWithoutTagsInput, { nullable: false }) 12 | data!: ArticleUpdateWithoutTagsInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-create-or-connect-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { CommentCreateWithoutAuthorInput } from './comment-create-without-author.input'; 4 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 5 | 6 | @InputType() 7 | export class CommentCreateOrConnectWithoutAuthorInput { 8 | @Field(() => CommentWhereUniqueInput, { nullable: false }) 9 | where!: CommentWhereUniqueInput; 10 | 11 | @Field(() => CommentCreateWithoutAuthorInput, { nullable: false }) 12 | create!: CommentCreateWithoutAuthorInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/user-upsert-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateWithoutArticlesInput } from './user-create-without-articles.input'; 4 | import { UserUpdateWithoutArticlesInput } from './user-update-without-articles.input'; 5 | 6 | @InputType() 7 | export class UserUpsertWithoutArticlesInput { 8 | @Field(() => UserUpdateWithoutArticlesInput, { nullable: false }) 9 | update!: UserUpdateWithoutArticlesInput; 10 | 11 | @Field(() => UserCreateWithoutArticlesInput, { nullable: false }) 12 | create!: UserCreateWithoutArticlesInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/user-upsert-without-comments.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateWithoutCommentsInput } from './user-create-without-comments.input'; 4 | import { UserUpdateWithoutCommentsInput } from './user-update-without-comments.input'; 5 | 6 | @InputType() 7 | export class UserUpsertWithoutCommentsInput { 8 | @Field(() => UserUpdateWithoutCommentsInput, { nullable: false }) 9 | update!: UserUpdateWithoutCommentsInput; 10 | 11 | @Field(() => UserCreateWithoutCommentsInput, { nullable: false }) 12 | create!: UserCreateWithoutCommentsInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/article/article-update-many-with-where-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleScalarWhereInput } from './article-scalar-where.input'; 4 | import { ArticleUpdateManyMutationInput } from './article-update-many-mutation.input'; 5 | 6 | @InputType() 7 | export class ArticleUpdateManyWithWhereWithoutAuthorInput { 8 | @Field(() => ArticleScalarWhereInput, { nullable: false }) 9 | where!: ArticleScalarWhereInput; 10 | 11 | @Field(() => ArticleUpdateManyMutationInput, { nullable: false }) 12 | data!: ArticleUpdateManyMutationInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-create-or-connect-without-article.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { CommentCreateWithoutArticleInput } from './comment-create-without-article.input'; 4 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 5 | 6 | @InputType() 7 | export class CommentCreateOrConnectWithoutArticleInput { 8 | @Field(() => CommentWhereUniqueInput, { nullable: false }) 9 | where!: CommentWhereUniqueInput; 10 | 11 | @Field(() => CommentCreateWithoutArticleInput, { nullable: false }) 12 | create!: CommentCreateWithoutArticleInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-unchecked-create-without-article.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentUncheckedCreateWithoutArticleInput { 5 | @Field(() => String, { nullable: true }) 6 | commentId?: string; 7 | 8 | @Field(() => Date, { nullable: true }) 9 | createdAt?: Date | string; 10 | 11 | @Field(() => Date, { nullable: true }) 12 | updatedAt?: Date | string; 13 | 14 | @Field(() => String, { nullable: false }) 15 | body!: string; 16 | 17 | @Field(() => String, { nullable: false }) 18 | authorId!: string; 19 | } 20 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-unchecked-create-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentUncheckedCreateWithoutAuthorInput { 5 | @Field(() => String, { nullable: true }) 6 | commentId?: string; 7 | 8 | @Field(() => Date, { nullable: true }) 9 | createdAt?: Date | string; 10 | 11 | @Field(() => Date, { nullable: true }) 12 | updatedAt?: Date | string; 13 | 14 | @Field(() => String, { nullable: false }) 15 | body!: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | articleId?: string; 19 | } 20 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-unchecked-update-without-article.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentUncheckedUpdateWithoutArticleInput { 5 | @Field(() => String, { nullable: true }) 6 | commentId?: string; 7 | 8 | @Field(() => Date, { nullable: true }) 9 | createdAt?: Date | string; 10 | 11 | @Field(() => Date, { nullable: true }) 12 | updatedAt?: Date | string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | body?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | authorId?: string; 19 | } 20 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-unchecked-update-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentUncheckedUpdateWithoutAuthorInput { 5 | @Field(() => String, { nullable: true }) 6 | commentId?: string; 7 | 8 | @Field(() => Date, { nullable: true }) 9 | createdAt?: Date | string; 10 | 11 | @Field(() => Date, { nullable: true }) 12 | updatedAt?: Date | string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | body?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | articleId?: string; 19 | } 20 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-update-many-with-where-without-article.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { CommentScalarWhereInput } from './comment-scalar-where.input'; 4 | import { CommentUpdateManyMutationInput } from './comment-update-many-mutation.input'; 5 | 6 | @InputType() 7 | export class CommentUpdateManyWithWhereWithoutArticleInput { 8 | @Field(() => CommentScalarWhereInput, { nullable: false }) 9 | where!: CommentScalarWhereInput; 10 | 11 | @Field(() => CommentUpdateManyMutationInput, { nullable: false }) 12 | data!: CommentUpdateManyMutationInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-update-many-with-where-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { CommentScalarWhereInput } from './comment-scalar-where.input'; 4 | import { CommentUpdateManyMutationInput } from './comment-update-many-mutation.input'; 5 | 6 | @InputType() 7 | export class CommentUpdateManyWithWhereWithoutAuthorInput { 8 | @Field(() => CommentScalarWhereInput, { nullable: false }) 9 | where!: CommentScalarWhereInput; 10 | 11 | @Field(() => CommentUpdateManyMutationInput, { nullable: false }) 12 | data!: CommentUpdateManyMutationInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/api/models/get-articles.dto.ts: -------------------------------------------------------------------------------- 1 | import { Transform } from 'class-transformer'; 2 | import { IsInt, IsOptional, Max } from 'class-validator'; 3 | 4 | /** 5 | * Type for query string when request list of articles. 6 | */ 7 | export class GetArticlesDto { 8 | @IsOptional() 9 | tag?: string; 10 | 11 | @IsOptional() 12 | author?: string; 13 | 14 | @IsOptional() 15 | favorited?: string; 16 | 17 | @IsOptional() 18 | @IsInt() 19 | @Transform(Number) 20 | offset = 0; 21 | 22 | @IsOptional() 23 | @IsInt() 24 | @Transform(Number) 25 | @Max(100) 26 | limit = 20; 27 | } 28 | -------------------------------------------------------------------------------- /src/@generated/article/article-update-with-where-unique-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleUpdateWithoutAuthorInput } from './article-update-without-author.input'; 4 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 5 | 6 | @InputType() 7 | export class ArticleUpdateWithWhereUniqueWithoutAuthorInput { 8 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 9 | where!: ArticleWhereUniqueInput; 10 | 11 | @Field(() => ArticleUpdateWithoutAuthorInput, { nullable: false }) 12 | data!: ArticleUpdateWithoutAuthorInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-update-with-where-unique-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { CommentUpdateWithoutAuthorInput } from './comment-update-without-author.input'; 4 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 5 | 6 | @InputType() 7 | export class CommentUpdateWithWhereUniqueWithoutAuthorInput { 8 | @Field(() => CommentWhereUniqueInput, { nullable: false }) 9 | where!: CommentWhereUniqueInput; 10 | 11 | @Field(() => CommentUpdateWithoutAuthorInput, { nullable: false }) 12 | data!: CommentUpdateWithoutAuthorInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-unchecked-create.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleUncheckedCreateNestedManyWithoutTagsInput } from '../article/article-unchecked-create-nested-many-without-tags.input'; 4 | 5 | @InputType() 6 | export class TagUncheckedCreateInput { 7 | @Field(() => String, { nullable: true }) 8 | tagId?: string; 9 | 10 | @Field(() => String, { nullable: false }) 11 | name!: string; 12 | 13 | @Field(() => ArticleUncheckedCreateNestedManyWithoutTagsInput, { nullable: true }) 14 | articles?: ArticleUncheckedCreateNestedManyWithoutTagsInput; 15 | } 16 | -------------------------------------------------------------------------------- /src/@generated/user/user-max-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class UserMaxAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | userId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | email?: true; 10 | 11 | @Field(() => Boolean, { nullable: true }) 12 | name?: true; 13 | 14 | @Field(() => Boolean, { nullable: true }) 15 | password?: true; 16 | 17 | @Field(() => Boolean, { nullable: true }) 18 | bio?: true; 19 | 20 | @Field(() => Boolean, { nullable: true }) 21 | image?: true; 22 | } 23 | -------------------------------------------------------------------------------- /src/@generated/user/user-min-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class UserMinAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | userId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | email?: true; 10 | 11 | @Field(() => Boolean, { nullable: true }) 12 | name?: true; 13 | 14 | @Field(() => Boolean, { nullable: true }) 15 | password?: true; 16 | 17 | @Field(() => Boolean, { nullable: true }) 18 | bio?: true; 19 | 20 | @Field(() => Boolean, { nullable: true }) 21 | image?: true; 22 | } 23 | -------------------------------------------------------------------------------- /src/user/user.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { PrismaModule } from 'app_modules/prisma'; 3 | 4 | import { AuthModule } from '../auth/auth.module'; 5 | import { UserRepository } from './user.repository'; 6 | import { UserResolver } from './user.resolver'; 7 | import { UserService } from './user.service'; 8 | import { UserExistsValidator } from './validators/user-exists.validator'; 9 | 10 | @Module({ 11 | imports: [PrismaModule, AuthModule], 12 | providers: [UserService, UserResolver, UserRepository, UserExistsValidator], 13 | exports: [UserService], 14 | }) 15 | export class UserModule {} 16 | -------------------------------------------------------------------------------- /src/@generated/article/article-create-or-connect-without-comments.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateWithoutCommentsInput } from './article-create-without-comments.input'; 4 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 5 | 6 | @InputType() 7 | export class ArticleCreateOrConnectWithoutCommentsInput { 8 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 9 | where!: ArticleWhereUniqueInput; 10 | 11 | @Field(() => ArticleCreateWithoutCommentsInput, { nullable: false }) 12 | create!: ArticleCreateWithoutCommentsInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/article/article-update-many-with-where-without-favorited-by.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleScalarWhereInput } from './article-scalar-where.input'; 4 | import { ArticleUpdateManyMutationInput } from './article-update-many-mutation.input'; 5 | 6 | @InputType() 7 | export class ArticleUpdateManyWithWhereWithoutFavoritedByInput { 8 | @Field(() => ArticleScalarWhereInput, { nullable: false }) 9 | where!: ArticleScalarWhereInput; 10 | 11 | @Field(() => ArticleUpdateManyMutationInput, { nullable: false }) 12 | data!: ArticleUpdateManyMutationInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-unchecked-update-many-without-comments.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentUncheckedUpdateManyWithoutCommentsInput { 5 | @Field(() => String, { nullable: true }) 6 | commentId?: string; 7 | 8 | @Field(() => Date, { nullable: true }) 9 | createdAt?: Date | string; 10 | 11 | @Field(() => Date, { nullable: true }) 12 | updatedAt?: Date | string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | body?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | articleId?: string; 19 | } 20 | -------------------------------------------------------------------------------- /src/@generated/tag/upsert-one-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { TagCreateInput } from './tag-create.input'; 4 | import { TagUpdateInput } from './tag-update.input'; 5 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 6 | 7 | @ArgsType() 8 | export class UpsertOneTagArgs { 9 | @Field(() => TagWhereUniqueInput, { nullable: false }) 10 | where!: TagWhereUniqueInput; 11 | 12 | @Field(() => TagCreateInput, { nullable: false }) 13 | create!: TagCreateInput; 14 | 15 | @Field(() => TagUpdateInput, { nullable: false }) 16 | update!: TagUpdateInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/user/user-max-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class UserMaxAggregate { 5 | @Field(() => String, { nullable: true }) 6 | userId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | email?: string; 10 | 11 | @Field(() => String, { nullable: true }) 12 | name?: string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | password?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | bio?: string; 19 | 20 | @Field(() => String, { nullable: true }) 21 | image?: string; 22 | } 23 | -------------------------------------------------------------------------------- /src/@generated/user/user-min-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class UserMinAggregate { 5 | @Field(() => String, { nullable: true }) 6 | userId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | email?: string; 10 | 11 | @Field(() => String, { nullable: true }) 12 | name?: string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | password?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | bio?: string; 19 | 20 | @Field(() => String, { nullable: true }) 21 | image?: string; 22 | } 23 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-update-with-where-unique-without-article.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { CommentUpdateWithoutArticleInput } from './comment-update-without-article.input'; 4 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 5 | 6 | @InputType() 7 | export class CommentUpdateWithWhereUniqueWithoutArticleInput { 8 | @Field(() => CommentWhereUniqueInput, { nullable: false }) 9 | where!: CommentWhereUniqueInput; 10 | 11 | @Field(() => CommentUpdateWithoutArticleInput, { nullable: false }) 12 | data!: CommentUpdateWithoutArticleInput; 13 | } 14 | -------------------------------------------------------------------------------- /test/run-api-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -x 3 | 4 | SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" 5 | 6 | APISCHEME=${APISCHEME:-http} 7 | APIURL=${APIURL:-conduit.productionready.io/api} 8 | USERNAME=${USERNAME:-u$(date +%s)} 9 | EMAIL=${EMAIL:-$USERNAME@mail.com} 10 | PASSWORD=${PASSWORD:-password} 11 | 12 | npx newman run $SCRIPTDIR/Conduit.postman_collection.json \ 13 | --delay-request 100 \ 14 | --global-var "APISCHEME=$APISCHEME" \ 15 | --global-var "APIURL=$APIURL" \ 16 | --global-var "USERNAME=$USERNAME" \ 17 | --global-var "EMAIL=$EMAIL" \ 18 | --global-var "PASSWORD=$PASSWORD" 19 | -------------------------------------------------------------------------------- /src/@generated/tag/aggregate-tag.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | import { TagCountAggregate } from './tag-count-aggregate.output'; 4 | import { TagMaxAggregate } from './tag-max-aggregate.output'; 5 | import { TagMinAggregate } from './tag-min-aggregate.output'; 6 | 7 | @ObjectType() 8 | export class AggregateTag { 9 | @Field(() => TagCountAggregate, { nullable: true }) 10 | _count?: TagCountAggregate; 11 | 12 | @Field(() => TagMinAggregate, { nullable: true }) 13 | _min?: TagMinAggregate; 14 | 15 | @Field(() => TagMaxAggregate, { nullable: true }) 16 | _max?: TagMaxAggregate; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/user/upsert-one-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { UserCreateInput } from './user-create.input'; 4 | import { UserUpdateInput } from './user-update.input'; 5 | import { UserWhereUniqueInput } from './user-where-unique.input'; 6 | 7 | @ArgsType() 8 | export class UpsertOneUserArgs { 9 | @Field(() => UserWhereUniqueInput, { nullable: false }) 10 | where!: UserWhereUniqueInput; 11 | 12 | @Field(() => UserCreateInput, { nullable: false }) 13 | create!: UserCreateInput; 14 | 15 | @Field(() => UserUpdateInput, { nullable: false }) 16 | update!: UserUpdateInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/user/user-create-or-connect-without-favorite-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateWithoutFavoriteArticlesInput } from './user-create-without-favorite-articles.input'; 4 | import { UserWhereUniqueInput } from './user-where-unique.input'; 5 | 6 | @InputType() 7 | export class UserCreateOrConnectWithoutFavoriteArticlesInput { 8 | @Field(() => UserWhereUniqueInput, { nullable: false }) 9 | where!: UserWhereUniqueInput; 10 | 11 | @Field(() => UserCreateWithoutFavoriteArticlesInput, { nullable: false }) 12 | create!: UserCreateWithoutFavoriteArticlesInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/user-update-many-mutation.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class UserUpdateManyMutationInput { 5 | @Field(() => String, { nullable: true }) 6 | userId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | email?: string; 10 | 11 | @Field(() => String, { nullable: true }) 12 | name?: string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | password?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | bio?: string; 19 | 20 | @Field(() => String, { nullable: true }) 21 | image?: string; 22 | } 23 | -------------------------------------------------------------------------------- /src/app_modules/nestjs-passport-graphql-auth-guard/optional-graphql-auth.guard.ts: -------------------------------------------------------------------------------- 1 | import { GraphqlAuthGuard } from './graphql-auth.guard'; 2 | 3 | /** 4 | * Used to trigger perform logic auth passport.authinticate() middleware, 5 | * to assign req.user if it exists. 6 | * This guard always return true. 7 | */ 8 | export class OptionalGraphqlAuthGuard extends GraphqlAuthGuard { 9 | handleRequest(err, user, info, context, status) { 10 | try { 11 | user = super.handleRequest(err, user, info, context, status); 12 | } catch { 13 | user = undefined; 14 | } 15 | return user; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/article/article-create-or-connect-without-favorited-by.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateWithoutFavoritedByInput } from './article-create-without-favorited-by.input'; 4 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 5 | 6 | @InputType() 7 | export class ArticleCreateOrConnectWithoutFavoritedByInput { 8 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 9 | where!: ArticleWhereUniqueInput; 10 | 11 | @Field(() => ArticleCreateWithoutFavoritedByInput, { nullable: false }) 12 | create!: ArticleCreateWithoutFavoritedByInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/article/article-upsert-without-comments.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateWithoutCommentsInput } from './article-create-without-comments.input'; 4 | import { ArticleUpdateWithoutCommentsInput } from './article-update-without-comments.input'; 5 | 6 | @InputType() 7 | export class ArticleUpsertWithoutCommentsInput { 8 | @Field(() => ArticleUpdateWithoutCommentsInput, { nullable: false }) 9 | update!: ArticleUpdateWithoutCommentsInput; 10 | 11 | @Field(() => ArticleCreateWithoutCommentsInput, { nullable: false }) 12 | create!: ArticleCreateWithoutCommentsInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/user-unchecked-update-many.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class UserUncheckedUpdateManyInput { 5 | @Field(() => String, { nullable: true }) 6 | userId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | email?: string; 10 | 11 | @Field(() => String, { nullable: true }) 12 | name?: string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | password?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | bio?: string; 19 | 20 | @Field(() => String, { nullable: true }) 21 | image?: string; 22 | } 23 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-max-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentMaxAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | commentId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | createdAt?: true; 10 | 11 | @Field(() => Boolean, { nullable: true }) 12 | updatedAt?: true; 13 | 14 | @Field(() => Boolean, { nullable: true }) 15 | body?: true; 16 | 17 | @Field(() => Boolean, { nullable: true }) 18 | authorId?: true; 19 | 20 | @Field(() => Boolean, { nullable: true }) 21 | articleId?: true; 22 | } 23 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-min-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentMinAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | commentId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | createdAt?: true; 10 | 11 | @Field(() => Boolean, { nullable: true }) 12 | updatedAt?: true; 13 | 14 | @Field(() => Boolean, { nullable: true }) 15 | body?: true; 16 | 17 | @Field(() => Boolean, { nullable: true }) 18 | authorId?: true; 19 | 20 | @Field(() => Boolean, { nullable: true }) 21 | articleId?: true; 22 | } 23 | -------------------------------------------------------------------------------- /src/@generated/user/user-update-with-where-unique-without-favorite-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserUpdateWithoutFavoriteArticlesInput } from './user-update-without-favorite-articles.input'; 4 | import { UserWhereUniqueInput } from './user-where-unique.input'; 5 | 6 | @InputType() 7 | export class UserUpdateWithWhereUniqueWithoutFavoriteArticlesInput { 8 | @Field(() => UserWhereUniqueInput, { nullable: false }) 9 | where!: UserWhereUniqueInput; 10 | 11 | @Field(() => UserUpdateWithoutFavoriteArticlesInput, { nullable: false }) 12 | data!: UserUpdateWithoutFavoriteArticlesInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/article/article-update-with-where-unique-without-favorited-by.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleUpdateWithoutFavoritedByInput } from './article-update-without-favorited-by.input'; 4 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 5 | 6 | @InputType() 7 | export class ArticleUpdateWithWhereUniqueWithoutFavoritedByInput { 8 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 9 | where!: ArticleWhereUniqueInput; 10 | 11 | @Field(() => ArticleUpdateWithoutFavoritedByInput, { nullable: false }) 12 | data!: ArticleUpdateWithoutFavoritedByInput; 13 | } 14 | -------------------------------------------------------------------------------- /src/@generated/user/aggregate-user.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | import { UserCountAggregate } from './user-count-aggregate.output'; 4 | import { UserMaxAggregate } from './user-max-aggregate.output'; 5 | import { UserMinAggregate } from './user-min-aggregate.output'; 6 | 7 | @ObjectType() 8 | export class AggregateUser { 9 | @Field(() => UserCountAggregate, { nullable: true }) 10 | _count?: UserCountAggregate; 11 | 12 | @Field(() => UserMinAggregate, { nullable: true }) 13 | _min?: UserMinAggregate; 14 | 15 | @Field(() => UserMaxAggregate, { nullable: true }) 16 | _max?: UserMaxAggregate; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-max-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class CommentMaxAggregate { 5 | @Field(() => String, { nullable: true }) 6 | commentId?: string; 7 | 8 | @Field(() => Date, { nullable: true }) 9 | createdAt?: Date | string; 10 | 11 | @Field(() => Date, { nullable: true }) 12 | updatedAt?: Date | string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | body?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | authorId?: string; 19 | 20 | @Field(() => String, { nullable: true }) 21 | articleId?: string; 22 | } 23 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-min-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class CommentMinAggregate { 5 | @Field(() => String, { nullable: true }) 6 | commentId?: string; 7 | 8 | @Field(() => Date, { nullable: true }) 9 | createdAt?: Date | string; 10 | 11 | @Field(() => Date, { nullable: true }) 12 | updatedAt?: Date | string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | body?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | authorId?: string; 19 | 20 | @Field(() => String, { nullable: true }) 21 | articleId?: string; 22 | } 23 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-unchecked-create.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentUncheckedCreateInput { 5 | @Field(() => String, { nullable: true }) 6 | commentId?: string; 7 | 8 | @Field(() => Date, { nullable: true }) 9 | createdAt?: Date | string; 10 | 11 | @Field(() => Date, { nullable: true }) 12 | updatedAt?: Date | string; 13 | 14 | @Field(() => String, { nullable: false }) 15 | body!: string; 16 | 17 | @Field(() => String, { nullable: false }) 18 | authorId!: string; 19 | 20 | @Field(() => String, { nullable: true }) 21 | articleId?: string; 22 | } 23 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-unchecked-update.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentUncheckedUpdateInput { 5 | @Field(() => String, { nullable: true }) 6 | commentId?: string; 7 | 8 | @Field(() => Date, { nullable: true }) 9 | createdAt?: Date | string; 10 | 11 | @Field(() => Date, { nullable: true }) 12 | updatedAt?: Date | string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | body?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | authorId?: string; 19 | 20 | @Field(() => String, { nullable: true }) 21 | articleId?: string; 22 | } 23 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-order-by-with-relation.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleOrderByRelationAggregateInput } from '../article/article-order-by-relation-aggregate.input'; 4 | import { SortOrder } from '../prisma/sort-order.enum'; 5 | 6 | @InputType() 7 | export class TagOrderByWithRelationInput { 8 | @Field(() => SortOrder, { nullable: true }) 9 | tagId?: keyof typeof SortOrder; 10 | 11 | @Field(() => SortOrder, { nullable: true }) 12 | name?: keyof typeof SortOrder; 13 | 14 | @Field(() => ArticleOrderByRelationAggregateInput, { nullable: true }) 15 | articles?: ArticleOrderByRelationAggregateInput; 16 | } 17 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-unchecked-update-many.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentUncheckedUpdateManyInput { 5 | @Field(() => String, { nullable: true }) 6 | commentId?: string; 7 | 8 | @Field(() => Date, { nullable: true }) 9 | createdAt?: Date | string; 10 | 11 | @Field(() => Date, { nullable: true }) 12 | updatedAt?: Date | string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | body?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | authorId?: string; 19 | 20 | @Field(() => String, { nullable: true }) 21 | articleId?: string; 22 | } 23 | -------------------------------------------------------------------------------- /src/@generated/user/user-unchecked-update-many-without-favorited-by.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class UserUncheckedUpdateManyWithoutFavoritedByInput { 5 | @Field(() => String, { nullable: true }) 6 | userId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | email?: string; 10 | 11 | @Field(() => String, { nullable: true }) 12 | name?: string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | password?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | bio?: string; 19 | 20 | @Field(() => String, { nullable: true }) 21 | image?: string; 22 | } 23 | -------------------------------------------------------------------------------- /src/@generated/article/upsert-one-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateInput } from './article-create.input'; 4 | import { ArticleUpdateInput } from './article-update.input'; 5 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 6 | 7 | @ArgsType() 8 | export class UpsertOneArticleArgs { 9 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 10 | where!: ArticleWhereUniqueInput; 11 | 12 | @Field(() => ArticleCreateInput, { nullable: false }) 13 | create!: ArticleCreateInput; 14 | 15 | @Field(() => ArticleUpdateInput, { nullable: false }) 16 | update!: ArticleUpdateInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/comment/upsert-one-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { CommentCreateInput } from './comment-create.input'; 4 | import { CommentUpdateInput } from './comment-update.input'; 5 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 6 | 7 | @ArgsType() 8 | export class UpsertOneCommentArgs { 9 | @Field(() => CommentWhereUniqueInput, { nullable: false }) 10 | where!: CommentWhereUniqueInput; 11 | 12 | @Field(() => CommentCreateInput, { nullable: false }) 13 | create!: CommentCreateInput; 14 | 15 | @Field(() => CommentUpdateInput, { nullable: false }) 16 | update!: CommentUpdateInput; 17 | } 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es2017", 5 | "importHelpers": true, 6 | "declaration": false, 7 | "removeComments": true, 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "esModuleInterop": true, 11 | "sourceMap": true, 12 | "skipLibCheck": true, 13 | "strictNullChecks": true, 14 | "incremental": true, 15 | "outDir": "./dist", 16 | "baseUrl": ".", 17 | "paths": { 18 | "@generated/*": ["src/@generated/*"], 19 | "app_modules/*": ["src/app_modules/*"] 20 | } 21 | }, 22 | "include": ["src/**/*.ts", "test/**/*.ts", "@generated/*", "prisma/*.ts"] 23 | } 24 | -------------------------------------------------------------------------------- /src/@generated/comment/aggregate-comment.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | import { CommentCountAggregate } from './comment-count-aggregate.output'; 4 | import { CommentMaxAggregate } from './comment-max-aggregate.output'; 5 | import { CommentMinAggregate } from './comment-min-aggregate.output'; 6 | 7 | @ObjectType() 8 | export class AggregateComment { 9 | @Field(() => CommentCountAggregate, { nullable: true }) 10 | _count?: CommentCountAggregate; 11 | 12 | @Field(() => CommentMinAggregate, { nullable: true }) 13 | _min?: CommentMinAggregate; 14 | 15 | @Field(() => CommentMaxAggregate, { nullable: true }) 16 | _max?: CommentMaxAggregate; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/user/user-count-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class UserCountAggregate { 5 | @Field(() => Int, { nullable: false }) 6 | userId!: number; 7 | 8 | @Field(() => Int, { nullable: false }) 9 | email!: number; 10 | 11 | @Field(() => Int, { nullable: false }) 12 | name!: number; 13 | 14 | @Field(() => Int, { nullable: false }) 15 | password!: number; 16 | 17 | @Field(() => Int, { nullable: false }) 18 | bio!: number; 19 | 20 | @Field(() => Int, { nullable: false }) 21 | image!: number; 22 | 23 | @Field(() => Int, { nullable: false }) 24 | _all!: number; 25 | } 26 | -------------------------------------------------------------------------------- /src/@generated/user/user-count-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class UserCountAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | userId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | email?: true; 10 | 11 | @Field(() => Boolean, { nullable: true }) 12 | name?: true; 13 | 14 | @Field(() => Boolean, { nullable: true }) 15 | password?: true; 16 | 17 | @Field(() => Boolean, { nullable: true }) 18 | bio?: true; 19 | 20 | @Field(() => Boolean, { nullable: true }) 21 | image?: true; 22 | 23 | @Field(() => Boolean, { nullable: true }) 24 | _all?: true; 25 | } 26 | -------------------------------------------------------------------------------- /src/auth/auth.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { JwtModule } from '@nestjs/jwt'; 3 | import { PassportModule } from '@nestjs/passport'; 4 | 5 | import { AuthService } from './auth.service'; 6 | import { JwtStrategy } from './jwt.strategy'; 7 | import { SessionService } from './session.service'; 8 | 9 | @Module({ 10 | imports: [ 11 | PassportModule.register({ 12 | defaultStrategy: 'jwt', 13 | }), 14 | JwtModule.register({ 15 | secret: process.env.JWT_SECRET_KEY, 16 | }), 17 | ], 18 | providers: [AuthService, JwtStrategy, SessionService], 19 | exports: [AuthService, SessionService], 20 | }) 21 | export class AuthModule {} 22 | -------------------------------------------------------------------------------- /src/@generated/user/user-order-by.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class UserOrderByInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | userId?: SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | email?: SortOrder; 12 | 13 | @Field(() => SortOrder, { nullable: true }) 14 | name?: SortOrder; 15 | 16 | @Field(() => SortOrder, { nullable: true }) 17 | password?: SortOrder; 18 | 19 | @Field(() => SortOrder, { nullable: true }) 20 | bio?: SortOrder; 21 | 22 | @Field(() => SortOrder, { nullable: true }) 23 | image?: SortOrder; 24 | } 25 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-count-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class CommentCountAggregate { 5 | @Field(() => Int, { nullable: false }) 6 | commentId!: number; 7 | 8 | @Field(() => Int, { nullable: false }) 9 | createdAt!: number; 10 | 11 | @Field(() => Int, { nullable: false }) 12 | updatedAt!: number; 13 | 14 | @Field(() => Int, { nullable: false }) 15 | body!: number; 16 | 17 | @Field(() => Int, { nullable: false }) 18 | authorId!: number; 19 | 20 | @Field(() => Int, { nullable: false }) 21 | articleId!: number; 22 | 23 | @Field(() => Int, { nullable: false }) 24 | _all!: number; 25 | } 26 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-count-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentCountAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | commentId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | createdAt?: true; 10 | 11 | @Field(() => Boolean, { nullable: true }) 12 | updatedAt?: true; 13 | 14 | @Field(() => Boolean, { nullable: true }) 15 | body?: true; 16 | 17 | @Field(() => Boolean, { nullable: true }) 18 | authorId?: true; 19 | 20 | @Field(() => Boolean, { nullable: true }) 21 | articleId?: true; 22 | 23 | @Field(() => Boolean, { nullable: true }) 24 | _all?: true; 25 | } 26 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-scalar-where.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { StringFilter } from '../prisma/string-filter.input'; 4 | 5 | @InputType() 6 | export class TagScalarWhereInput { 7 | @Field(() => [TagScalarWhereInput], { nullable: true }) 8 | AND?: Array; 9 | 10 | @Field(() => [TagScalarWhereInput], { nullable: true }) 11 | OR?: Array; 12 | 13 | @Field(() => [TagScalarWhereInput], { nullable: true }) 14 | NOT?: Array; 15 | 16 | @Field(() => StringFilter, { nullable: true }) 17 | tagId?: StringFilter; 18 | 19 | @Field(() => StringFilter, { nullable: true }) 20 | name?: StringFilter; 21 | } 22 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-order-by.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class CommentOrderByInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | commentId?: SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | createdAt?: SortOrder; 12 | 13 | @Field(() => SortOrder, { nullable: true }) 14 | updatedAt?: SortOrder; 15 | 16 | @Field(() => SortOrder, { nullable: true }) 17 | body?: SortOrder; 18 | 19 | @Field(() => SortOrder, { nullable: true }) 20 | authorId?: SortOrder; 21 | 22 | @Field(() => SortOrder, { nullable: true }) 23 | articleId?: SortOrder; 24 | } 25 | -------------------------------------------------------------------------------- /src/auth/session.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable, Scope } from '@nestjs/common'; 2 | import { REQUEST } from '@nestjs/core'; 3 | 4 | import { GraphQLContext } from '../types'; 5 | import { PassportUserFields } from './types'; 6 | 7 | /** 8 | * TODO: Problem with this Scope.REQUEST every dependant service 9 | * will be created on every request. 10 | */ 11 | @Injectable({ scope: Scope.REQUEST }) 12 | export class SessionService { 13 | constructor(@Inject(REQUEST) private readonly context: GraphQLContext) {} 14 | 15 | currentUser(): PassportUserFields | undefined { 16 | return this.context.req?.user; 17 | } 18 | 19 | currentUserId(): string | undefined { 20 | return this.context.req?.user?.id; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/api/api.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { GraphQLClient } from 'graphql-request'; 3 | 4 | import { AppEnvironment } from '../app.environment'; 5 | import { ApiController } from './api.controller'; 6 | import { ApiService } from './api.service'; 7 | 8 | @Module({ 9 | imports: [], 10 | controllers: [ApiController], 11 | providers: [ 12 | ApiService, 13 | { 14 | provide: 'GraphQLClient', 15 | inject: [AppEnvironment], 16 | useFactory: (appEnvironment: AppEnvironment) => { 17 | const url = appEnvironment.graphqlEndpoint; 18 | return new GraphQLClient(url); 19 | }, 20 | }, 21 | ], 22 | }) 23 | export class ApiModule {} 24 | -------------------------------------------------------------------------------- /src/@generated/prisma/int-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType, Int } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class IntFilter { 5 | @Field(() => Int, { nullable: true }) 6 | equals?: number; 7 | 8 | @Field(() => [Int], { nullable: true }) 9 | in?: Array; 10 | 11 | @Field(() => [Int], { nullable: true }) 12 | notIn?: Array; 13 | 14 | @Field(() => Int, { nullable: true }) 15 | lt?: number; 16 | 17 | @Field(() => Int, { nullable: true }) 18 | lte?: number; 19 | 20 | @Field(() => Int, { nullable: true }) 21 | gt?: number; 22 | 23 | @Field(() => Int, { nullable: true }) 24 | gte?: number; 25 | 26 | @Field(() => IntFilter, { nullable: true }) 27 | not?: IntFilter; 28 | } 29 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-update-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleUpdateOneWithoutCommentsInput } from '../article/article-update-one-without-comments.input'; 4 | 5 | @InputType() 6 | export class CommentUpdateWithoutAuthorInput { 7 | @Field(() => String, { nullable: true }) 8 | commentId?: string; 9 | 10 | @Field(() => Date, { nullable: true }) 11 | createdAt?: Date | string; 12 | 13 | @Field(() => Date, { nullable: true }) 14 | updatedAt?: Date | string; 15 | 16 | @Field(() => String, { nullable: true }) 17 | body?: string; 18 | 19 | @Field(() => ArticleUpdateOneWithoutCommentsInput, { nullable: true }) 20 | article?: ArticleUpdateOneWithoutCommentsInput; 21 | } 22 | -------------------------------------------------------------------------------- /test/jest-e2e.config.js: -------------------------------------------------------------------------------- 1 | const { pathsToModuleNameMapper } = require('ts-jest'); 2 | const { compilerOptions } = require('../tsconfig'); 3 | 4 | module.exports = { 5 | moduleFileExtensions: ['js', 'json', 'ts'], 6 | rootDir: '..', 7 | testEnvironment: 'node', 8 | // testRegex: '.(e2e-spec.ts|spec.ts)$', 9 | testMatch: ['/test/*.spec.ts'], 10 | transform: { 11 | '^.+\\.(t|j)s$': 'ts-jest', 12 | }, 13 | moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { 14 | prefix: '/', 15 | }), 16 | globals: { 17 | 'ts-jest': { 18 | diagnostics: false, 19 | isolatedModules: true, 20 | }, 21 | }, 22 | modulePathIgnorePatterns: ['/src/app_modules'], 23 | }; 24 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-create-without-article.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateNestedOneWithoutCommentsInput } from '../user/user-create-nested-one-without-comments.input'; 4 | 5 | @InputType() 6 | export class CommentCreateWithoutArticleInput { 7 | @Field(() => String, { nullable: true }) 8 | commentId?: string; 9 | 10 | @Field(() => Date, { nullable: true }) 11 | createdAt?: Date | string; 12 | 13 | @Field(() => Date, { nullable: true }) 14 | updatedAt?: Date | string; 15 | 16 | @Field(() => String, { nullable: false }) 17 | body!: string; 18 | 19 | @Field(() => UserCreateNestedOneWithoutCommentsInput, { nullable: false }) 20 | author!: UserCreateNestedOneWithoutCommentsInput; 21 | } 22 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-update-without-article.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserUpdateOneRequiredWithoutCommentsInput } from '../user/user-update-one-required-without-comments.input'; 4 | 5 | @InputType() 6 | export class CommentUpdateWithoutArticleInput { 7 | @Field(() => String, { nullable: true }) 8 | commentId?: string; 9 | 10 | @Field(() => Date, { nullable: true }) 11 | createdAt?: Date | string; 12 | 13 | @Field(() => Date, { nullable: true }) 14 | updatedAt?: Date | string; 15 | 16 | @Field(() => String, { nullable: true }) 17 | body?: string; 18 | 19 | @Field(() => UserUpdateOneRequiredWithoutCommentsInput, { nullable: true }) 20 | author?: UserUpdateOneRequiredWithoutCommentsInput; 21 | } 22 | -------------------------------------------------------------------------------- /src/@generated/prisma/float-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, Float, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class FloatFilter { 5 | @Field(() => Float, { nullable: true }) 6 | equals?: number; 7 | 8 | @Field(() => [Float], { nullable: true }) 9 | in?: Array; 10 | 11 | @Field(() => [Float], { nullable: true }) 12 | notIn?: Array; 13 | 14 | @Field(() => Float, { nullable: true }) 15 | lt?: number; 16 | 17 | @Field(() => Float, { nullable: true }) 18 | lte?: number; 19 | 20 | @Field(() => Float, { nullable: true }) 21 | gt?: number; 22 | 23 | @Field(() => Float, { nullable: true }) 24 | gte?: number; 25 | 26 | @Field(() => FloatFilter, { nullable: true }) 27 | not?: FloatFilter; 28 | } 29 | -------------------------------------------------------------------------------- /src/app_modules/nestjs-graphql-fields/index.ts: -------------------------------------------------------------------------------- 1 | import { createParamDecorator, ExecutionContext } from '@nestjs/common'; 2 | import { GqlExecutionContext } from '@nestjs/graphql'; 3 | import graphqlFields from 'graphql-fields'; 4 | import { DeepPartial, PlainObject } from 'simplytyped'; 5 | 6 | export const graphqlFieldsImpl = (data, [root, args, context, info]) => { 7 | return graphqlFields(info); 8 | }; 9 | 10 | export const GraphqlFields = createParamDecorator( 11 | (data: unknown, context: ExecutionContext) => { 12 | const graphqlContext = GqlExecutionContext.create(context); 13 | const info = graphqlContext.getInfo(); 14 | return graphqlFields(info); 15 | }, 16 | ); 17 | 18 | export type GraphqlFieldsParameter = DeepPartial>; 19 | -------------------------------------------------------------------------------- /src/user/models/user-create.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | import { IsEmail, IsNotEmpty, MinLength, Validate } from 'class-validator'; 3 | 4 | import { UserExistsValidator } from '../validators/user-exists.validator'; 5 | 6 | /** 7 | * Input type for create user mutation. 8 | */ 9 | @InputType() 10 | export class UserCreateInput { 11 | @IsNotEmpty() 12 | @IsEmail() 13 | @Field(() => String, { nullable: false }) 14 | @Validate(UserExistsValidator) 15 | email: string; 16 | 17 | @IsNotEmpty() 18 | @MinLength(3) 19 | @Field(() => String, { nullable: false }) 20 | @Validate(UserExistsValidator) 21 | name: string; 22 | 23 | @IsNotEmpty() 24 | @Field(() => String, { nullable: false }) 25 | password: string; 26 | } 27 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-create-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateNestedOneWithoutCommentsInput } from '../article/article-create-nested-one-without-comments.input'; 4 | 5 | @InputType() 6 | export class CommentCreateWithoutAuthorInput { 7 | @Field(() => String, { nullable: true }) 8 | commentId?: string; 9 | 10 | @Field(() => Date, { nullable: true }) 11 | createdAt?: Date | string; 12 | 13 | @Field(() => Date, { nullable: true }) 14 | updatedAt?: Date | string; 15 | 16 | @Field(() => String, { nullable: false }) 17 | body!: string; 18 | 19 | @Field(() => ArticleCreateNestedOneWithoutCommentsInput, { nullable: true }) 20 | article?: ArticleCreateNestedOneWithoutCommentsInput; 21 | } 22 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-group-by.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | import { TagCountAggregate } from './tag-count-aggregate.output'; 4 | import { TagMaxAggregate } from './tag-max-aggregate.output'; 5 | import { TagMinAggregate } from './tag-min-aggregate.output'; 6 | 7 | @ObjectType() 8 | export class TagGroupBy { 9 | @Field(() => String, { nullable: false }) 10 | tagId!: string; 11 | 12 | @Field(() => String, { nullable: false }) 13 | name!: string; 14 | 15 | @Field(() => TagCountAggregate, { nullable: true }) 16 | _count?: TagCountAggregate; 17 | 18 | @Field(() => TagMinAggregate, { nullable: true }) 19 | _min?: TagMinAggregate; 20 | 21 | @Field(() => TagMaxAggregate, { nullable: true }) 22 | _max?: TagMaxAggregate; 23 | } 24 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-upsert-with-where-unique-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { TagCreateWithoutArticlesInput } from './tag-create-without-articles.input'; 4 | import { TagUpdateWithoutArticlesInput } from './tag-update-without-articles.input'; 5 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 6 | 7 | @InputType() 8 | export class TagUpsertWithWhereUniqueWithoutArticlesInput { 9 | @Field(() => TagWhereUniqueInput, { nullable: false }) 10 | where!: TagWhereUniqueInput; 11 | 12 | @Field(() => TagUpdateWithoutArticlesInput, { nullable: false }) 13 | update!: TagUpdateWithoutArticlesInput; 14 | 15 | @Field(() => TagCreateWithoutArticlesInput, { nullable: false }) 16 | create!: TagCreateWithoutArticlesInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/user/user.repository.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { User } from '@prisma/client'; 3 | import { PrismaRepository } from 'app_modules/prisma'; 4 | 5 | /** 6 | * Repository to work with database. 7 | */ 8 | @Injectable() 9 | export class UserRepository { 10 | update = this.prisma.user.update; 11 | findUnique = this.prisma.user.findUnique; 12 | findMany = this.prisma.user.findMany; 13 | create = this.prisma.user.create; 14 | count = this.prisma.user.count; 15 | 16 | constructor(private readonly prisma: PrismaRepository) {} 17 | 18 | async randomUser() { 19 | const [result] = await this.prisma.$queryRaw< 20 | User[] 21 | >/* SQL */ `SELECT * FROM "User" ORDER BY random() LIMIT 1`; 22 | return result; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/@generated/user/user-max-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class UserMaxOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | userId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | email?: keyof typeof SortOrder; 12 | 13 | @Field(() => SortOrder, { nullable: true }) 14 | name?: keyof typeof SortOrder; 15 | 16 | @Field(() => SortOrder, { nullable: true }) 17 | password?: keyof typeof SortOrder; 18 | 19 | @Field(() => SortOrder, { nullable: true }) 20 | bio?: keyof typeof SortOrder; 21 | 22 | @Field(() => SortOrder, { nullable: true }) 23 | image?: keyof typeof SortOrder; 24 | } 25 | -------------------------------------------------------------------------------- /src/@generated/user/user-min-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class UserMinOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | userId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | email?: keyof typeof SortOrder; 12 | 13 | @Field(() => SortOrder, { nullable: true }) 14 | name?: keyof typeof SortOrder; 15 | 16 | @Field(() => SortOrder, { nullable: true }) 17 | password?: keyof typeof SortOrder; 18 | 19 | @Field(() => SortOrder, { nullable: true }) 20 | bio?: keyof typeof SortOrder; 21 | 22 | @Field(() => SortOrder, { nullable: true }) 23 | image?: keyof typeof SortOrder; 24 | } 25 | -------------------------------------------------------------------------------- /src/@generated/article/article-upsert-with-where-unique-without-tags.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateWithoutTagsInput } from './article-create-without-tags.input'; 4 | import { ArticleUpdateWithoutTagsInput } from './article-update-without-tags.input'; 5 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 6 | 7 | @InputType() 8 | export class ArticleUpsertWithWhereUniqueWithoutTagsInput { 9 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 10 | where!: ArticleWhereUniqueInput; 11 | 12 | @Field(() => ArticleUpdateWithoutTagsInput, { nullable: false }) 13 | update!: ArticleUpdateWithoutTagsInput; 14 | 15 | @Field(() => ArticleCreateWithoutTagsInput, { nullable: false }) 16 | create!: ArticleCreateWithoutTagsInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/user/user-count-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class UserCountOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | userId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | email?: keyof typeof SortOrder; 12 | 13 | @Field(() => SortOrder, { nullable: true }) 14 | name?: keyof typeof SortOrder; 15 | 16 | @Field(() => SortOrder, { nullable: true }) 17 | password?: keyof typeof SortOrder; 18 | 19 | @Field(() => SortOrder, { nullable: true }) 20 | bio?: keyof typeof SortOrder; 21 | 22 | @Field(() => SortOrder, { nullable: true }) 23 | image?: keyof typeof SortOrder; 24 | } 25 | -------------------------------------------------------------------------------- /src/@generated/user/user-upsert-with-where-unique-without-followers.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateWithoutFollowersInput } from './user-create-without-followers.input'; 4 | import { UserUpdateWithoutFollowersInput } from './user-update-without-followers.input'; 5 | import { UserWhereUniqueInput } from './user-where-unique.input'; 6 | 7 | @InputType() 8 | export class UserUpsertWithWhereUniqueWithoutFollowersInput { 9 | @Field(() => UserWhereUniqueInput, { nullable: false }) 10 | where!: UserWhereUniqueInput; 11 | 12 | @Field(() => UserUpdateWithoutFollowersInput, { nullable: false }) 13 | update!: UserUpdateWithoutFollowersInput; 14 | 15 | @Field(() => UserCreateWithoutFollowersInput, { nullable: false }) 16 | create!: UserCreateWithoutFollowersInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/user/user-upsert-with-where-unique-without-following.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateWithoutFollowingInput } from './user-create-without-following.input'; 4 | import { UserUpdateWithoutFollowingInput } from './user-update-without-following.input'; 5 | import { UserWhereUniqueInput } from './user-where-unique.input'; 6 | 7 | @InputType() 8 | export class UserUpsertWithWhereUniqueWithoutFollowingInput { 9 | @Field(() => UserWhereUniqueInput, { nullable: false }) 10 | where!: UserWhereUniqueInput; 11 | 12 | @Field(() => UserUpdateWithoutFollowingInput, { nullable: false }) 13 | update!: UserUpdateWithoutFollowingInput; 14 | 15 | @Field(() => UserCreateWithoutFollowingInput, { nullable: false }) 16 | create!: UserCreateWithoutFollowingInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/article/article-update-many-mutation.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType, Int } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class ArticleUpdateManyMutationInput { 5 | @Field(() => String, { nullable: true }) 6 | articleId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | slug?: string; 10 | 11 | @Field(() => String, { nullable: true }) 12 | title?: string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | description?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | body?: string; 19 | 20 | @Field(() => Date, { nullable: true }) 21 | createdAt?: Date | string; 22 | 23 | @Field(() => Date, { nullable: true }) 24 | updatedAt?: Date | string; 25 | 26 | @Field(() => Int, { nullable: true }) 27 | favoritesCount?: number; 28 | } 29 | -------------------------------------------------------------------------------- /src/@generated/article/article-upsert-with-where-unique-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateWithoutAuthorInput } from './article-create-without-author.input'; 4 | import { ArticleUpdateWithoutAuthorInput } from './article-update-without-author.input'; 5 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 6 | 7 | @InputType() 8 | export class ArticleUpsertWithWhereUniqueWithoutAuthorInput { 9 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 10 | where!: ArticleWhereUniqueInput; 11 | 12 | @Field(() => ArticleUpdateWithoutAuthorInput, { nullable: false }) 13 | update!: ArticleUpdateWithoutAuthorInput; 14 | 15 | @Field(() => ArticleCreateWithoutAuthorInput, { nullable: false }) 16 | create!: ArticleCreateWithoutAuthorInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-max-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class CommentMaxOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | commentId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | createdAt?: keyof typeof SortOrder; 12 | 13 | @Field(() => SortOrder, { nullable: true }) 14 | updatedAt?: keyof typeof SortOrder; 15 | 16 | @Field(() => SortOrder, { nullable: true }) 17 | body?: keyof typeof SortOrder; 18 | 19 | @Field(() => SortOrder, { nullable: true }) 20 | authorId?: keyof typeof SortOrder; 21 | 22 | @Field(() => SortOrder, { nullable: true }) 23 | articleId?: keyof typeof SortOrder; 24 | } 25 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-min-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class CommentMinOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | commentId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | createdAt?: keyof typeof SortOrder; 12 | 13 | @Field(() => SortOrder, { nullable: true }) 14 | updatedAt?: keyof typeof SortOrder; 15 | 16 | @Field(() => SortOrder, { nullable: true }) 17 | body?: keyof typeof SortOrder; 18 | 19 | @Field(() => SortOrder, { nullable: true }) 20 | authorId?: keyof typeof SortOrder; 21 | 22 | @Field(() => SortOrder, { nullable: true }) 23 | articleId?: keyof typeof SortOrder; 24 | } 25 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-upsert-with-where-unique-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { CommentCreateWithoutAuthorInput } from './comment-create-without-author.input'; 4 | import { CommentUpdateWithoutAuthorInput } from './comment-update-without-author.input'; 5 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 6 | 7 | @InputType() 8 | export class CommentUpsertWithWhereUniqueWithoutAuthorInput { 9 | @Field(() => CommentWhereUniqueInput, { nullable: false }) 10 | where!: CommentWhereUniqueInput; 11 | 12 | @Field(() => CommentUpdateWithoutAuthorInput, { nullable: false }) 13 | update!: CommentUpdateWithoutAuthorInput; 14 | 15 | @Field(() => CommentCreateWithoutAuthorInput, { nullable: false }) 16 | create!: CommentCreateWithoutAuthorInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/prisma/date-time-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class DateTimeFilter { 5 | @Field(() => Date, { nullable: true }) 6 | equals?: Date | string; 7 | 8 | @Field(() => [Date], { nullable: true }) 9 | in?: Array | Array; 10 | 11 | @Field(() => [Date], { nullable: true }) 12 | notIn?: Array | Array; 13 | 14 | @Field(() => Date, { nullable: true }) 15 | lt?: Date | string; 16 | 17 | @Field(() => Date, { nullable: true }) 18 | lte?: Date | string; 19 | 20 | @Field(() => Date, { nullable: true }) 21 | gt?: Date | string; 22 | 23 | @Field(() => Date, { nullable: true }) 24 | gte?: Date | string; 25 | 26 | @Field(() => DateTimeFilter, { nullable: true }) 27 | not?: DateTimeFilter; 28 | } 29 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-count-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class CommentCountOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | commentId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | createdAt?: keyof typeof SortOrder; 12 | 13 | @Field(() => SortOrder, { nullable: true }) 14 | updatedAt?: keyof typeof SortOrder; 15 | 16 | @Field(() => SortOrder, { nullable: true }) 17 | body?: keyof typeof SortOrder; 18 | 19 | @Field(() => SortOrder, { nullable: true }) 20 | authorId?: keyof typeof SortOrder; 21 | 22 | @Field(() => SortOrder, { nullable: true }) 23 | articleId?: keyof typeof SortOrder; 24 | } 25 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-upsert-with-where-unique-without-article.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { CommentCreateWithoutArticleInput } from './comment-create-without-article.input'; 4 | import { CommentUpdateWithoutArticleInput } from './comment-update-without-article.input'; 5 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 6 | 7 | @InputType() 8 | export class CommentUpsertWithWhereUniqueWithoutArticleInput { 9 | @Field(() => CommentWhereUniqueInput, { nullable: false }) 10 | where!: CommentWhereUniqueInput; 11 | 12 | @Field(() => CommentUpdateWithoutArticleInput, { nullable: false }) 13 | update!: CommentUpdateWithoutArticleInput; 14 | 15 | @Field(() => CommentCreateWithoutArticleInput, { nullable: false }) 16 | create!: CommentCreateWithoutArticleInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/user/user-create-nested-one-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateOrConnectWithoutArticlesInput } from './user-create-or-connect-without-articles.input'; 4 | import { UserCreateWithoutArticlesInput } from './user-create-without-articles.input'; 5 | import { UserWhereUniqueInput } from './user-where-unique.input'; 6 | 7 | @InputType() 8 | export class UserCreateNestedOneWithoutArticlesInput { 9 | @Field(() => UserCreateWithoutArticlesInput, { nullable: true }) 10 | create?: UserCreateWithoutArticlesInput; 11 | 12 | @Field(() => UserCreateOrConnectWithoutArticlesInput, { nullable: true }) 13 | connectOrCreate?: UserCreateOrConnectWithoutArticlesInput; 14 | 15 | @Field(() => UserWhereUniqueInput, { nullable: true }) 16 | connect?: UserWhereUniqueInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/user/user-create-nested-one-without-comments.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateOrConnectWithoutCommentsInput } from './user-create-or-connect-without-comments.input'; 4 | import { UserCreateWithoutCommentsInput } from './user-create-without-comments.input'; 5 | import { UserWhereUniqueInput } from './user-where-unique.input'; 6 | 7 | @InputType() 8 | export class UserCreateNestedOneWithoutCommentsInput { 9 | @Field(() => UserCreateWithoutCommentsInput, { nullable: true }) 10 | create?: UserCreateWithoutCommentsInput; 11 | 12 | @Field(() => UserCreateOrConnectWithoutCommentsInput, { nullable: true }) 13 | connectOrCreate?: UserCreateOrConnectWithoutCommentsInput; 14 | 15 | @Field(() => UserWhereUniqueInput, { nullable: true }) 16 | connect?: UserWhereUniqueInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/article/article.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { PrismaModule } from 'app_modules/prisma'; 3 | 4 | import { TagModule } from '../tag/tag.module'; 5 | import { UserModule } from '../user/user.module'; 6 | import { ArticleRepository } from './article.repository'; 7 | import { ArticleResolver } from './article.resolver'; 8 | import { ArticleService } from './article.service'; 9 | import { ArticleSelectService } from './article-select.service'; 10 | import { SlugService } from './slug/slug.service'; 11 | 12 | @Module({ 13 | imports: [PrismaModule, TagModule, UserModule], 14 | providers: [ 15 | ArticleResolver, 16 | ArticleService, 17 | SlugService, 18 | ArticleSelectService, 19 | ArticleRepository, 20 | ], 21 | exports: [ArticleService], 22 | }) 23 | export class ArticleModule {} 24 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-create-nested-many-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { TagCreateOrConnectWithoutArticlesInput } from './tag-create-or-connect-without-articles.input'; 4 | import { TagCreateWithoutArticlesInput } from './tag-create-without-articles.input'; 5 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 6 | 7 | @InputType() 8 | export class TagCreateNestedManyWithoutArticlesInput { 9 | @Field(() => [TagCreateWithoutArticlesInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [TagCreateOrConnectWithoutArticlesInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [TagWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/article/article-unchecked-update-many-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType, Int } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class ArticleUncheckedUpdateManyWithoutArticlesInput { 5 | @Field(() => String, { nullable: true }) 6 | articleId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | slug?: string; 10 | 11 | @Field(() => String, { nullable: true }) 12 | title?: string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | description?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | body?: string; 19 | 20 | @Field(() => Date, { nullable: true }) 21 | createdAt?: Date | string; 22 | 23 | @Field(() => Date, { nullable: true }) 24 | updatedAt?: Date | string; 25 | 26 | @Field(() => Int, { nullable: true }) 27 | favoritesCount?: number; 28 | } 29 | -------------------------------------------------------------------------------- /src/user/models/user-update.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | /** 4 | * Update user input type. 5 | */ 6 | @InputType() 7 | export class UserUpdateInput { 8 | @Field(() => String, { 9 | nullable: true, 10 | description: undefined, 11 | }) 12 | email?: string; 13 | 14 | @Field(() => String, { 15 | nullable: true, 16 | description: undefined, 17 | }) 18 | name?: string; 19 | 20 | @Field(() => String, { 21 | nullable: true, 22 | description: undefined, 23 | }) 24 | password?: string; 25 | 26 | @Field(() => String, { 27 | nullable: true, 28 | description: undefined, 29 | }) 30 | bio?: string; 31 | 32 | @Field(() => String, { 33 | nullable: true, 34 | description: undefined, 35 | }) 36 | image?: string; 37 | } 38 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-unchecked-create-nested-many-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { TagCreateOrConnectWithoutArticlesInput } from './tag-create-or-connect-without-articles.input'; 4 | import { TagCreateWithoutArticlesInput } from './tag-create-without-articles.input'; 5 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 6 | 7 | @InputType() 8 | export class TagUncheckedCreateNestedManyWithoutArticlesInput { 9 | @Field(() => [TagCreateWithoutArticlesInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [TagCreateOrConnectWithoutArticlesInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [TagWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/article/article-create-nested-many-without-tags.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateOrConnectWithoutTagsInput } from './article-create-or-connect-without-tags.input'; 4 | import { ArticleCreateWithoutTagsInput } from './article-create-without-tags.input'; 5 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 6 | 7 | @InputType() 8 | export class ArticleCreateNestedManyWithoutTagsInput { 9 | @Field(() => [ArticleCreateWithoutTagsInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [ArticleCreateOrConnectWithoutTagsInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [ArticleWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/app_modules/current-user-decorator/index.ts: -------------------------------------------------------------------------------- 1 | import { createParamDecorator, ExecutionContext } from '@nestjs/common'; 2 | import { GqlContextType } from '@nestjs/graphql'; 3 | 4 | /** 5 | * Extract request.user property (which is written by passport). 6 | */ 7 | export const CurrentUser = createParamDecorator( 8 | (_: unknown, context: ExecutionContext) => { 9 | let request; 10 | if (context.getType() === 'http') { 11 | request = context.switchToHttp().getRequest(); 12 | } else if (context.getType() === 'graphql') { 13 | // GraphQL context defined in src/app.module.ts@graphqlModuleFactory 14 | request = context.getArgByIndex(2).req; 15 | } else if (context.getType() === 'rpc') { 16 | throw new Error('Not implemented'); 17 | } 18 | 19 | return request?.user; 20 | }, 21 | ); 22 | -------------------------------------------------------------------------------- /src/@generated/article/article-max-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class ArticleMaxAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | articleId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | slug?: true; 10 | 11 | @Field(() => Boolean, { nullable: true }) 12 | title?: true; 13 | 14 | @Field(() => Boolean, { nullable: true }) 15 | description?: true; 16 | 17 | @Field(() => Boolean, { nullable: true }) 18 | body?: true; 19 | 20 | @Field(() => Boolean, { nullable: true }) 21 | createdAt?: true; 22 | 23 | @Field(() => Boolean, { nullable: true }) 24 | updatedAt?: true; 25 | 26 | @Field(() => Boolean, { nullable: true }) 27 | favoritesCount?: true; 28 | 29 | @Field(() => Boolean, { nullable: true }) 30 | authorId?: true; 31 | } 32 | -------------------------------------------------------------------------------- /src/@generated/article/article-min-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class ArticleMinAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | articleId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | slug?: true; 10 | 11 | @Field(() => Boolean, { nullable: true }) 12 | title?: true; 13 | 14 | @Field(() => Boolean, { nullable: true }) 15 | description?: true; 16 | 17 | @Field(() => Boolean, { nullable: true }) 18 | body?: true; 19 | 20 | @Field(() => Boolean, { nullable: true }) 21 | createdAt?: true; 22 | 23 | @Field(() => Boolean, { nullable: true }) 24 | updatedAt?: true; 25 | 26 | @Field(() => Boolean, { nullable: true }) 27 | favoritesCount?: true; 28 | 29 | @Field(() => Boolean, { nullable: true }) 30 | authorId?: true; 31 | } 32 | -------------------------------------------------------------------------------- /src/@generated/user/user-create-nested-many-without-followers.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateOrConnectWithoutFollowersInput } from './user-create-or-connect-without-followers.input'; 4 | import { UserCreateWithoutFollowersInput } from './user-create-without-followers.input'; 5 | import { UserWhereUniqueInput } from './user-where-unique.input'; 6 | 7 | @InputType() 8 | export class UserCreateNestedManyWithoutFollowersInput { 9 | @Field(() => [UserCreateWithoutFollowersInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [UserCreateOrConnectWithoutFollowersInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [UserWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/user/user-create-nested-many-without-following.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateOrConnectWithoutFollowingInput } from './user-create-or-connect-without-following.input'; 4 | import { UserCreateWithoutFollowingInput } from './user-create-without-following.input'; 5 | import { UserWhereUniqueInput } from './user-where-unique.input'; 6 | 7 | @InputType() 8 | export class UserCreateNestedManyWithoutFollowingInput { 9 | @Field(() => [UserCreateWithoutFollowingInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [UserCreateOrConnectWithoutFollowingInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [UserWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/article/article-create-nested-one-without-comments.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateOrConnectWithoutCommentsInput } from './article-create-or-connect-without-comments.input'; 4 | import { ArticleCreateWithoutCommentsInput } from './article-create-without-comments.input'; 5 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 6 | 7 | @InputType() 8 | export class ArticleCreateNestedOneWithoutCommentsInput { 9 | @Field(() => ArticleCreateWithoutCommentsInput, { nullable: true }) 10 | create?: ArticleCreateWithoutCommentsInput; 11 | 12 | @Field(() => ArticleCreateOrConnectWithoutCommentsInput, { nullable: true }) 13 | connectOrCreate?: ArticleCreateOrConnectWithoutCommentsInput; 14 | 15 | @Field(() => ArticleWhereUniqueInput, { nullable: true }) 16 | connect?: ArticleWhereUniqueInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/article/article-upsert-with-where-unique-without-favorited-by.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateWithoutFavoritedByInput } from './article-create-without-favorited-by.input'; 4 | import { ArticleUpdateWithoutFavoritedByInput } from './article-update-without-favorited-by.input'; 5 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 6 | 7 | @InputType() 8 | export class ArticleUpsertWithWhereUniqueWithoutFavoritedByInput { 9 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 10 | where!: ArticleWhereUniqueInput; 11 | 12 | @Field(() => ArticleUpdateWithoutFavoritedByInput, { nullable: false }) 13 | update!: ArticleUpdateWithoutFavoritedByInput; 14 | 15 | @Field(() => ArticleCreateWithoutFavoritedByInput, { nullable: false }) 16 | create!: ArticleCreateWithoutFavoritedByInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-where.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleListRelationFilter } from '../article/article-list-relation-filter.input'; 4 | import { StringFilter } from '../prisma/string-filter.input'; 5 | 6 | @InputType() 7 | export class TagWhereInput { 8 | @Field(() => [TagWhereInput], { nullable: true }) 9 | AND?: Array; 10 | 11 | @Field(() => [TagWhereInput], { nullable: true }) 12 | OR?: Array; 13 | 14 | @Field(() => [TagWhereInput], { nullable: true }) 15 | NOT?: Array; 16 | 17 | @Field(() => StringFilter, { nullable: true }) 18 | tagId?: StringFilter; 19 | 20 | @Field(() => StringFilter, { nullable: true }) 21 | name?: StringFilter; 22 | 23 | @Field(() => ArticleListRelationFilter, { nullable: true }) 24 | articles?: ArticleListRelationFilter; 25 | } 26 | -------------------------------------------------------------------------------- /src/@generated/article/article-unchecked-create-nested-many-without-tags.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateOrConnectWithoutTagsInput } from './article-create-or-connect-without-tags.input'; 4 | import { ArticleCreateWithoutTagsInput } from './article-create-without-tags.input'; 5 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 6 | 7 | @InputType() 8 | export class ArticleUncheckedCreateNestedManyWithoutTagsInput { 9 | @Field(() => [ArticleCreateWithoutTagsInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [ArticleCreateOrConnectWithoutTagsInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [ArticleWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/comment/comment.model.ts: -------------------------------------------------------------------------------- 1 | import { Field, ID, ObjectType } from '@nestjs/graphql'; 2 | 3 | import { Article } from '../article/article.model'; 4 | import { User } from '../user/user.model'; 5 | 6 | @ObjectType() 7 | export class Comment { 8 | @Field(() => ID, { nullable: false }) 9 | commentId!: string; 10 | 11 | @Field(() => Date, { nullable: false }) 12 | createdAt!: Date; 13 | 14 | @Field(() => Date, { nullable: false }) 15 | updatedAt!: Date; 16 | 17 | @Field(() => String, { nullable: false }) 18 | body!: string; 19 | 20 | @Field(() => User, { nullable: false }) 21 | author?: User; 22 | 23 | @Field(() => String, { nullable: false }) 24 | authorId!: string; 25 | 26 | @Field(() => Article, { nullable: true }) 27 | article?: Article | null; 28 | 29 | @Field(() => String, { nullable: true }) 30 | articleId!: string | null; 31 | } 32 | -------------------------------------------------------------------------------- /src/@generated/user/user-upsert-with-where-unique-without-favorite-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateWithoutFavoriteArticlesInput } from './user-create-without-favorite-articles.input'; 4 | import { UserUpdateWithoutFavoriteArticlesInput } from './user-update-without-favorite-articles.input'; 5 | import { UserWhereUniqueInput } from './user-where-unique.input'; 6 | 7 | @InputType() 8 | export class UserUpsertWithWhereUniqueWithoutFavoriteArticlesInput { 9 | @Field(() => UserWhereUniqueInput, { nullable: false }) 10 | where!: UserWhereUniqueInput; 11 | 12 | @Field(() => UserUpdateWithoutFavoriteArticlesInput, { nullable: false }) 13 | update!: UserUpdateWithoutFavoriteArticlesInput; 14 | 15 | @Field(() => UserCreateWithoutFavoriteArticlesInput, { nullable: false }) 16 | create!: UserCreateWithoutFavoriteArticlesInput; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/article/article-create-nested-many-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateOrConnectWithoutAuthorInput } from './article-create-or-connect-without-author.input'; 4 | import { ArticleCreateWithoutAuthorInput } from './article-create-without-author.input'; 5 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 6 | 7 | @InputType() 8 | export class ArticleCreateNestedManyWithoutAuthorInput { 9 | @Field(() => [ArticleCreateWithoutAuthorInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [ArticleCreateOrConnectWithoutAuthorInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [ArticleWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/article/article-max-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class ArticleMaxAggregate { 5 | @Field(() => String, { nullable: true }) 6 | articleId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | slug?: string; 10 | 11 | @Field(() => String, { nullable: true }) 12 | title?: string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | description?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | body?: string; 19 | 20 | @Field(() => Date, { nullable: true }) 21 | createdAt?: Date | string; 22 | 23 | @Field(() => Date, { nullable: true }) 24 | updatedAt?: Date | string; 25 | 26 | @Field(() => Int, { nullable: true }) 27 | favoritesCount?: number; 28 | 29 | @Field(() => String, { nullable: true }) 30 | authorId?: string; 31 | } 32 | -------------------------------------------------------------------------------- /src/@generated/article/article-min-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class ArticleMinAggregate { 5 | @Field(() => String, { nullable: true }) 6 | articleId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | slug?: string; 10 | 11 | @Field(() => String, { nullable: true }) 12 | title?: string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | description?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | body?: string; 19 | 20 | @Field(() => Date, { nullable: true }) 21 | createdAt?: Date | string; 22 | 23 | @Field(() => Date, { nullable: true }) 24 | updatedAt?: Date | string; 25 | 26 | @Field(() => Int, { nullable: true }) 27 | favoritesCount?: number; 28 | 29 | @Field(() => String, { nullable: true }) 30 | authorId?: string; 31 | } 32 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-create-nested-many-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { CommentCreateOrConnectWithoutAuthorInput } from './comment-create-or-connect-without-author.input'; 4 | import { CommentCreateWithoutAuthorInput } from './comment-create-without-author.input'; 5 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 6 | 7 | @InputType() 8 | export class CommentCreateNestedManyWithoutAuthorInput { 9 | @Field(() => [CommentCreateWithoutAuthorInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [CommentCreateOrConnectWithoutAuthorInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [CommentWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/user/user-unchecked-create-nested-many-without-followers.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateOrConnectWithoutFollowersInput } from './user-create-or-connect-without-followers.input'; 4 | import { UserCreateWithoutFollowersInput } from './user-create-without-followers.input'; 5 | import { UserWhereUniqueInput } from './user-where-unique.input'; 6 | 7 | @InputType() 8 | export class UserUncheckedCreateNestedManyWithoutFollowersInput { 9 | @Field(() => [UserCreateWithoutFollowersInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [UserCreateOrConnectWithoutFollowersInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [UserWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/user/user-unchecked-create-nested-many-without-following.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateOrConnectWithoutFollowingInput } from './user-create-or-connect-without-following.input'; 4 | import { UserCreateWithoutFollowingInput } from './user-create-without-following.input'; 5 | import { UserWhereUniqueInput } from './user-where-unique.input'; 6 | 7 | @InputType() 8 | export class UserUncheckedCreateNestedManyWithoutFollowingInput { 9 | @Field(() => [UserCreateWithoutFollowingInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [UserCreateOrConnectWithoutFollowingInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [UserWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-create-nested-many-without-article.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { CommentCreateOrConnectWithoutArticleInput } from './comment-create-or-connect-without-article.input'; 4 | import { CommentCreateWithoutArticleInput } from './comment-create-without-article.input'; 5 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 6 | 7 | @InputType() 8 | export class CommentCreateNestedManyWithoutArticleInput { 9 | @Field(() => [CommentCreateWithoutArticleInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [CommentCreateOrConnectWithoutArticleInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [CommentWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/article/models/article-create.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | import { 3 | ArrayUnique, 4 | IsNotEmpty, 5 | IsOptional, 6 | IsString, 7 | MaxLength, 8 | MinLength, 9 | } from 'class-validator'; 10 | 11 | /** 12 | * Create article input object type. 13 | */ 14 | @InputType() 15 | export class ArticleCreateInput { 16 | @IsNotEmpty() 17 | @Field(() => String, { nullable: false }) 18 | title: string; 19 | 20 | @IsNotEmpty() 21 | @Field(() => String, { nullable: false }) 22 | description: string; 23 | 24 | @IsNotEmpty() 25 | @Field(() => String, { nullable: false }) 26 | body: string; 27 | 28 | @IsOptional() 29 | @IsString({ each: true }) 30 | @MinLength(3, { each: true }) 31 | @MaxLength(50, { each: true }) 32 | @ArrayUnique() 33 | @Field(() => [String], { nullable: true }) 34 | tags?: string[]; 35 | } 36 | -------------------------------------------------------------------------------- /src/@generated/article/article-unchecked-create-nested-many-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateOrConnectWithoutAuthorInput } from './article-create-or-connect-without-author.input'; 4 | import { ArticleCreateWithoutAuthorInput } from './article-create-without-author.input'; 5 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 6 | 7 | @InputType() 8 | export class ArticleUncheckedCreateNestedManyWithoutAuthorInput { 9 | @Field(() => [ArticleCreateWithoutAuthorInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [ArticleCreateOrConnectWithoutAuthorInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [ArticleWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-unchecked-create-nested-many-without-author.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { CommentCreateOrConnectWithoutAuthorInput } from './comment-create-or-connect-without-author.input'; 4 | import { CommentCreateWithoutAuthorInput } from './comment-create-without-author.input'; 5 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 6 | 7 | @InputType() 8 | export class CommentUncheckedCreateNestedManyWithoutAuthorInput { 9 | @Field(() => [CommentCreateWithoutAuthorInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [CommentCreateOrConnectWithoutAuthorInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [CommentWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/article/article-unchecked-update-many.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType, Int } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class ArticleUncheckedUpdateManyInput { 5 | @Field(() => String, { nullable: true }) 6 | articleId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | slug?: string; 10 | 11 | @Field(() => String, { nullable: true }) 12 | title?: string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | description?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | body?: string; 19 | 20 | @Field(() => Date, { nullable: true }) 21 | createdAt?: Date | string; 22 | 23 | @Field(() => Date, { nullable: true }) 24 | updatedAt?: Date | string; 25 | 26 | @Field(() => Int, { nullable: true }) 27 | favoritesCount?: number; 28 | 29 | @Field(() => String, { nullable: true }) 30 | authorId?: string; 31 | } 32 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-scalar-where-with-aggregates.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { StringWithAggregatesFilter } from '../prisma/string-with-aggregates-filter.input'; 4 | 5 | @InputType() 6 | export class TagScalarWhereWithAggregatesInput { 7 | @Field(() => [TagScalarWhereWithAggregatesInput], { nullable: true }) 8 | AND?: Array; 9 | 10 | @Field(() => [TagScalarWhereWithAggregatesInput], { nullable: true }) 11 | OR?: Array; 12 | 13 | @Field(() => [TagScalarWhereWithAggregatesInput], { nullable: true }) 14 | NOT?: Array; 15 | 16 | @Field(() => StringWithAggregatesFilter, { nullable: true }) 17 | tagId?: StringWithAggregatesFilter; 18 | 19 | @Field(() => StringWithAggregatesFilter, { nullable: true }) 20 | name?: StringWithAggregatesFilter; 21 | } 22 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-unchecked-create-nested-many-without-article.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { CommentCreateOrConnectWithoutArticleInput } from './comment-create-or-connect-without-article.input'; 4 | import { CommentCreateWithoutArticleInput } from './comment-create-without-article.input'; 5 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 6 | 7 | @InputType() 8 | export class CommentUncheckedCreateNestedManyWithoutArticleInput { 9 | @Field(() => [CommentCreateWithoutArticleInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [CommentCreateOrConnectWithoutArticleInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [CommentWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/article/article-create-nested-many-without-favorited-by.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateOrConnectWithoutFavoritedByInput } from './article-create-or-connect-without-favorited-by.input'; 4 | import { ArticleCreateWithoutFavoritedByInput } from './article-create-without-favorited-by.input'; 5 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 6 | 7 | @InputType() 8 | export class ArticleCreateNestedManyWithoutFavoritedByInput { 9 | @Field(() => [ArticleCreateWithoutFavoritedByInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [ArticleCreateOrConnectWithoutFavoritedByInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [ArticleWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/user/user-create-nested-many-without-favorite-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateOrConnectWithoutFavoriteArticlesInput } from './user-create-or-connect-without-favorite-articles.input'; 4 | import { UserCreateWithoutFavoriteArticlesInput } from './user-create-without-favorite-articles.input'; 5 | import { UserWhereUniqueInput } from './user-where-unique.input'; 6 | 7 | @InputType() 8 | export class UserCreateNestedManyWithoutFavoriteArticlesInput { 9 | @Field(() => [UserCreateWithoutFavoriteArticlesInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [UserCreateOrConnectWithoutFavoriteArticlesInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [UserWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/article/article-count-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class ArticleCountAggregate { 5 | @Field(() => Int, { nullable: false }) 6 | articleId!: number; 7 | 8 | @Field(() => Int, { nullable: false }) 9 | slug!: number; 10 | 11 | @Field(() => Int, { nullable: false }) 12 | title!: number; 13 | 14 | @Field(() => Int, { nullable: false }) 15 | description!: number; 16 | 17 | @Field(() => Int, { nullable: false }) 18 | body!: number; 19 | 20 | @Field(() => Int, { nullable: false }) 21 | createdAt!: number; 22 | 23 | @Field(() => Int, { nullable: false }) 24 | updatedAt!: number; 25 | 26 | @Field(() => Int, { nullable: false }) 27 | favoritesCount!: number; 28 | 29 | @Field(() => Int, { nullable: false }) 30 | authorId!: number; 31 | 32 | @Field(() => Int, { nullable: false }) 33 | _all!: number; 34 | } 35 | -------------------------------------------------------------------------------- /src/@generated/article/article-count-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class ArticleCountAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | articleId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | slug?: true; 10 | 11 | @Field(() => Boolean, { nullable: true }) 12 | title?: true; 13 | 14 | @Field(() => Boolean, { nullable: true }) 15 | description?: true; 16 | 17 | @Field(() => Boolean, { nullable: true }) 18 | body?: true; 19 | 20 | @Field(() => Boolean, { nullable: true }) 21 | createdAt?: true; 22 | 23 | @Field(() => Boolean, { nullable: true }) 24 | updatedAt?: true; 25 | 26 | @Field(() => Boolean, { nullable: true }) 27 | favoritesCount?: true; 28 | 29 | @Field(() => Boolean, { nullable: true }) 30 | authorId?: true; 31 | 32 | @Field(() => Boolean, { nullable: true }) 33 | _all?: true; 34 | } 35 | -------------------------------------------------------------------------------- /src/article/models/article-update.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | import { 3 | ArrayUnique, 4 | IsNotEmpty, 5 | IsOptional, 6 | IsString, 7 | MaxLength, 8 | MinLength, 9 | } from 'class-validator'; 10 | 11 | /** 12 | * Update article input type. 13 | */ 14 | @InputType() 15 | export class ArticleUpdateInput { 16 | @IsOptional() 17 | @IsNotEmpty() 18 | @Field(() => String, { nullable: true }) 19 | title: string; 20 | 21 | @IsOptional() 22 | @IsNotEmpty() 23 | @Field(() => String, { nullable: true }) 24 | description: string; 25 | 26 | @IsOptional() 27 | @IsNotEmpty() 28 | @Field(() => String, { nullable: true }) 29 | body: string; 30 | 31 | @IsOptional() 32 | @IsString({ each: true }) 33 | @MinLength(3, { each: true }) 34 | @MaxLength(50, { each: true }) 35 | @ArrayUnique() 36 | @Field(() => [String], { nullable: true }) 37 | tags?: string[]; 38 | } 39 | -------------------------------------------------------------------------------- /src/@generated/article/article-unchecked-create-nested-many-without-favorited-by.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateOrConnectWithoutFavoritedByInput } from './article-create-or-connect-without-favorited-by.input'; 4 | import { ArticleCreateWithoutFavoritedByInput } from './article-create-without-favorited-by.input'; 5 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 6 | 7 | @InputType() 8 | export class ArticleUncheckedCreateNestedManyWithoutFavoritedByInput { 9 | @Field(() => [ArticleCreateWithoutFavoritedByInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [ArticleCreateOrConnectWithoutFavoritedByInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [ArticleWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /src/@generated/article/article-unchecked-update-many-without-favorite-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType, Int } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class ArticleUncheckedUpdateManyWithoutFavoriteArticlesInput { 5 | @Field(() => String, { nullable: true }) 6 | articleId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | slug?: string; 10 | 11 | @Field(() => String, { nullable: true }) 12 | title?: string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | description?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | body?: string; 19 | 20 | @Field(() => Date, { nullable: true }) 21 | createdAt?: Date | string; 22 | 23 | @Field(() => Date, { nullable: true }) 24 | updatedAt?: Date | string; 25 | 26 | @Field(() => Int, { nullable: true }) 27 | favoritesCount?: number; 28 | 29 | @Field(() => String, { nullable: true }) 30 | authorId?: string; 31 | } 32 | -------------------------------------------------------------------------------- /src/tag/tag.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { Prisma } from '@prisma/client'; 3 | import { InjectRepository, PrismaRepository } from 'app_modules/prisma'; 4 | 5 | /** 6 | * Service for manage tags. 7 | */ 8 | @Injectable() 9 | export class TagService { 10 | constructor( 11 | @InjectRepository('tag') private readonly repository: PrismaRepository['tag'], 12 | ) {} 13 | 14 | /** 15 | * Create tags (if not exists) from array of strings. 16 | */ 17 | async createTags(tags: string[]) { 18 | const upsertOperations = tags.map(name => { 19 | return this.repository.upsert({ 20 | where: { name }, 21 | create: { name }, 22 | update: {}, 23 | }); 24 | }); 25 | return Promise.all(upsertOperations); 26 | } 27 | 28 | findMany(args?: Prisma.TagFindManyArgs) { 29 | return this.repository.findMany(args); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/@generated/user/user-unchecked-create-nested-many-without-favorite-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateOrConnectWithoutFavoriteArticlesInput } from './user-create-or-connect-without-favorite-articles.input'; 4 | import { UserCreateWithoutFavoriteArticlesInput } from './user-create-without-favorite-articles.input'; 5 | import { UserWhereUniqueInput } from './user-where-unique.input'; 6 | 7 | @InputType() 8 | export class UserUncheckedCreateNestedManyWithoutFavoriteArticlesInput { 9 | @Field(() => [UserCreateWithoutFavoriteArticlesInput], { nullable: true }) 10 | create?: Array; 11 | 12 | @Field(() => [UserCreateOrConnectWithoutFavoriteArticlesInput], { nullable: true }) 13 | connectOrCreate?: Array; 14 | 15 | @Field(() => [UserWhereUniqueInput], { nullable: true }) 16 | connect?: Array; 17 | } 18 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3 AS base 2 | RUN apk add --update nodejs 3 | WORKDIR /app 4 | 5 | FROM base AS build 6 | # install tools 7 | RUN apk update \ 8 | && apk add npm jq \ 9 | && rm -rf /var/cache/apk/* 10 | # install dependencies 11 | COPY . . 12 | RUN npm ci 13 | # build sources 14 | RUN npm run build 15 | RUN npm ci --production --ignore-scripts 16 | 17 | FROM base 18 | ENV NODE_ENV production 19 | ENV DATABASE_URL file:data.db 20 | ENV JWT_SECRET_KEY secret_key 21 | COPY --from=build /app/node_modules ./node_modules 22 | COPY --from=build /app/dist ./ 23 | CMD ["node", "/app/src/main.js"] 24 | 25 | # docker build . -t nestjs-graphql-prisma-realworld-example-app 26 | # docker run -it -v "$PWD/data":/data -e DATABASE_URL=file:/data/db.sqlite -p 8080:3000 nestjs-graphql-prisma-realworld-example-app 27 | # docker run -it -p 8080:3000 nestjs-graphql-prisma-realworld-example-app 28 | # curl -i http://localhost:8080/api 29 | # docker run -it nestjs-graphql-prisma-realworld-example-app sh 30 | -------------------------------------------------------------------------------- /src/@generated/article/article-order-by.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class ArticleOrderByInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | articleId?: SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | slug?: SortOrder; 12 | 13 | @Field(() => SortOrder, { nullable: true }) 14 | title?: SortOrder; 15 | 16 | @Field(() => SortOrder, { nullable: true }) 17 | description?: SortOrder; 18 | 19 | @Field(() => SortOrder, { nullable: true }) 20 | body?: SortOrder; 21 | 22 | @Field(() => SortOrder, { nullable: true }) 23 | createdAt?: SortOrder; 24 | 25 | @Field(() => SortOrder, { nullable: true }) 26 | updatedAt?: SortOrder; 27 | 28 | @Field(() => SortOrder, { nullable: true }) 29 | favoritesCount?: SortOrder; 30 | 31 | @Field(() => SortOrder, { nullable: true }) 32 | authorId?: SortOrder; 33 | } 34 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-update.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleUpdateOneWithoutCommentsInput } from '../article/article-update-one-without-comments.input'; 4 | import { UserUpdateOneRequiredWithoutCommentsInput } from '../user/user-update-one-required-without-comments.input'; 5 | 6 | @InputType() 7 | export class CommentUpdateInput { 8 | @Field(() => String, { nullable: true }) 9 | commentId?: string; 10 | 11 | @Field(() => Date, { nullable: true }) 12 | createdAt?: Date | string; 13 | 14 | @Field(() => Date, { nullable: true }) 15 | updatedAt?: Date | string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | body?: string; 19 | 20 | @Field(() => UserUpdateOneRequiredWithoutCommentsInput, { nullable: true }) 21 | author?: UserUpdateOneRequiredWithoutCommentsInput; 22 | 23 | @Field(() => ArticleUpdateOneWithoutCommentsInput, { nullable: true }) 24 | article?: ArticleUpdateOneWithoutCommentsInput; 25 | } 26 | -------------------------------------------------------------------------------- /src/@generated/tag/find-many-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field, Int } from '@nestjs/graphql'; 2 | 3 | import { TagOrderByWithRelationInput } from './tag-order-by-with-relation.input'; 4 | import { TagScalarFieldEnum } from './tag-scalar-field.enum'; 5 | import { TagWhereInput } from './tag-where.input'; 6 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 7 | 8 | @ArgsType() 9 | export class FindManyTagArgs { 10 | @Field(() => TagWhereInput, { nullable: true }) 11 | where?: TagWhereInput; 12 | 13 | @Field(() => [TagOrderByWithRelationInput], { nullable: true }) 14 | orderBy?: Array; 15 | 16 | @Field(() => TagWhereUniqueInput, { nullable: true }) 17 | cursor?: TagWhereUniqueInput; 18 | 19 | @Field(() => Int, { nullable: true }) 20 | take?: number; 21 | 22 | @Field(() => Int, { nullable: true }) 23 | skip?: number; 24 | 25 | @Field(() => [TagScalarFieldEnum], { nullable: true }) 26 | distinct?: Array; 27 | } 28 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-create.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateNestedOneWithoutCommentsInput } from '../article/article-create-nested-one-without-comments.input'; 4 | import { UserCreateNestedOneWithoutCommentsInput } from '../user/user-create-nested-one-without-comments.input'; 5 | 6 | @InputType() 7 | export class CommentCreateInput { 8 | @Field(() => String, { nullable: true }) 9 | commentId?: string; 10 | 11 | @Field(() => Date, { nullable: true }) 12 | createdAt?: Date | string; 13 | 14 | @Field(() => Date, { nullable: true }) 15 | updatedAt?: Date | string; 16 | 17 | @Field(() => String, { nullable: false }) 18 | body!: string; 19 | 20 | @Field(() => UserCreateNestedOneWithoutCommentsInput, { nullable: false }) 21 | author!: UserCreateNestedOneWithoutCommentsInput; 22 | 23 | @Field(() => ArticleCreateNestedOneWithoutCommentsInput, { nullable: true }) 24 | article?: ArticleCreateNestedOneWithoutCommentsInput; 25 | } 26 | -------------------------------------------------------------------------------- /src/@generated/tag/find-first-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field, Int } from '@nestjs/graphql'; 2 | 3 | import { TagOrderByWithRelationInput } from './tag-order-by-with-relation.input'; 4 | import { TagScalarFieldEnum } from './tag-scalar-field.enum'; 5 | import { TagWhereInput } from './tag-where.input'; 6 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 7 | 8 | @ArgsType() 9 | export class FindFirstTagArgs { 10 | @Field(() => TagWhereInput, { nullable: true }) 11 | where?: TagWhereInput; 12 | 13 | @Field(() => [TagOrderByWithRelationInput], { nullable: true }) 14 | orderBy?: Array; 15 | 16 | @Field(() => TagWhereUniqueInput, { nullable: true }) 17 | cursor?: TagWhereUniqueInput; 18 | 19 | @Field(() => Int, { nullable: true }) 20 | take?: number; 21 | 22 | @Field(() => Int, { nullable: true }) 23 | skip?: number; 24 | 25 | @Field(() => [TagScalarFieldEnum], { nullable: true }) 26 | distinct?: Array; 27 | } 28 | -------------------------------------------------------------------------------- /src/@generated/prisma/string-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class StringFilter { 5 | @Field(() => String, { nullable: true }) 6 | equals?: string; 7 | 8 | @Field(() => [String], { nullable: true }) 9 | in?: Array; 10 | 11 | @Field(() => [String], { nullable: true }) 12 | notIn?: Array; 13 | 14 | @Field(() => String, { nullable: true }) 15 | lt?: string; 16 | 17 | @Field(() => String, { nullable: true }) 18 | lte?: string; 19 | 20 | @Field(() => String, { nullable: true }) 21 | gt?: string; 22 | 23 | @Field(() => String, { nullable: true }) 24 | gte?: string; 25 | 26 | @Field(() => String, { nullable: true }) 27 | contains?: string; 28 | 29 | @Field(() => String, { nullable: true }) 30 | startsWith?: string; 31 | 32 | @Field(() => String, { nullable: true }) 33 | endsWith?: string; 34 | 35 | @Field(() => StringFilter, { nullable: true }) 36 | not?: StringFilter; 37 | } 38 | -------------------------------------------------------------------------------- /src/@generated/user/find-many-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field, Int } from '@nestjs/graphql'; 2 | 3 | import { UserOrderByWithRelationInput } from './user-order-by-with-relation.input'; 4 | import { UserScalarFieldEnum } from './user-scalar-field.enum'; 5 | import { UserWhereInput } from './user-where.input'; 6 | import { UserWhereUniqueInput } from './user-where-unique.input'; 7 | 8 | @ArgsType() 9 | export class FindManyUserArgs { 10 | @Field(() => UserWhereInput, { nullable: true }) 11 | where?: UserWhereInput; 12 | 13 | @Field(() => [UserOrderByWithRelationInput], { nullable: true }) 14 | orderBy?: Array; 15 | 16 | @Field(() => UserWhereUniqueInput, { nullable: true }) 17 | cursor?: UserWhereUniqueInput; 18 | 19 | @Field(() => Int, { nullable: true }) 20 | take?: number; 21 | 22 | @Field(() => Int, { nullable: true }) 23 | skip?: number; 24 | 25 | @Field(() => [UserScalarFieldEnum], { nullable: true }) 26 | distinct?: Array; 27 | } 28 | -------------------------------------------------------------------------------- /src/@generated/article/aggregate-article.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | import { ArticleAvgAggregate } from './article-avg-aggregate.output'; 4 | import { ArticleCountAggregate } from './article-count-aggregate.output'; 5 | import { ArticleMaxAggregate } from './article-max-aggregate.output'; 6 | import { ArticleMinAggregate } from './article-min-aggregate.output'; 7 | import { ArticleSumAggregate } from './article-sum-aggregate.output'; 8 | 9 | @ObjectType() 10 | export class AggregateArticle { 11 | @Field(() => ArticleCountAggregate, { nullable: true }) 12 | _count?: ArticleCountAggregate; 13 | 14 | @Field(() => ArticleAvgAggregate, { nullable: true }) 15 | _avg?: ArticleAvgAggregate; 16 | 17 | @Field(() => ArticleSumAggregate, { nullable: true }) 18 | _sum?: ArticleSumAggregate; 19 | 20 | @Field(() => ArticleMinAggregate, { nullable: true }) 21 | _min?: ArticleMinAggregate; 22 | 23 | @Field(() => ArticleMaxAggregate, { nullable: true }) 24 | _max?: ArticleMaxAggregate; 25 | } 26 | -------------------------------------------------------------------------------- /src/@generated/tag/tag-order-by-with-aggregation.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | import { TagCountOrderByAggregateInput } from './tag-count-order-by-aggregate.input'; 5 | import { TagMaxOrderByAggregateInput } from './tag-max-order-by-aggregate.input'; 6 | import { TagMinOrderByAggregateInput } from './tag-min-order-by-aggregate.input'; 7 | 8 | @InputType() 9 | export class TagOrderByWithAggregationInput { 10 | @Field(() => SortOrder, { nullable: true }) 11 | tagId?: keyof typeof SortOrder; 12 | 13 | @Field(() => SortOrder, { nullable: true }) 14 | name?: keyof typeof SortOrder; 15 | 16 | @Field(() => TagCountOrderByAggregateInput, { nullable: true }) 17 | _count?: TagCountOrderByAggregateInput; 18 | 19 | @Field(() => TagMaxOrderByAggregateInput, { nullable: true }) 20 | _max?: TagMaxOrderByAggregateInput; 21 | 22 | @Field(() => TagMinOrderByAggregateInput, { nullable: true }) 23 | _min?: TagMinOrderByAggregateInput; 24 | } 25 | -------------------------------------------------------------------------------- /src/@generated/user/find-first-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field, Int } from '@nestjs/graphql'; 2 | 3 | import { UserOrderByWithRelationInput } from './user-order-by-with-relation.input'; 4 | import { UserScalarFieldEnum } from './user-scalar-field.enum'; 5 | import { UserWhereInput } from './user-where.input'; 6 | import { UserWhereUniqueInput } from './user-where-unique.input'; 7 | 8 | @ArgsType() 9 | export class FindFirstUserArgs { 10 | @Field(() => UserWhereInput, { nullable: true }) 11 | where?: UserWhereInput; 12 | 13 | @Field(() => [UserOrderByWithRelationInput], { nullable: true }) 14 | orderBy?: Array; 15 | 16 | @Field(() => UserWhereUniqueInput, { nullable: true }) 17 | cursor?: UserWhereUniqueInput; 18 | 19 | @Field(() => Int, { nullable: true }) 20 | take?: number; 21 | 22 | @Field(() => Int, { nullable: true }) 23 | skip?: number; 24 | 25 | @Field(() => [UserScalarFieldEnum], { nullable: true }) 26 | distinct?: Array; 27 | } 28 | -------------------------------------------------------------------------------- /src/types/index.ts: -------------------------------------------------------------------------------- 1 | import { DeepPartial, PlainObject } from 'simplytyped'; 2 | 3 | import { AppEnvironment as _AppEnvironment } from '../app.environment'; 4 | import { graphqlModuleFactory } from '../app.module'; 5 | import { PassportUserFields as _PassportUserFields } from '../auth'; 6 | 7 | export type Await = T extends { 8 | then(onfulfilled?: (value: infer U) => unknown): unknown; 9 | } 10 | ? U 11 | : T; 12 | 13 | export type GraphQLContext = ReturnType< 14 | Await>['context'] 15 | >; 16 | 17 | declare global { 18 | // eslint-disable-next-line @typescript-eslint/no-namespace 19 | namespace Express { 20 | /** 21 | * Same as PassportUserFields. 22 | */ 23 | interface User { 24 | id: string; 25 | email: string; 26 | } 27 | } 28 | } 29 | 30 | export type AppEnvironment = typeof _AppEnvironment; 31 | export type GraphqlFieldsParameter = DeepPartial>; 32 | export type PassportUserFields = _PassportUserFields; 33 | -------------------------------------------------------------------------------- /src/article/testing/index.ts: -------------------------------------------------------------------------------- 1 | import { Prisma } from '@prisma/client'; 2 | 3 | type ArticlePayload = Prisma.ArticleGetPayload<{ 4 | include: { 5 | author: true; 6 | tags: true; 7 | favoritedBy: true; 8 | comments: true; 9 | }; 10 | }>; 11 | 12 | export function createArticle(parts: Partial = {}): ArticlePayload { 13 | return { 14 | articleId: 'article_id', 15 | slug: 'article_slug', 16 | title: 'article_title', 17 | description: 'article_description', 18 | body: 'article_body', 19 | tags: [], 20 | createdAt: new Date(), 21 | updatedAt: new Date(), 22 | favoritesCount: 0, 23 | author: { 24 | userId: 'author_id', 25 | name: 'author_name', 26 | email: 'author_name@diamond.net', 27 | password: '', 28 | bio: null, 29 | image: null, 30 | }, 31 | authorId: 'author_id', 32 | favoritedBy: [], 33 | comments: [], 34 | ...parts, 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /src/api/tag-list.interceptor.ts: -------------------------------------------------------------------------------- 1 | import { 2 | CallHandler, 3 | ExecutionContext, 4 | Injectable, 5 | NestInterceptor, 6 | } from '@nestjs/common'; 7 | import { map } from 'rxjs/operators'; 8 | 9 | /** 10 | * Remap field value tags {name} to taglist [string]. 11 | */ 12 | @Injectable() 13 | export class TagListInterceptor implements NestInterceptor { 14 | intercept(context: ExecutionContext, next: CallHandler) { 15 | return next.handle().pipe( 16 | map(data => { 17 | if ('articles' in data) { 18 | data.articles = data.articles.map(a => toArticleDto(a)); 19 | } else if ('article' in data) { 20 | data.article = toArticleDto(data.article); 21 | } 22 | return data; 23 | }), 24 | ); 25 | } 26 | } 27 | 28 | function toArticleDto(article: { tags: { name: string }[] }) { 29 | const { tags, ...temporaryArticle } = article; 30 | return { 31 | ...temporaryArticle, 32 | tagList: tags.map(tag => tag.name), 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /src/article/slug/slug.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | 3 | import { SlugService } from './slug.service'; 4 | 5 | describe('SlugService', () => { 6 | let service: SlugService; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | providers: [SlugService], 11 | }).compile(); 12 | 13 | service = module.get(SlugService); 14 | }); 15 | 16 | it('should be defined', () => { 17 | expect(service).toBeDefined(); 18 | }); 19 | 20 | it('generate unique slug', async () => { 21 | let result = await service.generate('Google', async () => true); 22 | expect(result).toEqual('google'); 23 | result = await service.generate( 24 | 'Google', 25 | async (s: string) => { 26 | return s.length > 'Google'.length; 27 | }, 28 | 5, 29 | ); 30 | expect(result).toContain('google-'); 31 | expect(result.length).toBeGreaterThan(7); 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /src/comment/author.guard.ts: -------------------------------------------------------------------------------- 1 | import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'; 2 | import { GqlExecutionContext } from '@nestjs/graphql'; 3 | import { Prisma } from '@prisma/client'; 4 | 5 | import { CommentService } from './comment.service'; 6 | 7 | /** 8 | * Checks if user can edit own entity. 9 | */ 10 | @Injectable() 11 | export class AuthorGuard implements CanActivate { 12 | constructor(private readonly service: CommentService) {} 13 | 14 | async canActivate(context: ExecutionContext) { 15 | const graphqlContext = GqlExecutionContext.create(context); 16 | const request = graphqlContext.getContext().req; 17 | const where: Prisma.CommentWhereUniqueInput | undefined = 18 | context.getArgByIndex(1)?.where; 19 | if (!(request.user && where)) { 20 | return false; 21 | } 22 | const entity = await this.service.findUnique({ 23 | where, 24 | select: { authorId: true }, 25 | }); 26 | return Boolean(entity && entity.authorId === request.user.id); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/@generated/article/find-first-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field, Int } from '@nestjs/graphql'; 2 | 3 | import { ArticleOrderByWithRelationInput } from './article-order-by-with-relation.input'; 4 | import { ArticleScalarFieldEnum } from './article-scalar-field.enum'; 5 | import { ArticleWhereInput } from './article-where.input'; 6 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 7 | 8 | @ArgsType() 9 | export class FindFirstArticleArgs { 10 | @Field(() => ArticleWhereInput, { nullable: true }) 11 | where?: ArticleWhereInput; 12 | 13 | @Field(() => [ArticleOrderByWithRelationInput], { nullable: true }) 14 | orderBy?: Array; 15 | 16 | @Field(() => ArticleWhereUniqueInput, { nullable: true }) 17 | cursor?: ArticleWhereUniqueInput; 18 | 19 | @Field(() => Int, { nullable: true }) 20 | take?: number; 21 | 22 | @Field(() => Int, { nullable: true }) 23 | skip?: number; 24 | 25 | @Field(() => [ArticleScalarFieldEnum], { nullable: true }) 26 | distinct?: Array; 27 | } 28 | -------------------------------------------------------------------------------- /src/@generated/article/find-many-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field, Int } from '@nestjs/graphql'; 2 | 3 | import { ArticleOrderByWithRelationInput } from './article-order-by-with-relation.input'; 4 | import { ArticleScalarFieldEnum } from './article-scalar-field.enum'; 5 | import { ArticleWhereInput } from './article-where.input'; 6 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 7 | 8 | @ArgsType() 9 | export class FindManyArticleArgs { 10 | @Field(() => ArticleWhereInput, { nullable: true }) 11 | where?: ArticleWhereInput; 12 | 13 | @Field(() => [ArticleOrderByWithRelationInput], { nullable: true }) 14 | orderBy?: Array; 15 | 16 | @Field(() => ArticleWhereUniqueInput, { nullable: true }) 17 | cursor?: ArticleWhereUniqueInput; 18 | 19 | @Field(() => Int, { nullable: true }) 20 | take?: number; 21 | 22 | @Field(() => Int, { nullable: true }) 23 | skip?: number; 24 | 25 | @Field(() => [ArticleScalarFieldEnum], { nullable: true }) 26 | distinct?: Array; 27 | } 28 | -------------------------------------------------------------------------------- /src/@generated/comment/find-first-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field, Int } from '@nestjs/graphql'; 2 | 3 | import { CommentOrderByWithRelationInput } from './comment-order-by-with-relation.input'; 4 | import { CommentScalarFieldEnum } from './comment-scalar-field.enum'; 5 | import { CommentWhereInput } from './comment-where.input'; 6 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 7 | 8 | @ArgsType() 9 | export class FindFirstCommentArgs { 10 | @Field(() => CommentWhereInput, { nullable: true }) 11 | where?: CommentWhereInput; 12 | 13 | @Field(() => [CommentOrderByWithRelationInput], { nullable: true }) 14 | orderBy?: Array; 15 | 16 | @Field(() => CommentWhereUniqueInput, { nullable: true }) 17 | cursor?: CommentWhereUniqueInput; 18 | 19 | @Field(() => Int, { nullable: true }) 20 | take?: number; 21 | 22 | @Field(() => Int, { nullable: true }) 23 | skip?: number; 24 | 25 | @Field(() => [CommentScalarFieldEnum], { nullable: true }) 26 | distinct?: Array; 27 | } 28 | -------------------------------------------------------------------------------- /src/@generated/comment/find-many-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field, Int } from '@nestjs/graphql'; 2 | 3 | import { CommentOrderByWithRelationInput } from './comment-order-by-with-relation.input'; 4 | import { CommentScalarFieldEnum } from './comment-scalar-field.enum'; 5 | import { CommentWhereInput } from './comment-where.input'; 6 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 7 | 8 | @ArgsType() 9 | export class FindManyCommentArgs { 10 | @Field(() => CommentWhereInput, { nullable: true }) 11 | where?: CommentWhereInput; 12 | 13 | @Field(() => [CommentOrderByWithRelationInput], { nullable: true }) 14 | orderBy?: Array; 15 | 16 | @Field(() => CommentWhereUniqueInput, { nullable: true }) 17 | cursor?: CommentWhereUniqueInput; 18 | 19 | @Field(() => Int, { nullable: true }) 20 | take?: number; 21 | 22 | @Field(() => Int, { nullable: true }) 23 | skip?: number; 24 | 25 | @Field(() => [CommentScalarFieldEnum], { nullable: true }) 26 | distinct?: Array; 27 | } 28 | -------------------------------------------------------------------------------- /src/comment/comment.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Logger } from '@nestjs/common'; 2 | import { Test, TestingModule } from '@nestjs/testing'; 3 | import { DummyRepository } from 'app_modules/prisma/testing'; 4 | import { createSpyObj } from 'jest-createspyobj'; 5 | 6 | import { CommentService } from './comment.service'; 7 | 8 | describe('CommentService', () => { 9 | let service: CommentService; 10 | 11 | beforeEach(async () => { 12 | const module: TestingModule = await Test.createTestingModule({ 13 | providers: [ 14 | CommentService, 15 | { 16 | provide: 'commentPrismaRepository', 17 | useValue: createSpyObj(DummyRepository), 18 | }, 19 | { 20 | provide: Logger, 21 | useValue: createSpyObj(Logger), 22 | }, 23 | ], 24 | }).compile(); 25 | 26 | service = module.get(CommentService); 27 | }); 28 | 29 | it('should be defined', () => { 30 | expect(service).toBeDefined(); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /src/user/models/user.model.ts: -------------------------------------------------------------------------------- 1 | import { Article } from '@generated/article/article.model'; 2 | import { Field, HideField, ID, ObjectType } from '@nestjs/graphql'; 3 | 4 | @ObjectType({}) 5 | export class User { 6 | @Field(() => ID, { 7 | nullable: false, 8 | }) 9 | userId!: string; 10 | 11 | @Field(() => String, { 12 | nullable: false, 13 | }) 14 | email!: string; 15 | 16 | @Field(() => String, { 17 | nullable: false, 18 | }) 19 | name!: string; 20 | 21 | @HideField() 22 | password!: string; 23 | 24 | @Field(() => String, { 25 | nullable: true, 26 | }) 27 | bio?: string; 28 | 29 | @Field(() => String, { 30 | nullable: true, 31 | }) 32 | image?: string; 33 | 34 | @Field(() => [User], { 35 | nullable: true, 36 | }) 37 | following?: Array; 38 | 39 | @Field(() => [User], { 40 | nullable: true, 41 | }) 42 | followers?: Array; 43 | 44 | @Field(() => [Article], { 45 | nullable: true, 46 | }) 47 | favoriteArticles?: Array
; 48 | } 49 | -------------------------------------------------------------------------------- /src/@generated/user/user-scalar-where.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { StringFilter } from '../prisma/string-filter.input'; 4 | 5 | @InputType() 6 | export class UserScalarWhereInput { 7 | @Field(() => [UserScalarWhereInput], { nullable: true }) 8 | AND?: Array; 9 | 10 | @Field(() => [UserScalarWhereInput], { nullable: true }) 11 | OR?: Array; 12 | 13 | @Field(() => [UserScalarWhereInput], { nullable: true }) 14 | NOT?: Array; 15 | 16 | @Field(() => StringFilter, { nullable: true }) 17 | userId?: StringFilter; 18 | 19 | @Field(() => StringFilter, { nullable: true }) 20 | email?: StringFilter; 21 | 22 | @Field(() => StringFilter, { nullable: true }) 23 | name?: StringFilter; 24 | 25 | @Field(() => StringFilter, { nullable: true }) 26 | password?: StringFilter; 27 | 28 | @Field(() => StringFilter, { nullable: true }) 29 | bio?: StringFilter; 30 | 31 | @Field(() => StringFilter, { nullable: true }) 32 | image?: StringFilter; 33 | } 34 | -------------------------------------------------------------------------------- /src/article/author.guard.ts: -------------------------------------------------------------------------------- 1 | import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'; 2 | import { GqlExecutionContext } from '@nestjs/graphql'; 3 | import { Prisma } from '@prisma/client'; 4 | 5 | import { ArticleService } from './article.service'; 6 | 7 | /** 8 | * Checks if user can edit own article. 9 | */ 10 | @Injectable() 11 | export class AuthorGuard implements CanActivate { 12 | constructor(private readonly articleService: ArticleService) {} 13 | 14 | async canActivate(context: ExecutionContext) { 15 | const graphqlContext = GqlExecutionContext.create(context); 16 | const request = graphqlContext.getContext().req; 17 | const where: Prisma.ArticleWhereUniqueInput | undefined = 18 | context.getArgByIndex(1)?.where; 19 | if (!(request.user && where)) { 20 | return false; 21 | } 22 | const article = await this.articleService.findUnique({ 23 | where, 24 | select: { authorId: true }, 25 | }); 26 | return Boolean(article && article.authorId === request.user.id); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/auth/auth.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { JwtService } from '@nestjs/jwt'; 2 | import { Test } from '@nestjs/testing'; 3 | import { instance, mock } from 'ts-mockito'; 4 | 5 | import { AppEnvironment } from '../app.environment'; 6 | import { AuthService } from './auth.service'; 7 | 8 | describe('AuthService', () => { 9 | let service: AuthService; 10 | const jwtService = mock(JwtService); 11 | const appEnvironment = mock(AppEnvironment); 12 | 13 | beforeEach(async () => { 14 | const module = await Test.createTestingModule({ 15 | providers: [ 16 | AuthService, 17 | { 18 | provide: JwtService, 19 | useValue: instance(jwtService), 20 | }, 21 | { 22 | provide: AppEnvironment, 23 | useValue: instance(appEnvironment), 24 | }, 25 | ], 26 | }).compile(); 27 | 28 | service = module.get(AuthService); 29 | }); 30 | 31 | it('should be defined', () => { 32 | expect(service).toBeDefined(); 33 | }); 34 | }); 35 | -------------------------------------------------------------------------------- /src/app_modules/prisma/inject-repository.decorator.ts: -------------------------------------------------------------------------------- 1 | import { Inject } from '@nestjs/common'; 2 | import { PrismaClient } from '@prisma/client'; 3 | 4 | import { PrismaRepository } from './prisma.repository'; 5 | 6 | const prismaRepositories = new Set(); 7 | 8 | export function createRepositoryProviers() { 9 | return [...prismaRepositories].map(name => { 10 | return { 11 | provide: `${name}PrismaRepository`, 12 | inject: [PrismaRepository], 13 | useFactory: (prisma: PrismaRepository) => prisma[name], 14 | }; 15 | }); 16 | } 17 | 18 | /** 19 | * Example: 20 | * @InjectRepository('user') repository: PrismaRepository['user'] or PrismaClient['user'] 21 | */ 22 | export function InjectRepository(name: PrismaDelegateNames) { 23 | prismaRepositories.add(name); 24 | return Inject(`${name}PrismaRepository`); 25 | } 26 | 27 | type TestDelegate = { findMany: (args: any) => any }; 28 | type PrismaDelegateNames = keyof { 29 | [P in keyof PrismaClient as PrismaClient[P] extends TestDelegate 30 | ? P 31 | : never]: PrismaClient[P]; 32 | }; 33 | -------------------------------------------------------------------------------- /src/user/validators/user-exists.validator.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { 3 | ValidationArguments, 4 | ValidatorConstraint, 5 | ValidatorConstraintInterface, 6 | } from 'class-validator'; 7 | 8 | import { UserService } from '../user.service'; 9 | 10 | /** 11 | * Custom validator, checks for name/email unique. 12 | * Make sure that all your dependencies are not SCOPE.Default'ed. 13 | */ 14 | @ValidatorConstraint({ name: 'user', async: true }) 15 | @Injectable() 16 | export class UserExistsValidator implements ValidatorConstraintInterface { 17 | constructor(private readonly userService: UserService) {} 18 | 19 | /** 20 | * Method should return true, if name is not taken. 21 | */ 22 | async validate(name: string, args: ValidationArguments) { 23 | const result = await this.userService.findUnique({ 24 | where: { name }, 25 | select: { userId: true }, 26 | }); 27 | return !result; 28 | } 29 | 30 | defaultMessage(_args: ValidationArguments) { 31 | return 'User with $property $value already exists'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | const { pathsToModuleNameMapper } = require('ts-jest'); 2 | const { compilerOptions } = require('./tsconfig'); 3 | 4 | module.exports = { 5 | rootDir: 'src', 6 | testEnvironment: 'node', 7 | transform: { 8 | '^.+\\.tsx?$': 'ts-jest', 9 | }, 10 | collectCoverage: false, 11 | coverageDirectory: `${__dirname}/coverage`, 12 | coverageReporters: ['lcov', 'text'], 13 | collectCoverageFrom: [ 14 | '**/*.ts', 15 | '!**/*.spec.ts', 16 | '!**/*.module.ts', 17 | '!**/@generated/**', 18 | ], 19 | testRegex: ['(\\.|/)(test|spec)\\.[jt]sx?$'], 20 | // testMatch: ['/src/**/*.spec.ts'], 21 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'], 22 | // modulePathIgnorePatterns: ['/dist'], 23 | moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { 24 | prefix: '/../', 25 | }), 26 | // modulePathIgnorePatterns: ['/app_modules'], 27 | globals: { 28 | 'ts-jest': { 29 | diagnostics: false, 30 | isolatedModules: true, 31 | }, 32 | }, 33 | }; 34 | -------------------------------------------------------------------------------- /src/@generated/user/user-group-by.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | import { UserCountAggregate } from './user-count-aggregate.output'; 4 | import { UserMaxAggregate } from './user-max-aggregate.output'; 5 | import { UserMinAggregate } from './user-min-aggregate.output'; 6 | 7 | @ObjectType() 8 | export class UserGroupBy { 9 | @Field(() => String, { nullable: false }) 10 | userId!: string; 11 | 12 | @Field(() => String, { nullable: false }) 13 | email!: string; 14 | 15 | @Field(() => String, { nullable: false }) 16 | name!: string; 17 | 18 | @Field(() => String, { nullable: false }) 19 | password!: string; 20 | 21 | @Field(() => String, { nullable: true }) 22 | bio?: string; 23 | 24 | @Field(() => String, { nullable: true }) 25 | image?: string; 26 | 27 | @Field(() => UserCountAggregate, { nullable: true }) 28 | _count?: UserCountAggregate; 29 | 30 | @Field(() => UserMinAggregate, { nullable: true }) 31 | _min?: UserMinAggregate; 32 | 33 | @Field(() => UserMaxAggregate, { nullable: true }) 34 | _max?: UserMaxAggregate; 35 | } 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 RealWorld 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/@generated/article/article-max-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class ArticleMaxOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | articleId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | slug?: keyof typeof SortOrder; 12 | 13 | @Field(() => SortOrder, { nullable: true }) 14 | title?: keyof typeof SortOrder; 15 | 16 | @Field(() => SortOrder, { nullable: true }) 17 | description?: keyof typeof SortOrder; 18 | 19 | @Field(() => SortOrder, { nullable: true }) 20 | body?: keyof typeof SortOrder; 21 | 22 | @Field(() => SortOrder, { nullable: true }) 23 | createdAt?: keyof typeof SortOrder; 24 | 25 | @Field(() => SortOrder, { nullable: true }) 26 | updatedAt?: keyof typeof SortOrder; 27 | 28 | @Field(() => SortOrder, { nullable: true }) 29 | favoritesCount?: keyof typeof SortOrder; 30 | 31 | @Field(() => SortOrder, { nullable: true }) 32 | authorId?: keyof typeof SortOrder; 33 | } 34 | -------------------------------------------------------------------------------- /src/@generated/article/article-min-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class ArticleMinOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | articleId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | slug?: keyof typeof SortOrder; 12 | 13 | @Field(() => SortOrder, { nullable: true }) 14 | title?: keyof typeof SortOrder; 15 | 16 | @Field(() => SortOrder, { nullable: true }) 17 | description?: keyof typeof SortOrder; 18 | 19 | @Field(() => SortOrder, { nullable: true }) 20 | body?: keyof typeof SortOrder; 21 | 22 | @Field(() => SortOrder, { nullable: true }) 23 | createdAt?: keyof typeof SortOrder; 24 | 25 | @Field(() => SortOrder, { nullable: true }) 26 | updatedAt?: keyof typeof SortOrder; 27 | 28 | @Field(() => SortOrder, { nullable: true }) 29 | favoritesCount?: keyof typeof SortOrder; 30 | 31 | @Field(() => SortOrder, { nullable: true }) 32 | authorId?: keyof typeof SortOrder; 33 | } 34 | -------------------------------------------------------------------------------- /src/@generated/article/article-count-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class ArticleCountOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | articleId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | slug?: keyof typeof SortOrder; 12 | 13 | @Field(() => SortOrder, { nullable: true }) 14 | title?: keyof typeof SortOrder; 15 | 16 | @Field(() => SortOrder, { nullable: true }) 17 | description?: keyof typeof SortOrder; 18 | 19 | @Field(() => SortOrder, { nullable: true }) 20 | body?: keyof typeof SortOrder; 21 | 22 | @Field(() => SortOrder, { nullable: true }) 23 | createdAt?: keyof typeof SortOrder; 24 | 25 | @Field(() => SortOrder, { nullable: true }) 26 | updatedAt?: keyof typeof SortOrder; 27 | 28 | @Field(() => SortOrder, { nullable: true }) 29 | favoritesCount?: keyof typeof SortOrder; 30 | 31 | @Field(() => SortOrder, { nullable: true }) 32 | authorId?: keyof typeof SortOrder; 33 | } 34 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-group-by.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | import { CommentCountAggregate } from './comment-count-aggregate.output'; 4 | import { CommentMaxAggregate } from './comment-max-aggregate.output'; 5 | import { CommentMinAggregate } from './comment-min-aggregate.output'; 6 | 7 | @ObjectType() 8 | export class CommentGroupBy { 9 | @Field(() => String, { nullable: false }) 10 | commentId!: string; 11 | 12 | @Field(() => Date, { nullable: false }) 13 | createdAt!: Date | string; 14 | 15 | @Field(() => Date, { nullable: false }) 16 | updatedAt!: Date | string; 17 | 18 | @Field(() => String, { nullable: false }) 19 | body!: string; 20 | 21 | @Field(() => String, { nullable: false }) 22 | authorId!: string; 23 | 24 | @Field(() => String, { nullable: true }) 25 | articleId?: string; 26 | 27 | @Field(() => CommentCountAggregate, { nullable: true }) 28 | _count?: CommentCountAggregate; 29 | 30 | @Field(() => CommentMinAggregate, { nullable: true }) 31 | _min?: CommentMinAggregate; 32 | 33 | @Field(() => CommentMaxAggregate, { nullable: true }) 34 | _max?: CommentMaxAggregate; 35 | } 36 | -------------------------------------------------------------------------------- /src/@generated/comment/comment-scalar-where.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { DateTimeFilter } from '../prisma/date-time-filter.input'; 4 | import { StringFilter } from '../prisma/string-filter.input'; 5 | 6 | @InputType() 7 | export class CommentScalarWhereInput { 8 | @Field(() => [CommentScalarWhereInput], { nullable: true }) 9 | AND?: Array; 10 | 11 | @Field(() => [CommentScalarWhereInput], { nullable: true }) 12 | OR?: Array; 13 | 14 | @Field(() => [CommentScalarWhereInput], { nullable: true }) 15 | NOT?: Array; 16 | 17 | @Field(() => StringFilter, { nullable: true }) 18 | commentId?: StringFilter; 19 | 20 | @Field(() => DateTimeFilter, { nullable: true }) 21 | createdAt?: DateTimeFilter; 22 | 23 | @Field(() => DateTimeFilter, { nullable: true }) 24 | updatedAt?: DateTimeFilter; 25 | 26 | @Field(() => StringFilter, { nullable: true }) 27 | body?: StringFilter; 28 | 29 | @Field(() => StringFilter, { nullable: true }) 30 | authorId?: StringFilter; 31 | 32 | @Field(() => StringFilter, { nullable: true }) 33 | articleId?: StringFilter; 34 | } 35 | -------------------------------------------------------------------------------- /src/@generated/user/user.model.ts: -------------------------------------------------------------------------------- 1 | export { User } from '../../user/models/user.model'; 2 | 3 | // @ObjectType() 4 | // export class User { 5 | // 6 | // @Field(() => ID, {nullable:false}) 7 | // userId!: string; 8 | // 9 | // @Field(() => String, {nullable:false}) 10 | // email!: string; 11 | // 12 | // @Field(() => String, {nullable:false}) 13 | // name!: string; 14 | // 15 | // @Field(() => String, {nullable:false}) 16 | // password!: string; 17 | // 18 | // @Field(() => String, {nullable:true}) 19 | // bio!: string | null; 20 | // 21 | // @Field(() => String, {nullable:true}) 22 | // image!: string | null; 23 | // 24 | // @Field(() => [User], {nullable:true}) 25 | // following?: Array; 26 | // 27 | // @Field(() => [User], {nullable:true}) 28 | // followers?: Array; 29 | // 30 | // @Field(() => [Article], {nullable:true}) 31 | // favoriteArticles?: Array
; 32 | // 33 | // @Field(() => [Article], {nullable:true}) 34 | // articles?: Array
; 35 | // 36 | // @Field(() => [Comment], {nullable:true}) 37 | // comments?: Array; 38 | // 39 | // @Field(() => UserCount, {nullable:false}) 40 | // _count?: UserCount; 41 | // } 42 | -------------------------------------------------------------------------------- /src/app_modules/all-exceptions-filter/index.ts: -------------------------------------------------------------------------------- 1 | import { ArgumentsHost, Catch, ExceptionFilter } from '@nestjs/common'; 2 | import { Response } from 'express'; 3 | import { serializeError } from 'serialize-error'; 4 | 5 | /** 6 | * Temporary solution 7 | * https://github.com/the-vampiire/apollo-error-converter/issues/23 8 | */ 9 | @Catch() 10 | export class AllExceptionsFilter implements ExceptionFilter { 11 | catch(exception: any, host: ArgumentsHost) { 12 | if (host.getType() === 'http') { 13 | // todo: need find status code 14 | const response = host.switchToHttp().getResponse(); 15 | return response.status(500).json({ 16 | timestamp: new Date().toISOString(), 17 | errors: serializeError(exception), 18 | }); 19 | } 20 | // Fill name, code, type fields for Apollo Error Converter 21 | if (typeof exception === 'object') { 22 | if (!exception.type) { 23 | exception.type = exception.constructor?.name || exception.message; 24 | } 25 | if (!exception.code) { 26 | exception.code = exception.status; 27 | } 28 | } 29 | return exception; 30 | } 31 | } 32 | --------------------------------------------------------------------------------