Cant update 1-to-1 association

I have the following types and schema to have a 1-to-1 association between an AccessConfig node and a Permissions node:

type AccessConfig {
  delegate: bool
  delegateTo: uid
  finDelegatedTo: uid
  permissions: Persmissions
}

type Persmissions {
  publicRead: bool
  publicWrite: bool
}

permissions: uid .

I can create the AccessConfig node and set the Permissions with

_:accessConfig <permissions> <0x...> .

but when I try to update the Permissions reference to another Permissions node with the triad

<0x(access config uid)> <permissions> <0x(new permissions node uid)> .

I get the following error:

"2 UNKNOWN: cannot add value with uid 0x(new permissions node uid) to predicate permissions because one of the existing values does not match this uid, either delete the existing values first or modify the schema to 'permissions: [uid]'"
    }

I don’t understand the error. Updating the existing value with the new one without having an array if [uid] is precisely what I want.

You can recreate the error installing and running npm test of this branch
https://github.com/uprtcl/js-uprtcl-server/tree/dgraph-issue

What is this? is it from a variable? share the complete context. The whole query and maybe some samples.

That one is the whole mutation that fails.

<0x(access config uid)> is not that but a real uid. I thought that it was better to clarify which was the object it refererd to and not the actual value that changes at every test like 0x215e2

I just realized that this is the same issue of Unexpected bahaviour when mutating 1-to-1 relations - #12 by martinmr

Please, just read it.

1 Like