Prisma 部署:需要 enums/expecting 接口、指令或定义的关系

Prisma deploy: relations are expected for enums/expecting an interface, directive or definition

我正在尝试部署更新后的 datamodel.prisma 文件。但是,发生错误,据我所知,它认为我正在尝试在上面定义的枚举与 User 类型之间建立关系。

这是我的文件:

enum Permission {
  ADMIN
  USER
  ITEMCREATE
  ITEMUPDATE
  ITEMDELETE
  PERMISSIONUPDATE
}

type User {
  id: ID! @id
  name: String!
  email: String! @unique
  password: String!
  resetToken: String
  resetTokenExpiry: String
  permissions: [Permission]
}

type Item {
  id: ID! @id
  title: String!
  description: String!
  image: String
  largeImage: String
  price: Int!
  createdAt: DateTime! @createdAt
  updatedAt: DateTime! @updatedAt
}

运行 prisma deploy --env-file variables.env 给我以下错误:

Errors:

  User
    ✖ Valid values for the strategy argument of `@scalarList` are: RELATION.

如果我将 permissions: [Permission] 更改为 permissions: Permission[],它会给出此错误(具体来说,expected ImplementsInterfaces, DirectivesConst or FieldDefinitions):

ERROR: Syntax error while parsing GraphQL query. Invalid input "{\n  id: ID! @id\n  name: String!\n  email: String! @unique\n  password: String!\n  resetToken: String\n  resetTokenExpiry: String\n  permissions: Permission[", expected ImplementsInterfaces, DirectivesConst or FieldDefinitions (line 10, column 11):
type User {
          ^

{
  "data": {
    "deploy": null
  },
  "errors": [
    {
      "locations": [
        {
          "line": 2,
          "column": 9
        }
      ],
      "path": [
        "deploy"
      ],
      "code": 3017,
      "message": "Syntax error while parsing GraphQL query. Invalid input \"{\n  id: ID! @id\n  name: String!\n  email: String! @unique\n  password: String!\n  resetToken: String\n  resetTokenExpiry: String\n  permissions: Permission[\", expected ImplementsInterfaces, DirectivesConst or FieldDefinitions (line 10, column 11):\ntype User {\n          ^",
      "requestId": "us1:ck6au2sum8frx0b00fviv1dom"
    }
  ],
  "status": 200
}

我不确定该错误是什么意思,但我确实感觉它不理解电子邮件字段中的 @unique 类型修饰符。它以前不存在并且部署工作正常。非常感谢任何帮助!

您需要指定策略和@scalarList 指令。

This @scalarList(strategy: STRATEGY!) directive is required on any scalar list field. The only valid argument for the strategy argument is RELATION.

type Post {
  tags: [String!]! @scalarList(strategy: RELATION)
}

所有标量和枚举列表字段都需要它。

参见:https://www.prisma.io/docs/datamodel-and-migrations/datamodel-MYSQL-knul/#@scalarlist