Skip to content

Add field projection to sub-resource/referenced resource queries. #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions schema/query/projection_evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ func evalProjection(ctx context.Context, p Projection, payload map[string]interf
}
} else if ref, ok := def.Validator.(*schema.Reference); ok {
// Execute sub-request in batch
q := &Query{Predicate: Predicate{&Equal{Field: "id", Value: val}}}
q := &Query{
Projection: pf.Children,
Predicate: Predicate{&Equal{Field: "id", Value: val}},
}
rbr.request(ref.Path, q, func(payloads []map[string]interface{}, validator schema.Validator) error {
var v interface{}
if len(payloads) == 1 {
Expand Down Expand Up @@ -140,7 +143,8 @@ func evalProjection(ctx context.Context, p Projection, payload map[string]interf
// connectionQuery builds a query from a projection field on a schema.Connection type field.
func connectionQuery(pf ProjectionField, field string, id interface{}, validator schema.Validator) (*Query, error) {
q := &Query{
Predicate: Predicate{&Equal{Field: field, Value: id}},
Projection: pf.Children,
Predicate: Predicate{&Equal{Field: field, Value: id}},
}
if filter, ok := pf.Params["filter"].(string); ok {
p, err := ParsePredicate(filter)
Expand Down