Add data inventory
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -245,10 +245,10 @@ enum VendorComplianceReportOrderField
|
||||
)
|
||||
}
|
||||
|
||||
enum OrganizationOrderField {
|
||||
NAME
|
||||
CREATED_AT
|
||||
UPDATED_AT
|
||||
enum OrganizationOrderField @goModel(model: "github.com/getprobo/probo/pkg/coredata.OrganizationOrderField") {
|
||||
NAME @goEnum(value: "github.com/getprobo/probo/pkg/coredata.OrganizationOrderFieldName")
|
||||
CREATED_AT @goEnum(value: "github.com/getprobo/probo/pkg/coredata.OrganizationOrderFieldCreatedAt")
|
||||
UPDATED_AT @goEnum(value: "github.com/getprobo/probo/pkg/coredata.OrganizationOrderFieldUpdatedAt")
|
||||
}
|
||||
|
||||
enum ConnectorOrderField
|
||||
@@ -360,6 +360,12 @@ enum AssetOrderField @goModel(model: "github.com/getprobo/probo/pkg/coredata.Ass
|
||||
CRITICITY @goEnum(value: "github.com/getprobo/probo/pkg/coredata.AssetOrderFieldCriticity")
|
||||
}
|
||||
|
||||
enum DatumOrderField @goModel(model: "github.com/getprobo/probo/pkg/coredata.DatumOrderField") {
|
||||
CREATED_AT @goEnum(value: "github.com/getprobo/probo/pkg/coredata.DatumOrderFieldCreatedAt")
|
||||
NAME @goEnum(value: "github.com/getprobo/probo/pkg/coredata.DatumOrderFieldName")
|
||||
DATA_SENSITIVITY @goEnum(value: "github.com/getprobo/probo/pkg/coredata.DatumOrderFieldDataSensitivity")
|
||||
}
|
||||
|
||||
# Order Input Types
|
||||
input UserOrder
|
||||
@goModel(
|
||||
@@ -557,6 +563,14 @@ type Organization implements Node {
|
||||
orderBy: AssetOrder
|
||||
): AssetConnection! @goField(forceResolver: true)
|
||||
|
||||
data(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: DatumOrder
|
||||
): DatumConnection! @goField(forceResolver: true)
|
||||
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
@@ -1023,6 +1037,16 @@ type DocumentVersionEdge {
|
||||
node: DocumentVersion!
|
||||
}
|
||||
|
||||
type DatumConnection {
|
||||
edges: [DatumEdge!]!
|
||||
pageInfo: PageInfo!
|
||||
}
|
||||
|
||||
type DatumEdge {
|
||||
cursor: CursorKey!
|
||||
node: Datum!
|
||||
}
|
||||
|
||||
# Root Types
|
||||
type Query {
|
||||
node(id: ID!): Node!
|
||||
@@ -1157,6 +1181,12 @@ type Mutation {
|
||||
deleteAsset(input: DeleteAssetInput!): DeleteAssetPayload!
|
||||
addAssetVendor(input: AddAssetVendorInput!): AddAssetVendorPayload!
|
||||
removeAssetVendor(input: RemoveAssetVendorInput!): RemoveAssetVendorPayload!
|
||||
|
||||
createDatum(input: CreateDatumInput!): CreateDatumPayload!
|
||||
updateDatum(input: UpdateDatumInput!): UpdateDatumPayload!
|
||||
deleteDatum(input: DeleteDatumInput!): DeleteDatumPayload!
|
||||
addDatumVendor(input: AddDatumVendorInput!): AddDatumVendorPayload!
|
||||
removeDatumVendor(input: RemoveDatumVendorInput!): RemoveDatumVendorPayload!
|
||||
}
|
||||
|
||||
# Input Types
|
||||
@@ -1954,3 +1984,75 @@ type AddAssetVendorPayload {
|
||||
type RemoveAssetVendorPayload {
|
||||
asset: Asset!
|
||||
}
|
||||
|
||||
type Datum implements Node {
|
||||
id: ID!
|
||||
name: String!
|
||||
dataSensitivity: DataSensitivity!
|
||||
owner: People! @goField(forceResolver: true)
|
||||
vendors(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: VendorOrder
|
||||
): VendorConnection! @goField(forceResolver: true)
|
||||
organization: Organization! @goField(forceResolver: true)
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
input DatumOrder {
|
||||
direction: OrderDirection!
|
||||
field: DatumOrderField!
|
||||
}
|
||||
|
||||
input CreateDatumInput {
|
||||
organizationId: ID!
|
||||
name: String!
|
||||
dataSensitivity: DataSensitivity!
|
||||
ownerId: ID!
|
||||
vendorIds: [ID!]
|
||||
}
|
||||
|
||||
input UpdateDatumInput {
|
||||
id: ID!
|
||||
name: String
|
||||
dataSensitivity: DataSensitivity
|
||||
ownerId: ID
|
||||
vendorIds: [ID!]
|
||||
}
|
||||
|
||||
input DeleteDatumInput {
|
||||
datumId: ID!
|
||||
}
|
||||
|
||||
input AddDatumVendorInput {
|
||||
datumId: ID!
|
||||
vendorId: ID!
|
||||
}
|
||||
|
||||
input RemoveDatumVendorInput {
|
||||
datumId: ID!
|
||||
vendorId: ID!
|
||||
}
|
||||
|
||||
type CreateDatumPayload {
|
||||
datumEdge: DatumEdge!
|
||||
}
|
||||
|
||||
type UpdateDatumPayload {
|
||||
datum: Datum!
|
||||
}
|
||||
|
||||
type DeleteDatumPayload {
|
||||
deletedDatumId: ID!
|
||||
}
|
||||
|
||||
type AddDatumVendorPayload {
|
||||
datum: Datum!
|
||||
}
|
||||
|
||||
type RemoveDatumVendorPayload {
|
||||
datum: Datum!
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
36
pkg/server/api/console/v1/types/data.go
Normal file
36
pkg/server/api/console/v1/types/data.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/getprobo/probo/pkg/coredata"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
)
|
||||
|
||||
func NewDatum(d *coredata.Data) *Datum {
|
||||
return &Datum{
|
||||
ID: d.ID,
|
||||
Name: d.Name,
|
||||
DataSensitivity: d.DataSensitivity,
|
||||
CreatedAt: d.CreatedAt,
|
||||
UpdatedAt: d.UpdatedAt,
|
||||
Organization: &Organization{ID: d.OrganizationID},
|
||||
}
|
||||
}
|
||||
|
||||
func NewDatumEdge(d *coredata.Data, orderField coredata.DatumOrderField) *DatumEdge {
|
||||
return &DatumEdge{
|
||||
Node: NewDatum(d),
|
||||
Cursor: d.CursorKey(orderField),
|
||||
}
|
||||
}
|
||||
|
||||
func NewDataConnection(page *page.Page[*coredata.Data, coredata.DatumOrderField]) *DatumConnection {
|
||||
edges := make([]*DatumEdge, len(page.Data))
|
||||
for i, data := range page.Data {
|
||||
edges[i] = NewDatumEdge(data, page.Cursor.OrderBy.Field)
|
||||
}
|
||||
|
||||
return &DatumConnection{
|
||||
Edges: edges,
|
||||
PageInfo: NewPageInfo(page),
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,6 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/99designs/gqlgen/graphql"
|
||||
@@ -29,6 +25,15 @@ type AddAssetVendorPayload struct {
|
||||
Asset *Asset `json:"asset"`
|
||||
}
|
||||
|
||||
type AddDatumVendorInput struct {
|
||||
DatumID gid.GID `json:"datumId"`
|
||||
VendorID gid.GID `json:"vendorId"`
|
||||
}
|
||||
|
||||
type AddDatumVendorPayload struct {
|
||||
Datum *Datum `json:"datum"`
|
||||
}
|
||||
|
||||
type AssessVendorInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
WebsiteURL string `json:"websiteUrl"`
|
||||
@@ -173,6 +178,18 @@ type CreateControlMeasureMappingPayload struct {
|
||||
MeasureEdge *MeasureEdge `json:"measureEdge"`
|
||||
}
|
||||
|
||||
type CreateDatumInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Name string `json:"name"`
|
||||
DataSensitivity coredata.DataSensitivity `json:"dataSensitivity"`
|
||||
OwnerID gid.GID `json:"ownerId"`
|
||||
VendorIds []gid.GID `json:"vendorIds,omitempty"`
|
||||
}
|
||||
|
||||
type CreateDatumPayload struct {
|
||||
DatumEdge *DatumEdge `json:"datumEdge"`
|
||||
}
|
||||
|
||||
type CreateDocumentInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Title string `json:"title"`
|
||||
@@ -341,6 +358,35 @@ type CreateVendorRiskAssessmentPayload struct {
|
||||
VendorRiskAssessmentEdge *VendorRiskAssessmentEdge `json:"vendorRiskAssessmentEdge"`
|
||||
}
|
||||
|
||||
type Datum struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
DataSensitivity coredata.DataSensitivity `json:"dataSensitivity"`
|
||||
Owner *People `json:"owner"`
|
||||
Vendors *VendorConnection `json:"vendors"`
|
||||
Organization *Organization `json:"organization"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Datum) IsNode() {}
|
||||
func (this Datum) GetID() gid.GID { return this.ID }
|
||||
|
||||
type DatumConnection struct {
|
||||
Edges []*DatumEdge `json:"edges"`
|
||||
PageInfo *PageInfo `json:"pageInfo"`
|
||||
}
|
||||
|
||||
type DatumEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *Datum `json:"node"`
|
||||
}
|
||||
|
||||
type DatumOrder struct {
|
||||
Direction page.OrderDirection `json:"direction"`
|
||||
Field coredata.DatumOrderField `json:"field"`
|
||||
}
|
||||
|
||||
type DeleteAssetInput struct {
|
||||
AssetID gid.GID `json:"assetId"`
|
||||
}
|
||||
@@ -369,6 +415,14 @@ type DeleteControlMeasureMappingPayload struct {
|
||||
DeletedMeasureID gid.GID `json:"deletedMeasureId"`
|
||||
}
|
||||
|
||||
type DeleteDatumInput struct {
|
||||
DatumID gid.GID `json:"datumId"`
|
||||
}
|
||||
|
||||
type DeleteDatumPayload struct {
|
||||
DeletedDatumID gid.GID `json:"deletedDatumId"`
|
||||
}
|
||||
|
||||
type DeleteDocumentInput struct {
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
}
|
||||
@@ -700,6 +754,7 @@ type Organization struct {
|
||||
Risks *RiskConnection `json:"risks"`
|
||||
Tasks *TaskConnection `json:"tasks"`
|
||||
Assets *AssetConnection `json:"assets"`
|
||||
Data *DatumConnection `json:"data"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
@@ -718,8 +773,8 @@ type OrganizationEdge struct {
|
||||
}
|
||||
|
||||
type OrganizationOrder struct {
|
||||
Direction page.OrderDirection `json:"direction"`
|
||||
Field OrganizationOrderField `json:"field"`
|
||||
Direction page.OrderDirection `json:"direction"`
|
||||
Field coredata.OrganizationOrderField `json:"field"`
|
||||
}
|
||||
|
||||
type PageInfo struct {
|
||||
@@ -776,6 +831,15 @@ type RemoveAssetVendorPayload struct {
|
||||
Asset *Asset `json:"asset"`
|
||||
}
|
||||
|
||||
type RemoveDatumVendorInput struct {
|
||||
DatumID gid.GID `json:"datumId"`
|
||||
VendorID gid.GID `json:"vendorId"`
|
||||
}
|
||||
|
||||
type RemoveDatumVendorPayload struct {
|
||||
Datum *Datum `json:"datum"`
|
||||
}
|
||||
|
||||
type RemoveUserInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
UserID gid.GID `json:"userId"`
|
||||
@@ -903,6 +967,18 @@ type UpdateAssetPayload struct {
|
||||
Asset *Asset `json:"asset"`
|
||||
}
|
||||
|
||||
type UpdateDatumInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
DataSensitivity *coredata.DataSensitivity `json:"dataSensitivity,omitempty"`
|
||||
OwnerID *gid.GID `json:"ownerId,omitempty"`
|
||||
VendorIds []gid.GID `json:"vendorIds,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateDatumPayload struct {
|
||||
Datum *Datum `json:"datum"`
|
||||
}
|
||||
|
||||
type UpdateDocumentInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Title *string `json:"title,omitempty"`
|
||||
@@ -1181,60 +1257,3 @@ type Viewer struct {
|
||||
User *User `json:"user"`
|
||||
Organizations *OrganizationConnection `json:"organizations"`
|
||||
}
|
||||
|
||||
type OrganizationOrderField string
|
||||
|
||||
const (
|
||||
OrganizationOrderFieldName OrganizationOrderField = "NAME"
|
||||
OrganizationOrderFieldCreatedAt OrganizationOrderField = "CREATED_AT"
|
||||
OrganizationOrderFieldUpdatedAt OrganizationOrderField = "UPDATED_AT"
|
||||
)
|
||||
|
||||
var AllOrganizationOrderField = []OrganizationOrderField{
|
||||
OrganizationOrderFieldName,
|
||||
OrganizationOrderFieldCreatedAt,
|
||||
OrganizationOrderFieldUpdatedAt,
|
||||
}
|
||||
|
||||
func (e OrganizationOrderField) IsValid() bool {
|
||||
switch e {
|
||||
case OrganizationOrderFieldName, OrganizationOrderFieldCreatedAt, OrganizationOrderFieldUpdatedAt:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (e OrganizationOrderField) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e *OrganizationOrderField) UnmarshalGQL(v any) error {
|
||||
str, ok := v.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("enums must be strings")
|
||||
}
|
||||
|
||||
*e = OrganizationOrderField(str)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid OrganizationOrderField", str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e OrganizationOrderField) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
func (e *OrganizationOrderField) UnmarshalJSON(b []byte) error {
|
||||
s, err := strconv.Unquote(string(b))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return e.UnmarshalGQL(s)
|
||||
}
|
||||
|
||||
func (e OrganizationOrderField) MarshalJSON() ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
e.MarshalGQL(&buf)
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
@@ -146,6 +146,60 @@ func (r *controlResolver) Documents(ctx context.Context, obj *types.Control, fir
|
||||
return types.NewDocumentConnection(page), nil
|
||||
}
|
||||
|
||||
// Owner is the resolver for the owner field.
|
||||
func (r *datumResolver) Owner(ctx context.Context, obj *types.Datum) (*types.People, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
data, err := svc.Data.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get datum: %w", err)
|
||||
}
|
||||
|
||||
people, err := svc.Peoples.Get(ctx, data.OwnerID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get owner: %w", err)
|
||||
}
|
||||
|
||||
return types.NewPeople(people), nil
|
||||
}
|
||||
|
||||
// Vendors is the resolver for the vendors field.
|
||||
func (r *datumResolver) Vendors(ctx context.Context, obj *types.Datum, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.VendorOrderBy) (*types.VendorConnection, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.VendorOrderField]{
|
||||
Field: coredata.VendorOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.VendorOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := svc.Data.ListVendors(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list data vendors: %w", err))
|
||||
}
|
||||
|
||||
return types.NewVendorConnection(page), nil
|
||||
}
|
||||
|
||||
// Organization is the resolver for the organization field.
|
||||
func (r *datumResolver) Organization(ctx context.Context, obj *types.Datum) (*types.Organization, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
org, err := svc.Organizations.Get(ctx, obj.Organization.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get organization: %w", err)
|
||||
}
|
||||
|
||||
return types.NewOrganization(org), nil
|
||||
}
|
||||
|
||||
// Owner is the resolver for the owner field.
|
||||
func (r *documentResolver) Owner(ctx context.Context, obj *types.Document) (*types.People, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
@@ -1687,6 +1741,71 @@ func (r *mutationResolver) RemoveAssetVendor(ctx context.Context, input types.Re
|
||||
panic(fmt.Errorf("not implemented: RemoveAssetVendor - removeAssetVendor"))
|
||||
}
|
||||
|
||||
// CreateDatum is the resolver for the createDatum field.
|
||||
func (r *mutationResolver) CreateDatum(ctx context.Context, input types.CreateDatumInput) (*types.CreateDatumPayload, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.OrganizationID.TenantID())
|
||||
|
||||
data, err := svc.Data.Create(ctx, probo.CreateDatumRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
Name: input.Name,
|
||||
DataSensitivity: input.DataSensitivity,
|
||||
OwnerID: input.OwnerID,
|
||||
VendorIDs: input.VendorIds,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot create datum: %w", err)
|
||||
}
|
||||
|
||||
return &types.CreateDatumPayload{
|
||||
DatumEdge: types.NewDatumEdge(data, coredata.DatumOrderFieldCreatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UpdateDatum is the resolver for the updateDatum field.
|
||||
func (r *mutationResolver) UpdateDatum(ctx context.Context, input types.UpdateDatumInput) (*types.UpdateDatumPayload, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.ID.TenantID())
|
||||
|
||||
datum, err := svc.Data.Update(ctx, probo.UpdateDatumRequest{
|
||||
ID: input.ID,
|
||||
Name: input.Name,
|
||||
DataSensitivity: input.DataSensitivity,
|
||||
OwnerID: input.OwnerID,
|
||||
VendorIDs: input.VendorIds,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot update datum: %w", err)
|
||||
}
|
||||
|
||||
return &types.UpdateDatumPayload{
|
||||
Datum: types.NewDatum(datum),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeleteDatum is the resolver for the deleteDatum field.
|
||||
func (r *mutationResolver) DeleteDatum(ctx context.Context, input types.DeleteDatumInput) (*types.DeleteDatumPayload, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.DatumID.TenantID())
|
||||
|
||||
if err := svc.Data.Delete(ctx, input.DatumID); err != nil {
|
||||
return nil, fmt.Errorf("cannot delete datum: %w", err)
|
||||
}
|
||||
|
||||
return &types.DeleteDatumPayload{
|
||||
DeletedDatumID: input.DatumID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// AddDatumVendor is the resolver for the addDatumVendor field.
|
||||
func (r *mutationResolver) AddDatumVendor(ctx context.Context, input types.AddDatumVendorInput) (*types.AddDatumVendorPayload, error) {
|
||||
panic(fmt.Errorf("not implemented: AddDatumVendor - addDatumVendor"))
|
||||
}
|
||||
|
||||
// RemoveDatumVendor is the resolver for the removeDatumVendor field.
|
||||
func (r *mutationResolver) RemoveDatumVendor(ctx context.Context, input types.RemoveDatumVendorInput) (*types.RemoveDatumVendorPayload, error) {
|
||||
panic(fmt.Errorf("not implemented: RemoveDatumVendor - removeDatumVendor"))
|
||||
}
|
||||
|
||||
// LogoURL is the resolver for the logoUrl field.
|
||||
func (r *organizationResolver) LogoURL(ctx context.Context, obj *types.Organization) (*string, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
@@ -1942,6 +2061,31 @@ func (r *organizationResolver) Assets(ctx context.Context, obj *types.Organizati
|
||||
return types.NewAssetConnection(page), nil
|
||||
}
|
||||
|
||||
// Assets is the resolver for the assets field.
|
||||
func (r *organizationResolver) Data(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DatumOrder) (*types.DatumConnection, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DatumOrderField]{
|
||||
Field: coredata.DatumOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.DatumOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := svc.Data.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list organization data: %w", err))
|
||||
}
|
||||
|
||||
return types.NewDataConnection(page), nil
|
||||
}
|
||||
|
||||
// Node is the resolver for the node field.
|
||||
func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, id.TenantID())
|
||||
@@ -2039,6 +2183,12 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
panic(fmt.Errorf("cannot get asset: %w", err))
|
||||
}
|
||||
return types.NewAsset(asset), nil
|
||||
case coredata.DatumEntityType:
|
||||
datum, err := svc.Data.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get data: %w", err))
|
||||
}
|
||||
return types.NewDatum(datum), nil
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -2452,6 +2602,9 @@ func (r *Resolver) Asset() schema.AssetResolver { return &assetResolver{r} }
|
||||
// Control returns schema.ControlResolver implementation.
|
||||
func (r *Resolver) Control() schema.ControlResolver { return &controlResolver{r} }
|
||||
|
||||
// Datum returns schema.DatumResolver implementation.
|
||||
func (r *Resolver) Datum() schema.DatumResolver { return &datumResolver{r} }
|
||||
|
||||
// Document returns schema.DocumentResolver implementation.
|
||||
func (r *Resolver) Document() schema.DocumentResolver { return &documentResolver{r} }
|
||||
|
||||
@@ -2510,6 +2663,7 @@ func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} }
|
||||
|
||||
type assetResolver struct{ *Resolver }
|
||||
type controlResolver struct{ *Resolver }
|
||||
type datumResolver struct{ *Resolver }
|
||||
type documentResolver struct{ *Resolver }
|
||||
type documentVersionResolver struct{ *Resolver }
|
||||
type documentVersionSignatureResolver struct{ *Resolver }
|
||||
|
||||
Reference in New Issue
Block a user