Prisma1: scalarLists are always asking for RELATION as the strategy

Created on 21 Apr 2019  Â·  9Comments  Â·  Source: prisma/prisma1

Describe the bug
If you try to deploy a datamodel with a scalarList, it is always asking for the RELATION strategy and you are unable to use EMBEDDED strategy even if explicitly specified.

image

To Reproduce
Steps to reproduce the behavior:
Try to deploy the following datamodels:

type User {
  id: ID! @id
  name: String!
  test: [String!]!
}
type User {
  id: ID! @id
  name: String!
  test: [String!]! @scalarList(strategy: EMBEDDED)
}

Expected behavior
Scalar List should use EMBEDDED as the default. IT should also be allowed explicitly.

Versions (please complete the following information):

  • Connector: Postgres
  • Prisma Server: 1.31.1
  • prisma CLI: 1.31.1
  • OS: OSX 10.14.3 Mojave
kinquestion aredatamodel areserver

Most helpful comment

Hi there, I used to define a enum type in my datamodel.prisma file

enum Permission {
  ADMIN
  USER
  ITEMCREATE
  ITEMUPDATE
  ITEMDELETE
  PERMISSIONUPDATE
}

and use this in another type

type User {
  ... # other fileds
  permissions: [Permission!]!
}

It works fine for me until today, when I define another type and deploy it to prisma demo server, it says

Errors:

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

I thought there was something wrong with the new type but finally after I read this issue, I realize [Permission!]! is kinda like [String!]! so I should add @scalarList(strategy: RELATION)after it.

And now everything works fine again. Thank u very much!

My question is, I have googled and looked up in prisma docs, I can't find any explaination or document about @scalarList. Is this something new? What is the difference between RELATION and EMBEDDED?

All 9 comments

Update: This is intended. We only support the strategy RELATION as of now for our SQL connectors. The plan is to enable EMBEDDED at a later point. We force the user to provide the strategy explicitly here because embedded will be the default and like this it is backwards compatible.

Hi there, I used to define a enum type in my datamodel.prisma file

enum Permission {
  ADMIN
  USER
  ITEMCREATE
  ITEMUPDATE
  ITEMDELETE
  PERMISSIONUPDATE
}

and use this in another type

type User {
  ... # other fileds
  permissions: [Permission!]!
}

It works fine for me until today, when I define another type and deploy it to prisma demo server, it says

Errors:

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

I thought there was something wrong with the new type but finally after I read this issue, I realize [Permission!]! is kinda like [String!]! so I should add @scalarList(strategy: RELATION)after it.

And now everything works fine again. Thank u very much!

My question is, I have googled and looked up in prisma docs, I can't find any explaination or document about @scalarList. Is this something new? What is the difference between RELATION and EMBEDDED?

@WispAmulet you can read about @scalarList here: https://github.com/prisma/prisma/issues/3403

While adding @scalarList(strategy: RELATION) will allow you to deploy your schema, i.e. from:

enum Permission { USER ADMIN }

type User { permissions: [Permission] }

to:

type User { permissions: [Permission] @scalarList(strategy: RELATION) }

the new data model prevents users from setting values for their enums - both within their prisma admin and within their gql mutation resolvers:

For example the old data model allowed users to set enums in prisma admin like so.

Empty Permissions Item:
Screenshot 2019-04-28 at 16 12 13

Add A New Value:
Screenshot 2019-04-28 at 16 12 34

Select A Value:
Screenshot 2019-04-28 at 16 16 12

New Permissions (Not Yet Saved)
Screenshot 2019-04-28 at 16 12 48

Save To Database:
Screenshot 2019-04-28 at 16 12 58

New Permissions (Saved To Database)
Screenshot 2019-04-28 at 16 13 08

Whereas the mutation resolver used to allow users to set enum values like so

Screenshot 2019-04-28 at 16 22 06

Following the transition to the new data model, how does one go about setting the values of enums within their prisma admin or mutation resolver?

Is there any documentation about @scalarList? Maybe I'm missing it but I can't find anything. This isn't the first time I've come across undocumented changes in Prisma that stop me in my tracks. I get that you're moving fast and things are constantly improving but it'd be great if you could document these things. I only updated to the latest version to try Prisma Admin. Thanks in advance.

Update: In the Prisma Slack I was given the following advice, which seemed to work:

I think if you add @scalarList(strategy: RELATION) to your arrays that might fix it.

Update: In the Prisma Slack I was given the following advice, which seemed to work:

I think if you add @scalarList(strategy: RELATION) to your arrays that might fix it.

Hi Darryl - is your parent type using Int as @ id? If so you might be able to deploy with the above, but are unable to update your scalarLsits... There is a related bug here - 4421.

For the time being I replaced the scalarLists in my data model with strings and am handling the logic on the backend to save the correct selection(s).

Hi, @nickyrush.

is your parent type using Int as @ id?

In this particular case, the parent type is using id: ID! @id. Up until updating Prisma this morning, it was id: ID! @unique. I haven't touched Prisma for a bit so likely need to dig around and find some updated documentation. Thanks for sharing the link to that bug.

Closing in favour of #4456

Is there any documentation about @scalarList? Maybe I'm missing it but I can't find anything. This isn't the first time I've come across undocumented changes in Prisma that stop me in my tracks. I get that you're moving fast and things are constantly improving but it'd be great if you could document these things. I only updated to the latest version to try Prisma Admin. Thanks in advance.

Update: In the Prisma Slack I was given the following advice, which seemed to work:

I think if you add @scalarList(strategy: RELATION) to your arrays that might fix it.

+1 to this. What does relation mean in the context of SQL DBs? Does it create a new table for the scalar list field?

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marktani picture marktani  Â·  71Comments

sorenbs picture sorenbs  Â·  52Comments

marktani picture marktani  Â·  71Comments

marktani picture marktani  Â·  44Comments

marticrespi picture marticrespi  Â·  34Comments