部署运行pyramida后,程序会弹出此->(@scalarList的strategy参数的有效值为:RELATION。)。有人知道为什么吗?

type User {
  id: ID! @id
  name: String!
  email: String! @unique
  password: String!
  age: Int
  img: String
  location: Location
  hostedEvents: [Event]! @relation(name: "HostedEvents", onDelete: CASCADE)
  joinedEvents: [Event]! @relation(name: "EventMembers", onDelete: CASCADE)
  pushNotificationTokens: [PushNotificationTokens]!
  createdAt: DateTime! @createdAt
  updatedAt: DateTime! @updatedAt
}
type Event {
  id: ID! @id
  owner: User! @relation(name: "HostedEvents")
  name: String!
  imgs: [String]!
  description: String
  start: DateTime!
  end: DateTime!
  categories: [Category]!
  members: [User]! @relation(name: "EventMembers")
  chatRoom: GroupChatRoom!
  pendingRequests: [PendingRequest]!
  locations: [Location]!
  comments: [Comment]!
  createdAt: DateTime! @createdAt
  updatedAt: DateTime! @updatedAt
}

最佳答案

根据文档,当我们需要将字段创建为数组或列表时,需要使用指令 @scalarlist 指令,在您的情况下,正确的模型定义应使用表/列 imgs

type Event {
  id: ID! @id
  owner: User! @relation(name: "HostedEvents")
  name: String!
  imgs: [String!]! @scalarList(strategy: RELATION)
  description: String
  start: DateTime!
  end: DateTime!
  categories: [Category]!
  members: [User]! @relation(name: "EventMembers")
  chatRoom: GroupChatRoom!
  pendingRequests: [PendingRequest]!
  locations: [Location]!
  comments: [Comment]!
  createdAt: DateTime! @createdAt
  updatedAt: DateTime! @updatedAt
}

文件连结-> https://www.prisma.io/docs/datamodel-and-migrations/datamodel-MYSQL-knul/#@scalarlist

关于graphql - 错误: Valid values for the strategy argument of `@scalarList` are: RELATION,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56106736/

10-12 13:07