This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User interface { | |
Get(ctx context.Context, id *model.ID) (*model.User, error) | |
List(ctx context.Context, after *model.Cursor, first *int, before *model.Cursor, last *int) (*model.UserConnection, error) | |
} | |
... | |
func (u *user) List(ctx context.Context, after *model.Cursor, first *int, before *model.Cursor, last *int) (*model.UserConnection, error) { | |
return u.userRepository.List(ctx, after, first, before, last) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User interface { | |
Get(ctx context.Context, id *model.ID) (*model.User, error) | |
List(ctx context.Context, after *model.Cursor, first *int, before *model.Cursor, last *int) (*model.UserConnection, error) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (r *queryResolver) Users(ctx context.Context, after *model.Cursor, first *int, before *model.Cursor, last *int) (*ent.UserConnection, error) { | |
panic(fmt.Errorf("not implemented")) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UserConnection is the connection containing edges to User. | |
type UserConnection = ent.UserConnection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package model | |
import "golang-clean-architecture-ent-gqlgen/ent" | |
// Cursor of an edge type. | |
type Cursor = ent.Cursor | |
// PageInfo of a connection type. | |
type PageInfo = ent.PageInfo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type UserConnection { | |
totalCount: Int! | |
pageInfo: PageInfo! | |
edges: [UserEdge] | |
} | |
type UserEdge { | |
node: User | |
cursor: Cursor! | |
} | |
extend type Query { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalar Cursor | |
scalar Time | |
type PageInfo { | |
hasNextPage: Boolean! | |
hasPreviousPage: Boolean! | |
startCursor: Cursor | |
endCursor: Cursor | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (r *queryResolver) Node(ctx context.Context, id ulid.ID) (ent.Noder, error) { | |
n, err := r.client.Noder(ctx, id, ent.WithNodeType(ent.IDToType)) | |
if err != nil { | |
return nil, err | |
} | |
return n, nil | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ent | |
import ( | |
"context" | |
"fmt" | |
"golang-clean-architecture-ent-gqlgen/ent/schema/ulid" | |
"golang-clean-architecture-ent-gqlgen/pkg/const/globalid" | |
) | |
var globalIDs = globalid.New() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
field.String("id"). | |
GoType(ulid.ID("")). | |
DefaultFunc(func() ulid.ID { | |
return ulid.MustNew(globalid.New().Todo.Prefix) | |
}), |