【问题标题】:Error: Valid values for the strategy argument of `@scalarList` are: RELATION错误:`@scalarList` 的策略参数的有效值为:RELATION
【发布时间】:2019-09-30 01:59:21
【问题描述】:

程序会弹出这个 -> (@scalarList 的策略参数的有效值为:RELATION。)在运行 prisma deploy 之后。有谁知道为什么?

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
}

【问题讨论】:

    标签: graphql prisma prisma-graphql


    【解决方案1】:

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

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-13
      • 1970-01-01
      • 2018-05-22
      • 1970-01-01
      • 2021-01-01
      • 2023-04-05
      • 1970-01-01
      相关资源
      最近更新 更多