错误:“ @ scalarList”的策略参数的有效值为:RELATION

时间:2019-05-13 06:23:07

标签: graphql prisma prisma-graphql

程序弹出运行->(运行{1}的策略参数的有效值为RELATION。)。有人知道为什么吗?

@scalarList
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
}

1 个答案:

答案 0 :(得分:0)

根据文档,当我们需要将Fields创建为Array或List时,需要使用 @scalarlist 指令,在您的情况下,正确的模型定义应该在表/列 < em> 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

相关问题