Add an element in an Enum array


Hi everybody,
I have the following User schema :

type User {
  id: ID! @id
  roles: [Role!]! @scalarList(strategy: RELATION)

enum Role {

With a GraphQL API, I want to be able to add new roles to my user. So I created the following resolver :

    addRoles(_, { id, roles }, { prisma }) {
      return prisma.updateUser({
        data: {
        where: {

When I’m trying this request :

mutation {
    userId: "cjxow80vs00060703wzo20te2"
    roles: [ ADMIN ]
  ) {

I get the following error message :

"Variable '$data' expected value of type 'UserUpdateInput!' but got: {\"roles\":[\"ADMIN\"]}. Reason: 'roles' Expected 'UserUpdaterolesInput', found not an object. (line 1, column 11):\nmutation ($data: UserUpdateInput!, $where: UserWhereUniqueInput!) {\n          ^"

What does this message mean? How can I create my resolver to add (not to replace) new roles to my users?

Thanks for your help!


This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.