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

Generate _count as always nullable:true

Open Johann01 opened this issue 2 years ago • 7 comments

Is it possible to generate the _count property as always { nullable:true }? I couldn't find the generator option to do that.

Johann01 avatar Aug 05 '22 14:08 Johann01

There is no such option.

For what kind of generated class it should be null (model, input)? What is corresponding prisma expression which returns null instead of number?

unlight avatar Aug 05 '22 15:08 unlight

Ref: #84

unlight avatar Aug 05 '22 16:08 unlight

The problem with the _count property is, that it is automatically generated per default as nullable: false, but the default way of using prisma doesn't include the _count property meaning I always have to include it, which is counterintuitive to using prisma.

Johann01 avatar Aug 06 '22 06:08 Johann01

I dont understand the problem. If you have graphql client error about count property, it means that you must provide it. Using prisma for getting count is not supposing to return null.

unlight avatar Aug 06 '22 12:08 unlight

How can i delete this field?, since this field its not in the type definition on the prisma client type as a part of the model.

denes16 avatar Dec 28 '22 01:12 denes16

@denes16 Since v17.1.0 you can hide field in graphql schema using configuration:

  decorate_1_type = "ArticleCount" // outmatch pattern for graphql type
  decorate_1_field = "_count"
  decorate_1_name = "HideField"
  decorate_1_from = "@nestjs/graphql"
  decorate_1_arguments = "[]"

See https://github.com/unlight/prisma-nestjs-graphql#decorate

unlight avatar Dec 31 '22 15:12 unlight

how to delete this field from generation or how can I add isAbstract in every @ObjectType({ isAbstract: true })

0-don avatar Apr 02 '23 23:04 0-don