Fields missing in "input" if there is a relation
I am missing fields if there is a relation based on those. E.g.:
model customerTest {
id Int @id @default(autoincrement()) @db.UnsignedInt
/// @Validator.IsInt()
posId Int @db.UnsignedTinyInt
posRelation posSettings @relation(fields: [posId], references: [id])
}
Will result in "customer-test-create.input.ts":
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { posSettingsCreateNestedOneWithoutCustomerTestInput } from '../../pos-settings/inputs/pos-settings-create-nested-one-without-customer-test.input';
import { Type } from 'class-transformer';
@InputType()
export class customerTestCreateInput {
@Field(() => posSettingsCreateNestedOneWithoutCustomerTestInput, {nullable:false})
@Type(() => posSettingsCreateNestedOneWithoutCustomerTestInput)
posRelation!: posSettingsCreateNestedOneWithoutCustomerTestInput;
}
Which makes it impossible to set the "posId" directly.
Same type generated by prisma (without id). You can:
- Remove
@default(autoincrement())fromcustomerTest - Use
customerTestUncheckedCreateInputinstead
Hi, thanks for your hint. "customerTestUncheckedCreateInput" does the job. "@default(autoincrement())" has no input on posId. I could not find anything about these "*Unchecked" args in the prisma documentation, whats the idea behind? Is there any kind of rule when to use it?
I'm facing the same issue below is my prisma model model User { id Int @id @unique @default(autoincrement())
/// @Validator.IsEmail() email String @unique
/// @Validator.IsString() /// @Validator.MaxLength(100) /// @Validator.MinLength(3) name String? posts post[] }
model post { id Int @id @unique
/// @Validator.IsString() /// @Validator.MaxLength(1000) description String?
user User @relation(fields: [userId], references: [id])
userId Int @default(0)// relation scalar field (used in the @relation attribute above)
}
And this is how my types and mutation looks
input postCreateInput { id: Int! description: String user: UserCreateNestedOneWithoutPostsInput }
mutation addPost($data: postCreateInput!){ createPost(data: $data) { description userId user { name email } } } { "data": { "id": 1, "description": "testing the first input", "userId" : 1 } }
Error : "message": "Variable "$data" got invalid value { description: "testing the first input", userId: 1 }; Field "id" of required type "Int!" was not provided.",
Same type generated by prisma (without id). You can:
1. Remove `@default(autoincrement())` from `customerTest` 2. Use `customerTestUncheckedCreateInput` instead
Doesn't work for me