我正在为 Prisma 服务器生成一个数据模型,使用graphql-cli
. 但是,graphql-cli
在没有的情况下继续生成 id 属性@unique
,当我将其部署到 prisma 演示服务器时出现此错误。
该字段
id
是保留的,必须具有以下格式:id:ID!@独特的。
所以我的问题是如何让 graph-cli 生成@unique?
我的 prisma.graphql(aka datamodel.graphql) 有
type Comment implements Node {
id: ID!
content: String!
userIdCommenBy: String!
videoId: String!
createdTime: String!
}
这种类型应该是
type Comment implements Node {
id: ID! @unique
content: String!
userIdCommenBy: String!
videoId: String!
createdTime: String!
}
架构.graphql
type Query {
feeds: [Video]
users: [User]
user: User
videos: [Video]
video: Video
comments: [Comment]
comment: Comment
questions: [Question]
question: Question
}
type Mutation {
addUser(id: ID, firstName: String, lastName: String, companyId: String): User
addComment(id: ID, content: String, userIdCommenBy: String): Comment
addQuestion(id: ID, title: String, userIdAsekedBy: String, isAnonymous: String): Question
}
type User {
id: ID
email: String
password: String
firstName: String
lastName: String
companyId: String
createdTime: String
}
type Video {
id: ID
questionId: String
imgUrl: String
videoUrl: String
views: Int
likes: Int
isPrivate: Boolean
comments: [Comment]
createdTime: String
}
type Comment {
id: ID
content: String
userIdCommenBy: String
videoId: String
createdTime: String
}
type Question {
id: ID
title: String
userIdAsekedBy: String
isAnonymous: Boolean
countSkipped: Int
views: Int
createdTime: String
}
type Notification {
isRead: Boolean
isHidden: Boolean
senderId: String
recipientId: String
typeOfNotification: String
createdTime: String
}
.graphqlconfig.yml
projects:
app:
schemPath: src/schema.graphql
extensions:
endpoints:
default: ${env:API_ENDPOINT}
prisma:
schemaPath: src/prisma/prisma.graphql
extensions:
prisma: src/prisma/prisma.yml
我运行的命令
graphql get-schema --project prisma --dotenv .env.dev
谢谢!