Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

omitModelsCount param is not working as expected #199

Open
bmajkut opened this issue Nov 24, 2023 · 3 comments
Open

omitModelsCount param is not working as expected #199

bmajkut opened this issue Nov 24, 2023 · 3 comments

Comments

@bmajkut
Copy link

bmajkut commented Nov 24, 2023

Hi,
I have such simple Prisma shema (I set omitModelsCount=true)

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["postgresqlExtensions"]
}

generator nestgraphql {
    provider = "node node_modules/prisma-nestjs-graphql"
    output = "../src/@generated"
    noTypeId = true
    omitModelsCount=true
    fields_Scalars_from = "graphql-scalars"
    graphqlScalars_BigInt_name = "GraphQLBigInt"
    graphqlScalars_BigInt_specifier = "graphql-scalars"
    fields_Scalars_input=true
    fields_Scalars_output=true
    requireSingleFieldsInWhereUniqueInput=true
    emitSingle=true
    // purgeOutput=true
    reExport=true
}

datasource db {
  provider   = "postgresql"
  url        = env("DATABASE_URL")
  extensions = [citext, pgcrypto]
}

model City {
  id BigInt @id @default(autoincrement())

  value      String    @unique()
  createdAt  DateTime  @default(now())
  updatedAt  DateTime  @updatedAt
  archivedAt DateTime?

  addresses Address[]
}

model Address {
  id BigInt @id @default(autoincrement())

  zipCode     String @default("")
  building    String @default("")
  houseNumber String @default("")

  street   Street? @relation(fields: [streetId], references: [id])
  streetId BigInt?

  city   City?   @relation(fields: [cityId], references: [id])
  cityId BigInt?

  province   Provice? @relation(fields: [provinceId], references: [id])
  provinceId BigInt?

  country   Country? @relation(fields: [countryId], references: [id])
  countryId BigInt?

  documents Document[]
  obligorFiles ObligorFile[]

  createdAt  DateTime  @default(now())
  updatedAt  DateTime  @updatedAt
  archivedAt DateTime?
}

when I use prisma-nestjs-graphql generator I am getting:

@ObjectType()
export class City {
    @Field(() => GraphQLBigInt, {nullable:false})
    id!: bigint;
    @Field(() => String, {nullable:false})
    value!: string;
    @Field(() => Date, {nullable:false})
    createdAt!: Date;
    @Field(() => Date, {nullable:false})
    updatedAt!: Date;
    @Field(() => Date, {nullable:true})
    archivedAt!: Date | null;
    @Field(() => [Address], {nullable:true})
    addresses?: Array<Address>;
    @Field(() => CityCount, {nullable:false})
    _count?: InstanceType<typeof CityCount>;
}

Why Am I still getting field _count as non-nullable in Graphql?

It is a source of multiple errors on the consumer side that the types are incompatible between each other:

The types of 'document.address.city' are incompatible between these types.
      Property '_count' is missing in type '{ __typename?: "City"; id: any; value: string; createdAt: any; updatedAt: any; archivedAt?: any; }' but required in type 'City'
``

I would appreciate any hint how to deal with that. Thank You in advance.
@nextor2k
Copy link

@unlight any update on that issue?

@unlight
Copy link
Owner

unlight commented Jan 17, 2024

I did not check it yet

@nextor2k
Copy link

Updated to the latest version, and it's working fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants