Dgraph for SQL Pros workshop on 6/10 - Free Signup
To optimize your experience, the interactive tutorial is only available on desktop.

Dgraph DQL Tour

Var Blocks

Multiple Named Query Blocks

Note

From now on, to run the queries, you’ll need to have loaded the million triple movie dataset.

Queries can be issued as multiples.

For queries labeled q1, ..., qn issued as a multiple query block, the JSON result will contain labeled answer blocks q1, ..., qn for each query.

If a block is labeled with var, no results are returned for that query.

Queries issued in this way are independent.

The visualization here finds the union in the two queries based on uid, but the JSON result contains the independent answer for each query.

So, In this case, we are visualizing the union between two distinct queries.

Query variables are one of the most powerful features of DQL. Query variables allow the answers from one block to be used in another, joining the two queries. You’ll learn about query variables in the following pages.