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: https://github.com/dgraph-io/dgraph/issues/4879

This PR fixes this issue: https://github.com/dgraph-io/dgraph/pull/4883
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.