Add an element in an Enum array


#1

Hi everybody,
I have the following User schema :

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

enum Role {
  ADMIN
}

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: {
          roles
        },
        where: {
          id
        }
      });
    }

When I’m trying this request :

mutation {
  addRoles(
    userId: "cjxow80vs00060703wzo20te2"
    roles: [ ADMIN ]
  ) {
    roles
  }
}

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!