diff --git a/gql_graph.go b/gql_graph.go index 2aa310f..80e1af6 100644 --- a/gql_graph.go +++ b/gql_graph.go @@ -704,6 +704,12 @@ func GQLSubscribeSignal(p graphql.ResolveParams) (interface{}, error) { }) } +func GQLSubscribeSelf(p graphql.ResolveParams) (interface{}, error) { + return GQLSubscribeFn(p, func(signal GraphSignal, p graphql.ResolveParams)(interface{}, error) { + return p.Source, nil + }) +} + func GQLSubscribeFn(p graphql.ResolveParams, fn func(GraphSignal, graphql.ResolveParams)(interface{}, error))(interface{}, error) { server, ok := p.Context.Value("gql_server").(*GQLThread) if ok == false { @@ -734,6 +740,21 @@ func GQLSubscribeFn(p graphql.ResolveParams, fn func(GraphSignal, graphql.Resolv return c, nil } +var gql_subscription_self * graphql.Field = nil +func GQLSubscriptionSelf() * graphql.Field { + if gql_subscription_self == nil { + gql_subscription_self = &graphql.Field{ + Type: GQLTypeGQLThread(), + Resolve: func(p graphql.ResolveParams) (interface{}, error) { + return p.Source, nil + }, + Subscribe: GQLSubscribeSelf, + } + } + + return gql_subscription_update +} + var gql_subscription_update * graphql.Field = nil func GQLSubscriptionUpdate() * graphql.Field { if gql_subscription_update == nil { diff --git a/graph.go b/graph.go index 25a7f66..260aa24 100644 --- a/graph.go +++ b/graph.go @@ -95,6 +95,7 @@ func NewGQLContext(additional_types TypeList, extended_types ObjTypeMap, extende subscriptions := graphql.Fields{ "Update": GQLSubscriptionUpdate(), + "Self": GQLSubscriptionSelf(), } for key, val := range(extended_subscriptions) {