Mutation doesn't update value

For example, I have some device with owner:

type  Device {
    uuid: String! @id @search(by: [hash])
    owner: User! @hasInverse(field: devices)
}

type User  {
    uuid: String! @id @search(by: [hash])
    devices: [Device] @hasInverse(field: owner)
}
query {
  queryDevice {
    uuid
    owner {
        uuid
    }
  }
}
{
    "data": {
        "queryDevice": [
            {
                "uuid": "foo",
                "owner": {
                    "uuid": "bar"
                }
            }
        ]
}

I make some mutation and get the result:

mutation {
   updateDevice(input: {
     filter: { uuid: { eq: "foo" }},
     set: { owner: { uuid: "baz" } }
   }) {
     device {
       uuid
       owner {
           uuid
       }
     }
   }
}
{
    "data": {
        "updateDevice": {
            "device": [
                {
                    "uuid": "foo",
                    "owner": {
                        "uuid": "baz"
                    }
                }
            ]
        }
    }
}

Then I want to return back old owner, but mutation doesn’t change it:

mutation {
   updateDevice(input: {
     filter: { uuid: { eq: "foo" }},
     set: { owner: { uuid: "bar" } }
   }) {
     device {
       uuid
       owner {
           uuid
       }
     }
   }
}
{
    "data": {
        "updateDevice": {
            "device": [
                {
                    "uuid": "foo",
                    "owner": {
                        "uuid": "baz"
                    }
                }
            ]
        }
    }
}

Am I doing something wrong?

Hey @poketulhu

Could you please share the GraphQL schema that you are using or atleast the schema for types Device and Owner?

Hi! Added schema for types to question

Filed a bug for this: List value returned for a non-list uid predicate · Issue #4879 · dgraph-io/dgraph · GitHub

This PR fixes this issue: Overwrite values for uid predicates by martinmr · Pull Request #4883 · dgraph-io/dgraph · GitHub
Verified it on my system.

Hi @poketulhu,

The PR with fix for this issue has been merged in latest master branch on GitHub. You can try it out out by building Dgraph from GitHub master or you can wait for the next release which is expected to be out by 17th March.

Great news! Thank you

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