"message": "mutation addProject failed because Dgraph execution failed because Some variables are used but not defined\nDefined:[Dataset4 Project2 Project5 __dgraph__0]\nUsed:[Dataset4 Project2 Project5 User7 __dgraph__0]\n",
Okay, I found the bug. The nested UserRef tries to create a new User instead of linking to an existing user. Therefore, the mutation fails as not all fields are present in the input.
The following mutation works, but does not do what I try to achieve. (Which is linking the new project and dataset to the same owner instead of creating a new one for the dataset)
This bug does not appear using the update-mutations. There, I can create a new Dataset and inside the dataset-creation I can reference the correct user.
Thanks for providing schema and step by step instructions to reproduce the issue.
I could reproduce this on master. I am accepting this as a bug. This in a way is similar to what @spinelsun has reported over here, Can't insert data .
My current workaround is a @custom createAccount mutation where the 2nd server calculates the password-hash and calls the addUser mutation with the calculated hash. Similar I have dedicated login mutations.
@rajas Is this bug relevant also for DQL?
also any work around?
Note: I cannot separate queries because I have typs that their childs are required and I have has inverse from the child to the parent which is also required.
I don’t want to remove these connections…
I don’t think that this is relevant to DQL as well. With the error which is thrown, it looks like a bug in converting the GraphQL mutation to DQL mutation.
Although, things will be clear when a deeper investigation is carried out.
The bug seems to occur when a node is added referencing other nodes at the second and third level. (Notice how user is referenced inside versions and branch). The workaround could be to add data in a step by step way. i.e. adding versions first and then adding branch.
The problem is that I have inverse between branch and version that obligates to create the branch with at least one version or when creating a version specify the branch it belongs to…
Until this bug will be solved I will remove this constrain in one of them
I confirm this bug after an upgrade to
Dgraph version : v20.07.2
Dgraph codename : shuri-2
Exemple of query that failed with errors
mutation addNode failed because Dgraph execution failed because Some variables are used but not defined
Defined:[Node2 Node5 Node6 __dgraph__0]
Used:[Node2 Node5 Node6 User9 __dgraph__0]
Schema
Type Node {
id: ID!
createdBy: User!
nameid: String! @id
children: [Node!] @hasInverse(field: parent)
}
Type User {
id: ID!
username: String! @id
}
Note that when changing the reference of the User in the createdBy field with its id instead of its usernamein the children node, dgraph doesnt complain anymore and the request run without the error.