prisma-nestjs-graphql icon indicating copy to clipboard operation
prisma-nestjs-graphql copied to clipboard

Prisma generate do not generate some Aggregate Args classes

Open KozielGPC opened this issue 2 years ago • 9 comments

Hello to everyone, This week I have updated my prisma environment and I'm having a problem where some AggregateArgs classes are not being generated. I thought that something was different between other classes in schema.prisma, but they are structured the same way. Classes like Avg, Sum, Min, Max Aggregate are generated, but only AggregateArgs are not:

Folder with Missing AggregateArgs

image

Folder without Missing AggregateArgs

image

Environment

"@prisma/client": "^4.11.0", "prisma": "^4.11.0", "prisma-nestjs-graphql": "^17.1.0", "@nestjs/common": "^8.1.1", "@nestjs/core": "^8.0.0", "nestjs-prisma": "^0.20.0", "@nestjs/graphql": "^9.1.1",

KozielGPC avatar Mar 08 '23 13:03 KozielGPC

have hit similar issue. Some tables are generated with find-many-[x].args.ts, while others don't have that file generated

djdabs avatar May 04 '23 20:05 djdabs

found them, they were in the @generated/prisma directory for some reason instead directory dedicated to that table

djdabs avatar May 04 '23 21:05 djdabs

Scalar inputs, enums, and other common types which are not related to model name will be saved to "prisma" folder

unlight avatar May 09 '23 15:05 unlight

Is there issue here? Something is missing?

unlight avatar May 09 '23 15:05 unlight

Is there issue here? Something is missing?

Yes, the files were not generated even in @generated/prisma folder, I had to copy it to a file using the previous version, as example, and save it in some other folder that were not generated

KozielGPC avatar May 09 '23 17:05 KozielGPC

@KozielGPC Could you provide minimal reproducing repo?

unlight avatar May 09 '23 17:05 unlight

@unlight sure This is an example of how my schema.prisma is with the models that I mentioned above:

Note

In my prisma generated files, there was no one file like league-partner-aggregate.args.ts, as the Cart has the cart-aggregate.args.ts

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator nestgraphql {
  provider                        = "node node_modules/prisma-nestjs-graphql"
  output                          = "@generated"
  noAtomicOperations              = true
  fields_Validator_input          = "true"
  fields_Validator_from           = "class-validator"
  fields_BrazilianValidator_input = "true"
  fields_BrazilianValidator_from  = "brazilian-class-validator"
  fields_Transformer_model        = "true"
  fields_Transformer_from         = "class-transformer"
  fields_Scalars_from             = "graphql-scalars"
  fields_Scalars_input            = true
  fields_Scalars_output           = true
}

generator docs {
  provider = "node node_modules/prisma-docs-generator"
  output   = "../docs/"
}

generator dbml {
  provider   = "prisma-dbml-generator"
  output     = "../docs/dbml"
  outputName = "model.dbml"
}

model LeaguePartner {
  /// @Validator.IsUUID('4')
  /// @HideField({ match: '{LeaguePartnerUncheckedCreateInput,LeaguePartnerUncheckedUpdateInput}' })
  id String @id @default(uuid()) @db.Uuid

  /// @Validator.IsBoolean()
  /// @Validator.IsOptional()
  active Boolean @default(true)

  /// @Validator.ValidateIf((o) => o.tickets_quantity !== undefined)
  /// @Validator.IsInt()
  /// @Validator.IsPositive()
  /// @Validator.IsNotEmpty()
  /// @Validator.Min(1)
  tickets_quantity Int

  /// @HideField({ match: '{LeaguePartnerUncheckedCreateInput,LeaguePartnerUncheckedUpdateInput}' })
  /// @Transformer.Transform(({ value }) => new Date(value), { toClassOnly: true })
  created_at DateTime @default(now()) @db.Timestamptz(6)

  /// @HideField({ match: '{LeaguePartnerUncheckedCreateInput,LeaguePartnerUncheckedUpdateInput}' })
  /// @Transformer.Transform(({ value }) => new Date(value), { toClassOnly: true })
  updated_at DateTime @default(now()) @updatedAt @db.Timestamptz(6)

  /// @HideField({ output: false, input: true })
  /// @Transformer.Transform(({ value }) => (value ? new Date(value) : null), { toClassOnly: true })
  deleted_at DateTime? @db.Timestamptz(6)

  @@map("league_partners")
}

