Skip to content
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

[Web UI] Filter entities by given subscription #1656

Merged
merged 10 commits into from
Jun 18, 2018
27 changes: 27 additions & 0 deletions backend/apid/graphql/environment.go
Original file line number Diff line number Diff line change
@@ -283,3 +283,30 @@ func (r *envImpl) CheckHistory(p schema.EnvironmentCheckHistoryFieldResolverPara
limit := clampInt(p.Args.Limit, 0, len(history))
return history[0:limit], nil
}

// Subscriptions implements response to request for 'subscriptions' field.
func (r *envImpl) Subscriptions(p graphql.ResolveParams) (interface{}, error) {
set := subscriptionSet{}
env := p.Source.(*types.Environment)
ctx := types.SetContextFromResource(p.Context, env)

entities, err := r.entityCtrl.Query(ctx)
if err != nil {
return set, err
}
for _, entity := range entities {
newSet := newSubscriptionSet(entity)
set.merge(newSet)
}

checks, err := r.checksCtrl.Query(ctx)
if err != nil {
return set, err
}
for _, check := range checks {
newSet := newSubscriptionSet(check)
set.merge(newSet)
}

return set, nil
}
Loading