With EdgeDB 2.0, global now references a schema-defined global. This pattern needs to change as the confusion can be clear.
New design
The new design for WITH will use anonymous types[^fn1]. The context variable will make use of this anonymous type allowing a workflow that looks like this:
QueryBuilder
.With(new { Friend = person })
.Select(ctx => ctx.Variables.Friend)
The pro about this approach is that ctx.Variables is strongly typed thanks to generics, the name "Variables" is subject to change but it still gets the point across.
For internally defined values within a with block, they will still use the QueryGlobal class to maintain references etc.
Summary
The current way we reference values defined in the
WITH
block is like so:With EdgeDB 2.0,
global
now references a schema-defined global. This pattern needs to change as the confusion can be clear.New design
The new design for
WITH
will use anonymous types[^fn1]. The context variable will make use of this anonymous type allowing a workflow that looks like this:The pro about this approach is that
ctx.Variables
is strongly typed thanks to generics, the name "Variables" is subject to change but it still gets the point across.For internally defined values within a with block, they will still use the
QueryGlobal
class to maintain references etc.[^fn1]: read about anonymous types here