Added Resources field to gql for Event

graph-rework
noah metz 2023-06-20 21:13:35 -06:00
parent 5be9b9ac07
commit fe307ff27f
1 changed files with 23 additions and 0 deletions

@ -433,6 +433,12 @@ func GQLEventChildren(p graphql.ResolveParams) (interface{}, error) {
}) })
} }
func GQLEventResources(p graphql.ResolveParams) (interface{}, error) {
return GQLEventFn(p, func(event Event, p graphql.ResolveParams)(interface{}, error) {
return event.Resources(), nil
})
}
var gql_list_resource * graphql.List = nil var gql_list_resource * graphql.List = nil
func GQLListResource() * graphql.List { func GQLListResource() * graphql.List {
if gql_list_resource == nil { if gql_list_resource == nil {
@ -608,6 +614,10 @@ func GQLInterfaceEvent() * graphql.Interface {
gql_list_event = graphql.NewList(gql_interface_event) gql_list_event = graphql.NewList(gql_interface_event)
} }
if gql_list_resource == nil {
gql_list_resource = graphql.NewList(GQLInterfaceResource())
}
gql_interface_event.AddFieldConfig("ID", &graphql.Field{ gql_interface_event.AddFieldConfig("ID", &graphql.Field{
Type: graphql.String, Type: graphql.String,
}) })
@ -623,6 +633,10 @@ func GQLInterfaceEvent() * graphql.Interface {
gql_interface_event.AddFieldConfig("Children", &graphql.Field{ gql_interface_event.AddFieldConfig("Children", &graphql.Field{
Type: gql_list_event, Type: gql_list_event,
}) })
gql_interface_event.AddFieldConfig("Resources", &graphql.Field{
Type: gql_list_resource,
})
} }
return gql_interface_event return gql_interface_event
@ -662,6 +676,11 @@ func GQLTypeBaseEvent() * graphql.Object {
Type: GQLListEvent(), Type: GQLListEvent(),
Resolve: GQLEventChildren, Resolve: GQLEventChildren,
}) })
gql_type_base_event.AddFieldConfig("Resources", &graphql.Field{
Type: GQLListResource(),
Resolve: GQLEventResources,
})
} }
return gql_type_base_event return gql_type_base_event
@ -698,6 +717,10 @@ func GQLTypeEventQueue() * graphql.Object {
Type: GQLListEvent(), Type: GQLListEvent(),
Resolve: GQLEventChildren, Resolve: GQLEventChildren,
}) })
gql_type_event_queue.AddFieldConfig("Resources", &graphql.Field{
Type: GQLListResource(),
Resolve: GQLEventResources,
})
} }
return gql_type_event_queue return gql_type_event_queue
} }