diff --git a/gql.go b/gql.go index 1d58ef3..6727c8c 100644 --- a/gql.go +++ b/gql.go @@ -898,6 +898,25 @@ func NewGQLExtContext() *GQLExtContext { panic(err) } + context.Query.AddFieldConfig("Self", &graphql.Field{ + Type: context.Interfaces["Node"].Interface, + Resolve: func(p graphql.ResolveParams) (interface{}, error) { + ctx, err := PrepResolve(p) + if err != nil { + return nil, err + } + + nodes, err := ResolveNodes(ctx, p, []NodeID{ctx.Server.ID}) + if err != nil { + return nil, err + } else if len(nodes) != 1 { + return nil, fmt.Errorf("wrong length of resolved nodes returned") + } + + return nodes[0], nil + }, + }) + context.Query.AddFieldConfig("Node", &graphql.Field{ Type: context.Interfaces["Node"].Interface, Args: graphql.FieldConfigArgument{