feat(query): streaming IterNodes terminal and edge-predicate filtering#4
Merged
Conversation
Design for typed.Query[T].IterNodes() — a streaming counterpart to Nodes() that pages results instead of materializing them. Records the decisions to respect caller-set Limit/Offset (Query[T] tracks its own bounds) and to unify Client.Iter onto the new terminal.
Adds typed.Query[T].WhereEdge — filter root records by a scalar predicate of
a node reached over an outbound edge ("owners who have a pet named Fido").
dgman renders one query block with no per-edge @filter, so a query carrying
edge constraints runs as a two-step semi-join: an @cascade pre-pass resolves
the matching root UIDs, then the main query runs against uid(...), keeping
ordering, pagination, IterNodes paging, and result projection on the normal
dgman path.
The generator emits one thin <Entity>Query.Where<Edge> method per edge field,
delegating to the WhereEdge substrate. Regenerates the movies fixture; adds
tests at the typed, generator, and wrapper-e2e layers.
See docs/specs/2026-05-21-query-edge-filter-design.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lands the query-builder work from
feature/query-iternodesonto the fork'smain— two complete features plus their design specs (9 commits;mainwasbehind by the whole IterNodes line).
Edge-predicate filtering (new)
<Entity>Querycan now filter root records by a scalar predicate of aneighbouring node reached over an edge — e.g. directors who directed a film
named "Inception":
dgraph's root
@filtercannot express this (it only sees the root node's ownpredicates), so a query carrying
WhereEdgeconstraints runs a two-stepsemi-join: a
@cascadepre-pass resolves the matching root UIDs, then themain query is re-pointed at
uid(...). Step two stays entirely on the dgmanpath, so ordering, pagination,
IterNodes, and reverse-edge-aware projectionall keep working unchanged.
typed.Query[T].WhereEdge(predicate, filter, params...)— handwritten substrate<Entity>Query.Where<Edge>(filter, params...)— one per edge fieldWhere*calls AND together; composes withFilter/OrderAsc/Limit/…Filter); a typed predicate DSL is future workdocs/specs/2026-05-21-query-edge-filter-design.mdStreaming IterNodes (already on the branch)
typed.Query[T].IterNodes()and the generated<Entity>Query.IterNodes()— astreaming terminal that pages results instead of materializing them, with
Client.Iterunified onto it. Design:docs/specs/2026-05-21-query-iternodes-design.md. A third design spec (untypedquery operations) is included as design-only, no implementation.
Test plan
go test ./typed/...— green (IterNodes suite + 7 newWhereEdgebehavioral tests)go test ./cmd/modusgraph-gen/...and themoviesfixture package — green(new
TestGenerate_WrapperQueryEdgeFilter; newTestWrapperQuery_WhereEdgeFiltersByEdgeTargete2e)go vet ./...andgo build ./...— clean