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

relation filter is not created #213

Open
apss-pohl opened this issue May 2, 2024 · 2 comments
Open

relation filter is not created #213

apss-pohl opened this issue May 2, 2024 · 2 comments

Comments

@apss-pohl
Copy link

apss-pohl commented May 2, 2024

Given this models:

generator client {
  provider        = "prisma-client-js"
  binaryTargets   = ["native", "darwin", "debian-openssl-1.1.x", "linux-musl", "windows"]
  output          = "./dist"
  previewFeatures = ["fullTextSearch", "fullTextIndex"]
}

// configService.get<any>('internal.config.mainDatabaseUrl')
datasource db {
  provider = "mysql"
  url      = env("APP_MAIN_DATABASE_URL")
}

generator nestgraphql {
  provider             = "prisma-nestjs-graphql"
  output               = "../src/@generated"
  outputFilePattern    = "{model}/{plural.type}/{name}.{type}.ts"
  prismaClientImport   = "@m/../prisma/dist"
  combineScalarFilters = false
  noAtomicOperations   = false
  noTypeId             = true
}

model checkin {
  id     Int   @id @default(autoincrement()) @db.UnsignedInt
  areaId Int?  @db.UnsignedSmallInt
  area   area? @relation("checkinRelation", fields: [areaId], references: [id])

  @@map("karena_checkin")
}

model area {
  id      Int       @id @default(autoincrement()) @db.UnsignedSmallInt
  checkin checkin[] @relation("checkinRelation")
}

The generated file:

../../prisma/inputs/area-relation-filter.input

is empty but is needed by

checkin/inputs/checkin-where-unique.input.ts

import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { Int } from '@nestjs/graphql';
import { checkinWhereInput } from './checkin-where.input';
import { IntNullableFilter } from '../../prisma/inputs/int-nullable-filter.input';
import { AreaNullableRelationFilter } from '../../prisma/inputs/area-nullable-relation-filter.input'; // <---- This file is created but empty

@InputType()
export class checkinWhereUniqueInput {

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

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

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

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

    @Field(() => IntNullableFilter, {nullable:true})
    areaId?: IntNullableFilter;

    @Field(() => AreaNullableRelationFilter, {nullable:true})
    area?: AreaNullableRelationFilter;
}

Current versions of prisma and prisma-nestjs-graphql are used

@Mario2280
Copy link

Mario2280 commented May 10, 2024

@unlight I also want to add to this issue. previewFeatures = ["relationJoins"] doesn't work either. I'm faced with passing a graphql "include" prisma field. But it is not generated. This is a big drawback of this package that cuts off a large piece of prisma functionality in filtering nested fields

@ArgsType()
export class FindManyOrderArgs {
    @Field(() => OrderWhereInput, {nullable:true})
    @Type(() => OrderWhereInput)
    where?: InstanceType<typeof OrderWhereInput>;
    @Field(() => [OrderOrderByWithRelationInput], {nullable:true})
    orderBy?: Array<OrderOrderByWithRelationInput>;
    @Field(() => OrderWhereUniqueInput, {nullable:true})
    cursor?: Prisma.AtLeast<OrderWhereUniqueInput, 'id'>;
    @Field(() => Int, {nullable:true})
    take?: number;
    @Field(() => Int, {nullable:true})
    skip?: number;
    @Field(() => [OrderScalarFieldEnum], {nullable:true})
    distinct?: Array<keyof typeof OrderScalarFieldEnum>;
    @Field(() => RelationLoadStrategy, {nullable:true})
    relationLoadStrategy?: keyof typeof RelationLoadStrategy;
}

, I had to enter it manually.

@Query(() => [Order], { nullable: false })
 listsOrder(@Args() args: FindManyOrderArgs) {
   return this.orderService.findMany({
     ...args,
     include: {
       client: true,
     }
   })
 }

Here is my config:

generator nestgraphql {
  provider                              = "node node_modules/prisma-nestjs-graphql"
  output                                = "../src/dtos"
  fields_Validator_from                 = "class-validator"
  fields_Validator_input                = true
  requireSingleFieldsInWhereUniqueInput = true
  emitSingle                            = true
  emitCompiled                          = false
  purgeOutput                           = true
  noTypeId                              = true
  previewFeatures                       = ["relationJoins"]
}

@apss-pohl
Copy link
Author

i figured out in the meantime that the relation filter is not generated because "areaId" is optional. However AreaNullableRelationFilter must be generated

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

2 participants