Dgraph fails when using a variable inside of a node which does not exist yet

Hi there,

I am not sure if this is a bug or if I am sending an invalid query.

I am sending the following query:

 var(func: uid($id))
      objectives as ~objective_company
      s as startValue
      t as targetValue
      c as currentValue
      diff as math(t - s)
      progress as math((c - s) / diff)
      average as avg(val(progress))

 objectives (func: uid(objectives)) @filter(lt(val(average),0.2) {
     numberOfObjectivesAtRisk: count(

The query works fine in the following cases:

  • The account does not have any objectives
  • The account has at least one objective and at least one key result

Otherwise it fails with the error message: Expected a valid value map. But got empty.

I appreciate the help, thanks

Please share an equivalent schema and mutation so I can reproduce and try to help you.

The necessary part of the schema looks like the following:

		objective_company: uid @reverse @count .
		keyResult_objective: uid @reverse .

I didn’t understand the part with the mutation. Do you want to me to write a mutation for you which you can use to create the necessary nodes?

It would be interesting to get your whole structure straight. How did you build the Node. But I can try something, but the other predicates are int float?

You build a sample mutation according to its structure helps a lot. So I can even give another recommendation according to mutation. And better analyze what is happening.