Search code examples
graphqlprismaprisma-graphql

Error: Valid values for the strategy argument of `@scalarList` are: RELATION


Program pops up this -> (Valid values for the strategy argument of @scalarList are: RELATION.) after run prisma deploy. Any one knows why ?

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
}

Solution

  • According with docs, when we need to create Fields as Array or List, the directive @scalarlist directive is required, in your case the correct model definition should be with the table/column 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
    }
    

    Docs link -> https://www.prisma.io/docs/datamodel-and-migrations/datamodel-MYSQL-knul/#@scalarlist