How to mimic SQL subselect during a mutation?

I’m pretty sure you can’t do this in Graphql, but maybe DQL. This is a pretty huge deal, and I can’t find anything in the docs or on here that does this effectively.

The inability to effectively and efficiently do migrations is a big sticking point for me right now. The inability to do much of anything across relationships is a paint point (IE- filter on a property of a relationship in Graphql).

Given an item that has a price.
Let’s say I stored the price separately for a bit on a priceHistory.
But now I’ve learned I don’t need or want it and want to move the most recent (last) price from the history and place it directly on the item.

PriceHistory = {on: DateTime, value: Int}
Item = {id: ID!, priceHistory: [PriceHistory!]}

In SQL we’d simply do this:

update Item set price = (select value, on from priceHistory where priceHistory.itemId = order by on desc limit 1;

I wrote a mutationLambda to try and do this for me, but I can’t process more than about 200 records per call. It’s just too slow, which worries me about dgraphs long term performance…

This is basically the concept of upsert with DQL.

Build any kind of DQL query and set any field/value to a variable, then use that variable in a set or delete statement.