Data doesn't update

Hi,

I have this data in my db:

"branch": [
        {
          "versions": [
            {
              "wayOfCreation": "New_Branch",
              "code": "1.0",
              "orkId": "0x13882-master-1.0"
            },
            {
              "wayOfCreation": "New_Version",
              "code": "1.1",
              "orkId": "0x13882-master-1.1"
            }
          ]
        }
      ]

I try to update the data using deep update with the following mutation:

mutation MyMutation {
  updateBranch(input: {filter: {orkId: {eq: "0x13882-master"}}, set: {versions: [{orkId: "0x13882-master-1.0", code: "1.2"}, {orkId: "0x13882-master-1.1", wayOfCreation: Publish}]}}) {
    branch {
      versions {
        wayOfCreation
        code
        orkId
      }
    }
  }
}

but the result is:

{
  "data": {
    "updateBranch": {
      "branch": [
        {
          "versions": [
            {
              "wayOfCreation": "New_Branch",
              "code": "1.0",
              "orkId": "0x13882-master-1.0"
            },
            {
              "wayOfCreation": "New_Version",
              "code": "1.1",
              "orkId": "0x13882-master-1.1"
            }
          ]
        }
      ]
    }
  },

Nothing was changed
I tried to follow the example in the docs about the deep update

Hi @spinelsun, can you please share the schema?

Hi @anand

sure:

type Branch {
  orkId: String! @search(by: [hash]) @id
  changeMark: String!
  name: String! @search(by: [exact, regexp])
  versions: [Version!]!
  checkedOutFrom: Version @hasInverse(field: checkouts)
  in: Repository! @hasInverse(field: branches)
  createdAt: DateTime!
  createdBy: User!
}

type Version {
  orkId: String! @search(by: [hash]) @id
  code: String! @search(by: [regexp, hash])
  vid: String!
  gitCommit: String @search(by: [hash])
  next: Version
  previous: Version @hasInverse(field: next)
  ofBranch: Branch! @hasInverse(field: versions)
  publishedFrom: Version @hasInverse(field: publications)
  publications: [Version!]
  checkouts: [Branch!]
  artifacts: [IArtifact!] @hasInverse(field: inVersion)
  createdAt: DateTime!
  lastModified: DateTime
  createdBy: User!
  wayOfCreation: CreationType!
}

Thanks @spinelsun
Can you please query for all the versions of branch 0x13882-master and share with us?

query MyQuery {
  getBranch(orkId: "0x13882-master") {
    createdBy
    orkId
    versions {
       wayOfCreation
        code
        orkId
    }
  }
}

@anand here is the result

Hi @spinelsun
Deep mutations do not alter linked objects. In this case, versions will have to be updated via updateVersion API. We cannot alter existing versions using the updateBranch.

We are updating the documentation to clearly convey this aspect.

1 Like

Hi, Everyone! Updated docs for deep mutations are now available: https://dgraph.io/docs/master/graphql/mutations/deep/. These will be merged to the 20.11 docs branch soon. Thank you!