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

Support options for scalar list fields

Open nick-allen opened this issue 1 year ago • 1 comments

https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/working-with-scalar-lists-arrays#setting-the-value-of-a-scalar-list

Using a scalar list in postgres leads to generated type requiring a set field, should support direct setting as outlined in linked doc.

Example model with output types

model Task {
  ...
  categories  String[]
  ...
}
@InputType()
export class TaskCreateInput {

    ...

    @Field(() => TaskCreatecategoriesInput, {nullable:true})
    categories?: TaskCreatecategoriesInput;

    ...

}

@InputType()
export class TaskCreatecategoriesInput {

    @Field(() => [String], {nullable:false})
    set!: Array<string>;
}

This leads to requiring inputs always use the set: [...] form, and prevents being able to set the value directly, or use unset: true.

nick-allen avatar Aug 05 '24 03:08 nick-allen

I did not get. You are referencing to postgres, but documentation says that unset is supported by MongoDB only

unlight avatar Jan 26 '25 08:01 unlight