Although this use case is stated in the official docs, assigning count
to a value variable does not work.
Steps to reproduce
This behaviour can be reproduced on the Dgraph Cloud Free Tier.
Schema
type Course {
id: ID!
title: String!
chapters: [Chapter!]!
}
type Chapter {
id: ID!
title: String!
sequence: Int
}
Initial Mutation
{
"set": {
"dgraph.type": "Course",
"Course.title": "Course 1",
"Course.chapters": [
{
"dgraph.type": "Chapter",
"Chapter.title": "Chapter 1",
"Chapter.sequence": 0
},
{
"dgraph.type": "Chapter",
"Chapter.title": "Chapter 2",
"Chapter.sequence": 1
}
]
}
}
Upsert Muatation
{
"query": "{ qTest(func: uid(0x1)) { u as uid c as count(Course.chapters) } }",
"mutations": [
{
"set": {
"uid": "uid(u)",
"Course.chapters": [
{
"dgraph.type": "Chapter",
"Chapter.title": "Test Chapter",
"Chapter.sequence": "val(c)"
}
]
}
}
]
}
Response
{
data: {
code: "Success"
message: "Done"
queries: {
qTest: [
0: {
uid:"0x1"
count(Course.chapters): 2
}
]
}
uids: {
dg.3162278161.22051:"0x1"
}
}
Expected behaviour
We would expect that Chapter.sequence
of the new Chapter Test Chapter
would be 2
since count(Course.chapters)
validates 2
.
Actual behaviour
Chapter.sequence
of the newly created Chapter Test Chapter
remains undefined.