Dgraph DQL Tour

Var Blocks

Exercise: Query Variables linking queries

We’ve seen two common uses for variables: filtering and reorganizing results. Another is linking two queries to gain some new insight based on the joined results.

Let’s look at an example of joining two queries.

For two directors find the actors who have worked with both (not necessarily on the same movie). Many directors won’t have actors in common, so start with some you are sure will (the answer below uses Peter Jackson and Martin Scorsese who have a small number of actors in common).

As an optional challenge, for each of those actors list the movies they have made with either director.

5.6 Exercise: Query Variables linking queries