From fe307ff27f625bbef080da58044e241f19520ed3 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Tue, 20 Jun 2023 21:13:35 -0600 Subject: [PATCH] Added Resources field to gql for Event --- gql.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gql.go b/gql.go index 15801a5..8a154dc 100644 --- a/gql.go +++ b/gql.go @@ -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 func GQLListResource() * graphql.List { if gql_list_resource == nil { @@ -608,6 +614,10 @@ func GQLInterfaceEvent() * graphql.Interface { 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{ Type: graphql.String, }) @@ -623,6 +633,10 @@ func GQLInterfaceEvent() * graphql.Interface { gql_interface_event.AddFieldConfig("Children", &graphql.Field{ Type: gql_list_event, }) + + gql_interface_event.AddFieldConfig("Resources", &graphql.Field{ + Type: gql_list_resource, + }) } return gql_interface_event @@ -662,6 +676,11 @@ func GQLTypeBaseEvent() * graphql.Object { Type: GQLListEvent(), Resolve: GQLEventChildren, }) + + gql_type_base_event.AddFieldConfig("Resources", &graphql.Field{ + Type: GQLListResource(), + Resolve: GQLEventResources, + }) } return gql_type_base_event @@ -698,6 +717,10 @@ func GQLTypeEventQueue() * graphql.Object { Type: GQLListEvent(), Resolve: GQLEventChildren, }) + gql_type_event_queue.AddFieldConfig("Resources", &graphql.Field{ + Type: GQLListResource(), + Resolve: GQLEventResources, + }) } return gql_type_event_queue }