Fix types generation

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-08-07 18:34:26 +02:00
parent 987c85652c
commit c9ab0678be
13 changed files with 66 additions and 117 deletions

View File

@@ -20,10 +20,10 @@ call_argument_directives_with_null: true
models:
ID:
model:
- "github.com/getprobo/probo/pkg/server/api/trust/v1/types.GIDScalar"
- "github.com/getprobo/probo/pkg/server/graphql/types/gid.GIDScalar"
Datetime:
model:
- "github.com/99designs/gqlgen/graphql.Time"
CursorKey:
model:
- "github.com/getprobo/probo/pkg/server/api/trust/v1/types.CursorKeyScalar"
- "github.com/getprobo/probo/pkg/server/graphql/types/cursor.CursorKeyScalar"

View File

@@ -17,6 +17,8 @@ import (
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/page"
"github.com/getprobo/probo/pkg/server/api/trust/v1/types"
"github.com/getprobo/probo/pkg/server/graphql/types/cursor"
gid1 "github.com/getprobo/probo/pkg/server/graphql/types/gid"
gqlparser "github.com/vektah/gqlparser/v2"
"github.com/vektah/gqlparser/v2/ast"
)
@@ -7333,13 +7335,13 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se
}
func (ec *executionContext) unmarshalNCursorKey2githubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx context.Context, v any) (page.CursorKey, error) {
res, err := types.UnmarshalCursorKeyScalar(v)
res, err := cursor.UnmarshalCursorKeyScalar(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNCursorKey2githubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx context.Context, sel ast.SelectionSet, v page.CursorKey) graphql.Marshaler {
_ = sel
res := types.MarshalCursorKeyScalar(v)
res := cursor.MarshalCursorKeyScalar(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
@@ -7490,13 +7492,13 @@ func (ec *executionContext) marshalNFramework2ᚖgithubᚗcomᚋgetproboᚋprobo
}
func (ec *executionContext) unmarshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx context.Context, v any) (gid.GID, error) {
res, err := types.UnmarshalGIDScalar(v)
res, err := gid1.UnmarshalGIDScalar(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx context.Context, sel ast.SelectionSet, v gid.GID) graphql.Marshaler {
_ = sel
res := types.MarshalGIDScalar(v)
res := gid1.MarshalGIDScalar(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
@@ -7978,7 +7980,7 @@ func (ec *executionContext) unmarshalOCursorKey2ᚖgithubᚗcomᚋgetproboᚋpro
if v == nil {
return nil, nil
}
res, err := types.UnmarshalCursorKeyScalar(v)
res, err := cursor.UnmarshalCursorKeyScalar(v)
return &res, graphql.ErrorOnPath(ctx, err)
}
@@ -7988,7 +7990,7 @@ func (ec *executionContext) marshalOCursorKey2ᚖgithubᚗcomᚋgetproboᚋprobo
}
_ = sel
_ = ctx
res := types.MarshalCursorKeyScalar(*v)
res := cursor.MarshalCursorKeyScalar(*v)
return res
}

View File

@@ -16,7 +16,7 @@ package types
import (
"github.com/getprobo/probo/pkg/page"
sharedTypes "github.com/getprobo/probo/pkg/server/api/types"
"github.com/getprobo/probo/pkg/server/graphql/types/cursor"
)
func NewCursor[O page.OrderField](
@@ -26,24 +26,5 @@ func NewCursor[O page.OrderField](
before *page.CursorKey,
orderBy page.OrderBy[O],
) *page.Cursor[O] {
var (
size int
from *page.CursorKey
direction = page.Head
)
if first != nil {
size = *first
direction = page.Head
from = after
} else if last != nil {
size = *last
direction = page.Tail
from = before
}
return page.NewCursor(size, from, direction, orderBy)
return cursor.NewCursor(first, after, last, before, orderBy)
}
var MarshalCursorKeyScalar = sharedTypes.MarshalCursorKeyScalar
var UnmarshalCursorKeyScalar = sharedTypes.UnmarshalCursorKeyScalar

View File

@@ -1,22 +0,0 @@
// 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 (
sharedTypes "github.com/getprobo/probo/pkg/server/api/types"
)
var MarshalGIDScalar = sharedTypes.MarshalGIDScalar
var UnmarshalGIDScalar = sharedTypes.UnmarshalGIDScalar

View File

@@ -16,11 +16,11 @@ package types
import (
"github.com/getprobo/probo/pkg/page"
sharedTypes "github.com/getprobo/probo/pkg/server/api/types"
"github.com/getprobo/probo/pkg/server/graphql/types/pageinfo"
)
func NewPageInfo[T page.Paginable[O], O page.OrderField](p *page.Page[T, O]) *PageInfo {
data := sharedTypes.NewPageInfoData(p)
data := pageinfo.NewPageInfo(p)
return &PageInfo{
HasNextPage: data.HasNextPage,
HasPreviousPage: data.HasPreviousPage,