The fn:trace() function is useful for debugging XQuery modules. It wraps an expression and writes its value to an implementation-defined log. In the Dgraph, output generated by calls to fn:trace() is sent to the Dgraph log file, or to stdout, if the Dgraph is run from a shell.
fn:trace() takes two arguments: the expression you are tracing and a label. The XQuery evaluator serializes the value of the expression (that is, turns a typed value into a string) and returns the same value again, so you can transparently annotate your query.
trace(<parent><child1/><child2/></parent>/*, "my_label") dgraph log output: Request: 1 - trace(<child1/><child2/>, my_label)