model Cart {
  /// @Validator.IsUUID('4')
  id String @id @default(uuid()) @db.Uuid

  /// @Validator.IsUUID()
  /// @Validator.IsNotEmpty()
  /// @Validator.IsOptional()
  reference_user_id String? @db.Uuid

  /// @Validator.IsUUID()
  /// @Validator.IsNotEmpty()
  /// @Validator.IsOptional()
  reference_order_id String? @db.Uuid

  /// @Validator.IsUUID()
  /// @Validator.IsNotEmpty()
  /// @Validator.IsOptional()
  event_id String? @db.Uuid

  /// @Validator.IsUUID()
  /// @Validator.IsNotEmpty()
  /// @Validator.IsOptional()
  payment_id String? @db.Uuid

  /// @Validator.IsString()
  /// @Validator.MaxLength(50)
  /// @Validator.IsNotEmpty()
  /// @HideField({ output: false, input: true })
  payment_method_id String? @db.VarChar(50)

  /// @Validator.IsString()
  /// @Validator.MinLength(8)
  /// @Validator.MaxLength(20)
  /// @BrazilianValidator.IsCPFOrCNPJ()
  /// @Validator.IsNotEmpty()
  /// @Validator.IsOptional()
  user_document_number String? @db.VarChar(20)

  /// @Validator.IsNotEmpty()
  /// @Validator.IsOptional()
  enumerateds Json? @db.Json

  /// @Validator.IsNotEmpty()
  /// @Validator.IsOptional()
  bleachers Json? @db.Json

  /// @Validator.IsPositive()
  /// @FieldType('Scalars.GraphQLBigInt')
  total_price BigInt @db.BigInt

  /// @HideField({ match: '{CartUncheckedCreateInput,CartUncheckedUpdateInput}' })
  /// @Transformer.Transform(({ value }) => new Date(value), { toClassOnly: true })
  expires_in DateTime @db.Timestamptz(6)

  /// @HideField({ output: false, input: true })
  /// @Transformer.Transform(({ value }) => new Date(value), { toClassOnly: true })
  rejected_at DateTime? @db.Timestamptz(6)

  /// @HideField({ output: false, input: true })
  /// @Transformer.Transform(({ value }) => new Date(value), { toClassOnly: true })
  expired_at DateTime? @db.Timestamptz(6)

  /// @HideField({ output: false, input: true })
  /// @Transformer.Transform(({ value }) => new Date(value), { toClassOnly: true })
  approved_at DateTime? @db.Timestamptz(6)

  /// @HideField({ output: false, input: true })
  /// @Transformer.Transform(({ value }) => new Date(value), { toClassOnly: true })
  canceled_at DateTime? @db.Timestamptz(6)

  /// @HideField({ output: false, input: true })
  /// @Transformer.Transform(({ value }) => new Date(value), { toClassOnly: true })
  created_at DateTime @default(now()) @db.Timestamptz(6)

  /// @HideField({ output: false, input: true })
  /// @Transformer.Transform(({ value }) => new Date(value), { toClassOnly: true })
  updated_at DateTime @default(now()) @updatedAt @db.Timestamptz(6)

  /// @HideField({ output: false, input: true })
  /// @Transformer.Transform(({ value }) => (value ? new Date(value) : null), { toClassOnly: true })
  deleted_at DateTime? @db.Timestamptz(6)

  @@map("carts")
}


KozielGPC avatar May 09 '23 17:05 KozielGPC

Sorry, but I cant reproduce it on my dev environment. I got generated: @generated/cart/cart-aggregate.args.ts @generated/league-partner/league-partner-aggregate.args.ts

import { Field } from '@nestjs/graphql';
import { ArgsType } from '@nestjs/graphql';
import { LeaguePartnerWhereInput } from './league-partner-where.input';
import { Type } from 'class-transformer';
import { LeaguePartnerOrderByWithRelationAndSearchRelevanceInput } from './league-partner-order-by-with-relation-and-search-relevance.input';
import { LeaguePartnerWhereUniqueInput } from './league-partner-where-unique.input';
import { Int } from '@nestjs/graphql';
import { LeaguePartnerCountAggregateInput } from './league-partner-count-aggregate.input';
import { LeaguePartnerAvgAggregateInput } from './league-partner-avg-aggregate.input';
import { LeaguePartnerSumAggregateInput } from './league-partner-sum-aggregate.input';
import { LeaguePartnerMinAggregateInput } from './league-partner-min-aggregate.input';
import { LeaguePartnerMaxAggregateInput } from './league-partner-max-aggregate.input';

@ArgsType()
export class LeaguePartnerAggregateArgs {
  @Field(() => LeaguePartnerWhereInput, { nullable: true })
  @Type(() => LeaguePartnerWhereInput)
  where?: LeaguePartnerWhereInput;

  @Field(() => [LeaguePartnerOrderByWithRelationAndSearchRelevanceInput], {
    nullable: true,
  })
  orderBy?: Array<LeaguePartnerOrderByWithRelationAndSearchRelevanceInput>;

  @Field(() => LeaguePartnerWhereUniqueInput, { nullable: true })
  cursor?: LeaguePartnerWhereUniqueInput;

  @Field(() => Int, { nullable: true })
  take?: number;

  @Field(() => Int, { nullable: true })
  skip?: number;

  @Field(() => LeaguePartnerCountAggregateInput, { nullable: true })
  _count?: LeaguePartnerCountAggregateInput;

  @Field(() => LeaguePartnerAvgAggregateInput, { nullable: true })
  _avg?: LeaguePartnerAvgAggregateInput;

  @Field(() => LeaguePartnerSumAggregateInput, { nullable: true })
  _sum?: LeaguePartnerSumAggregateInput;

  @Field(() => LeaguePartnerMinAggregateInput, { nullable: true })
  _min?: LeaguePartnerMinAggregateInput;

  @Field(() => LeaguePartnerMaxAggregateInput, { nullable: true })
  _max?: LeaguePartnerMaxAggregateInput;
}

unlight avatar May 09 '23 17:05 unlight

That is weird.... The only aggregate file that is generated for me is the this one

image

image

KozielGPC avatar May 09 '23 17:05 KozielGPC