@fletcherist I checked what you suggested and finally understood my problem, which is different from yours.
My api.Mutation.DeleteJson was set to the string null instead of the nil value, which seemed to be ignored in dgraph <= v20 but fails with dgraph >= v21.
The problem is I am wrapping my set and delete json values in interfaces (due to function arguments), and thus when my delModel is nil, testing delModel == nil fails and then I marshal the value to "null":
if delModel != nil {
delData, err = jsoniter.Marshal(delModel)
if err != nil {
return nil, err
}
}
mutation := &api.Mutation{
SetJson: setData,
DeleteJson: delData,
}
Here delData is "null".
I fixed it with reflection:
if !IsNil(delModel) {
delData, err = jsoniter.Marshal(delModel)
if err != nil {
return nil, err
}
}
[...]
func IsNil(i interface{}) bool {
if i == nil {
return true
}
switch reflect.TypeOf(i).Kind() {
case reflect.Ptr, reflect.Map, reflect.Array, reflect.Chan, reflect.Slice:
return reflect.ValueOf(i).IsNil()
}
return false
}
Now delData is nil.
This might be a breaking change worth a mention in the changelog.