Skip to content

set in nested writes for one to many relationship has incorrect field types #474

@valerii15298

Description

@valerii15298

Describe the Bug
When trying to set(https://www.prisma.io/docs/orm/reference/prisma-client-reference#set) posts of the user via generated graphql, schema has invalid types for fields in set

To Reproduce
Imagine this schema:

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

generator typegraphql {
  provider = "typegraphql-prisma"
}

model User {
 id Int     @id @default(autoincrement())
 name String

 posts Post[]
}

model Post {
 id Int     @id @default(autoincrement())
 name String
 user   User @relation(fields: [userId], references: [id])
 userId Int
}

then with prisma you can do something like this:

prisma.user.update({
  where: { id: 1 },
  data: { posts: { set: [{ id: 1, name: "hello" }, { name: "world" }] } },
});

But typegraphql prisma generates graphql schema so that query looks like this:

mutation {
  updateOneUser(
    where: {id: 1}
    data: {posts: {set: [{name: {equals: "why operators here???"}}]}}
  ) {
    id
  }
}

Which is not logical at all. name property should be just a string and not a object with operators from where clause.

Expected Behavior
properties inside set should be raw values and not objects with operators properties

Environment (please complete the following information):

  • typegraphql-prisma version 0.28.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions