Skip to content

Commit d3461c4

Browse files
Add field projection to sub-resource/referenced resource queries.
1 parent ca3afb7 commit d3461c4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

schema/query/projection_evaluator.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ func evalProjection(ctx context.Context, p Projection, payload map[string]interf
7979
}
8080
} else if ref, ok := def.Validator.(*schema.Reference); ok {
8181
// Execute sub-request in batch
82-
q := &Query{Predicate: Predicate{&Equal{Field: "id", Value: val}}}
82+
q := &Query{
83+
Projection: pf.Children,
84+
Predicate: Predicate{&Equal{Field: "id", Value: val}},
85+
}
8386
rbr.request(ref.Path, q, func(payloads []map[string]interface{}, validator schema.Validator) error {
8487
var v interface{}
8588
if len(payloads) == 1 {
@@ -140,7 +143,8 @@ func evalProjection(ctx context.Context, p Projection, payload map[string]interf
140143
// connectionQuery builds a query from a projection field on a schema.Connection type field.
141144
func connectionQuery(pf ProjectionField, field string, id interface{}, validator schema.Validator) (*Query, error) {
142145
q := &Query{
143-
Predicate: Predicate{&Equal{Field: field, Value: id}},
146+
Projection: pf.Children,
147+
Predicate: Predicate{&Equal{Field: field, Value: id}},
144148
}
145149
if filter, ok := pf.Params["filter"].(string); ok {
146150
p, err := ParsePredicate(filter)

0 commit comments

Comments
 (0)