Add node resolver

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-01-24 11:28:14 +01:00
parent d17a29a748
commit 6a378a8a2b
2 changed files with 38 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// 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{}
}

View File

@@ -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.