首页 > 解决方案 > 在 prisma 中表示没有 id 的类型的最佳方法是什么?

问题描述

数据模型.graphql

type Data {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  points:[Point!]!
}

type Point {
 x:Float!
 y:Float!
}

生成的类型(prisma.graphql):

type Data implements Node {
  id: ID!
  points(where: PointWhereInput, orderBy: PointOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Point!]
}

在我的数据模型points中是必填字段,但在生成的棱镜类型points中是可选的?当我更新我的数据点时,以前的数据也会出现结果(https://github.com/prisma/prisma/issues/1657)..

我看到的解决方法是Json,但我们在 codegen 和 graphiql 中失去了类型安全性:(,

默认情况下, prisma 是否会在type没有id字段的情况下作为 Json 处理......?

标签: graphqlprisma

解决方案


推荐阅读