Can't insert data

Hi,

I have this mutation:

mutation MyMutation {
  addBranch(input: 
    [
      {
        orkId: "0x13882-master", 
        changeMark: "76c0e168329e4a938344816f02e09d45", 
        name: "master", 
        versions: 
        [
          {
            code: "1.0", 
            createdAt: "2020-11-05", 
            createdBy: {username: "orch"}, 
            vid: "76c0e168329e4a938344816f02e09d46", 
            orkId: "0x13882-master-1.0", 
            wayOfCreation: Root
          }, 
          {
            code: "1.1", 
            createdAt: "2020-11-05", 
            createdBy: {username: "orch"}, 
            vid: "76c0e168329e4a938344816f02e09d47", 
            orkId: "0x13882-master-1.1", 
            wayOfCreation: New_Version
          }
        ], 
        in: {id: "0x13882"}, 
        createdAt: "2020-11-05", 
        createdBy: {username: "orch"}
      }
    ]
  ) {
    branch {
      orkId
      changeMark
      createdAt
      createdBy {
        username
      }
      in {
        id
      }
      versions {
        orkId
        vid
        wayOfCreation
        createdAt
        code
        createdBy {
          username
        }
      }
      name
    }
  }
}

I get this error message

“mutation addBranch failed because Dgraph execution failed because Some variables are used but not defined\nDefined:[Version11 Version7 __dgraph__0 __dgraph__1]\nUsed:[User4 Version11 Version7 __dgraph__0 __dgraph__1]\n”

It is strange because I use all fieldsi defind in the input
What Am I missing?

Thanks,
Spinelsun

1 Like

Shouldn’t this be "Root" ?

Yes,

It is an enum value

Can you share your schema for the nodes that you are mutating so that we can reproduce this locally and do a potential fix?

Possibly related (example schema included):

type User {
    username: String! @search(by: [hash, regexp]) @id
    name: String
    email: String! @search(by: [hash, regexp])
    memberships: [Membership!] @hasInverse(field: belongsTo)
    hasCredentials: [Credentials!] @hasInverse(field: forUser)
    visits: [UserVisit!]
    joinedAt: DateTime @search(by: [month])
}

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!
}

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!
}

enum CreationType {
    New_Version
    New_Branch
    Publish
    Root
}

Recently reported similar issue: Create Child nodes with addParent(...)

1 Like