From 6a378a8a2b7148fd6ec0b639313ae00da9c72f1f Mon Sep 17 00:00:00 2001 From: gearnode Date: Fri, 24 Jan 2025 11:28:14 +0100 Subject: [PATCH] Add node resolver Signed-off-by: gearnode --- pkg/api/console/v1/types/organization.go | 23 +++++++++++++++++++++++ pkg/api/console/v1/v1_resolver.go | 16 +++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 pkg/api/console/v1/types/organization.go diff --git a/pkg/api/console/v1/types/organization.go b/pkg/api/console/v1/types/organization.go new file mode 100644 index 000000000..d2c8f6c1f --- /dev/null +++ b/pkg/api/console/v1/types/organization.go @@ -0,0 +1,23 @@ +// Copyright (c) 2025 Probo Inc . +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +// PERFORMANCE OF THIS SOFTWARE. + +package types + +import ( + "github.com/getprobo/probo/pkg/probo/coredata" +) + +func NewOrganization(e *coredata.Organization) *Organization { + return &Organization{} +} diff --git a/pkg/api/console/v1/v1_resolver.go b/pkg/api/console/v1/v1_resolver.go index 564fa8004..64e440f05 100644 --- a/pkg/api/console/v1/v1_resolver.go +++ b/pkg/api/console/v1/v1_resolver.go @@ -10,8 +10,10 @@ import ( "github.com/getprobo/probo/pkg/api/console/v1/schema" "github.com/getprobo/probo/pkg/api/console/v1/types" + "github.com/getprobo/probo/pkg/probo/coredata" "github.com/getprobo/probo/pkg/probo/coredata/gid" "github.com/getprobo/probo/pkg/probo/coredata/page" + "github.com/vektah/gqlparser/v2/gqlerror" ) // Tasks is the resolver for the tasks field. @@ -52,7 +54,19 @@ func (r *organizationResolver) Frameworks(ctx context.Context, obj *types.Organi // Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error) { - panic(fmt.Errorf("not implemented: Node - node")) + + switch id.EntityType() { + case coredata.OrganizationEntityType: + organization, err := r.svc.GetOrganization(ctx, id) + if err != nil { + return nil, err + } + + return types.NewOrganization(organization), nil + default: + } + + return nil, gqlerror.Errorf("node %q not found", id) } // Control returns schema.ControlResolver implementation.