Can I update fields with the @id directive?

Thanks guys! This really helped! :raised_hands: I’ve got the basic example working. Just for completion I will post this here

The User type

type User {
  id: ID!
  email: String! @id
  userName: String
}

The Resolve Function

async function updateUserWithDql({ args, dql }) {
  const update = await dql.mutate(`{
    set {
      <${args.userId}> <User.email> "${args.email}" .
      <${args.userId}> <User.userName> "${args.userName}" .
    }
  }`);
}

This updates all fields fine! Unfortunately, I ran into another problem :see_no_evil: What if I have

enum RoleType {
  "ADMIN"
  "MEMBER"
}

type Role {
  id: ID!
  type: RoleType!
}

type User {
  id: ID!
  email: String! @id
  userName: String
  role: Role
}

I can perform deep mutations with a GraphQL query but it is not clear to me how I do this with DQL? I have read this but I guess I’m using it wrong since I only get errors that my input type uid is a scalar… Could someone explain me what I have to do if I want to update User.role?

Thanks!

1 Like