Add datum totalCount support
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -46,6 +46,7 @@ type ResolverRoot interface {
|
||||
Control() ControlResolver
|
||||
ControlConnection() ControlConnectionResolver
|
||||
Datum() DatumResolver
|
||||
DatumConnection() DatumConnectionResolver
|
||||
Document() DocumentResolver
|
||||
DocumentConnection() DocumentConnectionResolver
|
||||
DocumentVersion() DocumentVersionResolver
|
||||
@@ -242,8 +243,9 @@ type ComplexityRoot struct {
|
||||
}
|
||||
|
||||
DatumConnection struct {
|
||||
Edges func(childComplexity int) int
|
||||
PageInfo func(childComplexity int) int
|
||||
Edges func(childComplexity int) int
|
||||
PageInfo func(childComplexity int) int
|
||||
TotalCount func(childComplexity int) int
|
||||
}
|
||||
|
||||
DatumEdge struct {
|
||||
@@ -560,7 +562,7 @@ type ComplexityRoot struct {
|
||||
Connectors func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ConnectorOrder) int
|
||||
Controls func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy, filter *types.ControlFilter) int
|
||||
CreatedAt func(childComplexity int) int
|
||||
Data func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DatumOrder) int
|
||||
Data func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DatumOrderBy) int
|
||||
Documents func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DocumentOrderBy, filter *types.DocumentFilter) int
|
||||
Frameworks func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.FrameworkOrderBy) int
|
||||
ID func(childComplexity int) int
|
||||
@@ -900,6 +902,9 @@ type DatumResolver interface {
|
||||
Vendors(ctx context.Context, obj *types.Datum, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.VendorOrderBy) (*types.VendorConnection, error)
|
||||
Organization(ctx context.Context, obj *types.Datum) (*types.Organization, error)
|
||||
}
|
||||
type DatumConnectionResolver interface {
|
||||
TotalCount(ctx context.Context, obj *types.DatumConnection) (int, error)
|
||||
}
|
||||
type DocumentResolver interface {
|
||||
Owner(ctx context.Context, obj *types.Document) (*types.People, error)
|
||||
Organization(ctx context.Context, obj *types.Document) (*types.Organization, error)
|
||||
@@ -1026,7 +1031,7 @@ type OrganizationResolver interface {
|
||||
Risks(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.RiskOrderBy, filter *types.RiskFilter) (*types.RiskConnection, error)
|
||||
Tasks(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.TaskOrderBy) (*types.TaskConnection, error)
|
||||
Assets(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.AssetOrder) (*types.AssetConnection, error)
|
||||
Data(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DatumOrder) (*types.DatumConnection, error)
|
||||
Data(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DatumOrderBy) (*types.DatumConnection, error)
|
||||
}
|
||||
type PeopleConnectionResolver interface {
|
||||
TotalCount(ctx context.Context, obj *types.PeopleConnection) (int, error)
|
||||
@@ -1638,6 +1643,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.DatumConnection.PageInfo(childComplexity), true
|
||||
|
||||
case "DatumConnection.totalCount":
|
||||
if e.complexity.DatumConnection.TotalCount == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.DatumConnection.TotalCount(childComplexity), true
|
||||
|
||||
case "DatumEdge.cursor":
|
||||
if e.complexity.DatumEdge.Cursor == nil {
|
||||
break
|
||||
@@ -3327,7 +3339,7 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return e.complexity.Organization.Data(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey), args["orderBy"].(*types.DatumOrder)), true
|
||||
return e.complexity.Organization.Data(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey), args["orderBy"].(*types.DatumOrderBy)), true
|
||||
|
||||
case "Organization.documents":
|
||||
if e.complexity.Organization.Documents == nil {
|
||||
@@ -6041,7 +6053,11 @@ type DocumentVersionEdge {
|
||||
node: DocumentVersion!
|
||||
}
|
||||
|
||||
type DatumConnection {
|
||||
type DatumConnection
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.DatumConnection"
|
||||
) {
|
||||
totalCount: Int! @goField(forceResolver: true)
|
||||
edges: [DatumEdge!]!
|
||||
pageInfo: PageInfo!
|
||||
}
|
||||
@@ -7024,7 +7040,10 @@ type Datum implements Node {
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
input DatumOrder {
|
||||
input DatumOrder
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.DatumOrderBy"
|
||||
) {
|
||||
direction: OrderDirection!
|
||||
field: DatumOrderField!
|
||||
}
|
||||
@@ -10171,13 +10190,13 @@ func (ec *executionContext) field_Organization_data_argsBefore(
|
||||
func (ec *executionContext) field_Organization_data_argsOrderBy(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (*types.DatumOrder, error) {
|
||||
) (*types.DatumOrderBy, error) {
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy"))
|
||||
if tmp, ok := rawArgs["orderBy"]; ok {
|
||||
return ec.unmarshalODatumOrder2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDatumOrder(ctx, tmp)
|
||||
return ec.unmarshalODatumOrder2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDatumOrderBy(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal *types.DatumOrder
|
||||
var zeroVal *types.DatumOrderBy
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
@@ -15577,6 +15596,50 @@ func (ec *executionContext) fieldContext_Datum_updatedAt(_ context.Context, fiel
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _DatumConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *types.DatumConnection) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_DatumConnection_totalCount(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return ec.resolvers.DatumConnection().TotalCount(rctx, obj)
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(int)
|
||||
fc.Result = res
|
||||
return ec.marshalNInt2int(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_DatumConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "DatumConnection",
|
||||
Field: field,
|
||||
IsMethod: true,
|
||||
IsResolver: true,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type Int does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _DatumConnection_edges(ctx context.Context, field graphql.CollectedField, obj *types.DatumConnection) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_DatumConnection_edges(ctx, field)
|
||||
if err != nil {
|
||||
@@ -15653,9 +15716,9 @@ func (ec *executionContext) _DatumConnection_pageInfo(ctx context.Context, field
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(*types.PageInfo)
|
||||
res := resTmp.(types.PageInfo)
|
||||
fc.Result = res
|
||||
return ec.marshalNPageInfo2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPageInfo(ctx, field.Selections, res)
|
||||
return ec.marshalNPageInfo2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPageInfo(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_DatumConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
@@ -26211,7 +26274,7 @@ func (ec *executionContext) _Organization_data(ctx context.Context, field graphq
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return ec.resolvers.Organization().Data(rctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*page.CursorKey), fc.Args["last"].(*int), fc.Args["before"].(*page.CursorKey), fc.Args["orderBy"].(*types.DatumOrder))
|
||||
return ec.resolvers.Organization().Data(rctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*page.CursorKey), fc.Args["last"].(*int), fc.Args["before"].(*page.CursorKey), fc.Args["orderBy"].(*types.DatumOrderBy))
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
@@ -26236,6 +26299,8 @@ func (ec *executionContext) fieldContext_Organization_data(ctx context.Context,
|
||||
IsResolver: true,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
switch field.Name {
|
||||
case "totalCount":
|
||||
return ec.fieldContext_DatumConnection_totalCount(ctx, field)
|
||||
case "edges":
|
||||
return ec.fieldContext_DatumConnection_edges(ctx, field)
|
||||
case "pageInfo":
|
||||
@@ -37929,8 +37994,8 @@ func (ec *executionContext) unmarshalInputCreateVendorRiskAssessmentInput(ctx co
|
||||
return it, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalInputDatumOrder(ctx context.Context, obj any) (types.DatumOrder, error) {
|
||||
var it types.DatumOrder
|
||||
func (ec *executionContext) unmarshalInputDatumOrder(ctx context.Context, obj any) (types.DatumOrderBy, error) {
|
||||
var it types.DatumOrderBy
|
||||
asMap := map[string]any{}
|
||||
for k, v := range obj.(map[string]any) {
|
||||
asMap[k] = v
|
||||
@@ -42254,15 +42319,51 @@ func (ec *executionContext) _DatumConnection(ctx context.Context, sel ast.Select
|
||||
switch field.Name {
|
||||
case "__typename":
|
||||
out.Values[i] = graphql.MarshalString("DatumConnection")
|
||||
case "totalCount":
|
||||
field := field
|
||||
|
||||
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
}
|
||||
}()
|
||||
res = ec._DatumConnection_totalCount(ctx, field, obj)
|
||||
if res == graphql.Null {
|
||||
atomic.AddUint32(&fs.Invalids, 1)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
if field.Deferrable != nil {
|
||||
dfs, ok := deferred[field.Deferrable.Label]
|
||||
di := 0
|
||||
if ok {
|
||||
dfs.AddField(field)
|
||||
di = len(dfs.Values) - 1
|
||||
} else {
|
||||
dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
|
||||
deferred[field.Deferrable.Label] = dfs
|
||||
}
|
||||
dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
|
||||
return innerFunc(ctx, dfs)
|
||||
})
|
||||
|
||||
// don't run the out.Concurrently() call below
|
||||
out.Values[i] = graphql.Null
|
||||
continue
|
||||
}
|
||||
|
||||
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
||||
case "edges":
|
||||
out.Values[i] = ec._DatumConnection_edges(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
out.Invalids++
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
case "pageInfo":
|
||||
out.Values[i] = ec._DatumConnection_pageInfo(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
out.Invalids++
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
default:
|
||||
panic("unknown field " + strconv.Quote(field.Name))
|
||||
@@ -53733,7 +53834,7 @@ func (ec *executionContext) marshalODatetime2ᚖtimeᚐTime(ctx context.Context,
|
||||
return res
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalODatumOrder2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDatumOrder(ctx context.Context, v any) (*types.DatumOrder, error) {
|
||||
func (ec *executionContext) unmarshalODatumOrder2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDatumOrderBy(ctx context.Context, v any) (*types.DatumOrderBy, error) {
|
||||
if v == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user