Fixed GQLVexQueryArenas

graph-rework
noah metz 2023-06-13 14:23:33 -06:00
parent d5954d2860
commit 4a6edade74
1 changed files with 18 additions and 3 deletions

@ -26,11 +26,26 @@ func GQLVexQueries() map[string]*graphql.Field {
func FindResources(event Event, resource_type reflect.Type) []Resource { func FindResources(event Event, resource_type reflect.Type) []Resource {
resources := event.RequiredResources() resources := event.RequiredResources()
found := []Resource{}
for _, resource := range(resources) {
if reflect.TypeOf(resource) == resource_type {
found = append(found, resource)
}
}
for _, child := range(event.Children()) { for _, child := range(event.Children()) {
resources = append(resources, FindResources(child, resource_type)...) found = append(found, FindResources(child, resource_type)...)
} }
return resources m := map[string]Resource{}
for _, resource := range(found) {
m[resource.ID()] = resource
}
ret := []Resource{}
for _, resource := range(m) {
ret = append(ret, resource)
}
return ret
} }
var gql_vex_query_arenas *graphql.Field = nil var gql_vex_query_arenas *graphql.Field = nil
@ -48,7 +63,7 @@ func GQLVexQueryArenas() *graphql.Field {
if is_event == false { if is_event == false {
return nil, fmt.Errorf("Can't enumerate arenas when server is attached to resource") return nil, fmt.Errorf("Can't enumerate arenas when server is attached to resource")
} }
return FindResources(owner, reflect.TypeOf((*Arena)(nil))), nil return FindResources(owner, reflect.TypeOf((*VirtualArena)(nil))), nil
}, },
} }
} }