Debug mode produces `\n` instead of actual newline in console

Moved from GitHub dgraph-js/42

Posted by aryzing:

When debug mod is turned on, the console output is not properly formatted. The newlines appear as the sequence \n instead of actual newlines as shown in the following example output:

{"query":"\n      query getByName($name: string) {\n        getByName(func: anyofterms(name@., $name)) {\n          expand(_all_)\n        }\n      }\n    ","varsMap":[["name","Julia"]],"startTs":0,"linRead":{"idsMap":[]}}

danielmai commented :

That looks like the expected output. The query text itself contains newlines, but the entire debug output is in JSON as a single line.

aryzing commented :

What are the advantages of having it as is? I’d much prefer a formatted output for easier reading. Having the option to choose would be nice.

danielmai commented :

If the newlines weren’t escaped, the debug output wouldn’t be valid JSON and thus not parse-able.

You could process the query key and print out the query if that’s what you need.