Set variable as undefined to prevent further use

Hi everyone!

What I want to do

I want to declare an undefined variable in case further use isn’t needed. Currently, I am implementing the following.

What I did

movies as var(func: uid(0x01))

Assuming that 0x01 doesn’t exist, I use the variable without any issues since it is already declared. This way I avoid implementing logical tolls that define if the variable would be used or not.

Is it a better way to do it?
Do you think I am properly using resources by applying this solution?

Thanks!

Dgraph metadata

dgraph version

v20.11.1

Not sure what you are trying to accomplish. But 0x01 will always exist no matter what. That’s by design. And variables need to be used.

We are doing this as part of a conditional query construction, in some cases we want the variable to be defined but empty.

So, I think this would be a better question, is there a better way to assign an empty value to a new variable rather than using a “random” uid ?

There’s no empty variable assigning in DQL. See this post Custom Block - Discussion

Thanks a lot for the reply, it’s been very helpful, I’ll check it out.