todopulid

package
v0.0.0-...-8e6a2f5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

README

todo example with PULIDs (Prefixed ULIDs).

PULIDs are an identifier encoding scheme that builds upon the excellent [ULID](Universally Unique Lexicographically Sortable Identifier) scheme. Prefixes should maintain compatibility with base32. If constrained to 2 characters for encoding the entity type, the number of types of entities that can be referenced with this scheme is 2^32 (1024).

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllOneToManyOrderField = []OneToManyOrderField{
	OneToManyOrderFieldName,
}

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

func NewSchema

func NewSchema(client *ent.Client) graphql.ExecutableSchema

NewSchema creates a graphql executable schema.

Types

type CategoryResolver

type CategoryResolver interface {
	TodosCount(ctx context.Context, obj *ent.Category) (*int, error)
}

type ComplexityRoot

type ComplexityRoot struct {
	BillProduct struct {
		ID       func(childComplexity int) int
		Name     func(childComplexity int) int
		Quantity func(childComplexity int) int
		Sku      func(childComplexity int) int
	}

	Category struct {
		Config        func(childComplexity int) int
		Count         func(childComplexity int) int
		Duration      func(childComplexity int) int
		ID            func(childComplexity int) int
		Status        func(childComplexity int) int
		Strings       func(childComplexity int) int
		SubCategories func(childComplexity int, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) int
		Text          func(childComplexity int) int
		Todos         func(childComplexity int, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int
		TodosCount    func(childComplexity int) int
	}

	CategoryConfig struct {
		MaxMembers func(childComplexity int) int
	}

	CategoryConnection struct {
		Edges      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	CategoryEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	Custom struct {
		Info func(childComplexity int) int
	}

	Friendship struct {
		CreatedAt func(childComplexity int) int
		Friend    func(childComplexity int) int
		FriendID  func(childComplexity int) int
		ID        func(childComplexity int) int
		User      func(childComplexity int) int
		UserID    func(childComplexity int) int
	}

	FriendshipConnection struct {
		Edges      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	FriendshipEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	Group struct {
		ID    func(childComplexity int) int
		Name  func(childComplexity int) int
		Users func(childComplexity int, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int
	}

	GroupConnection struct {
		Edges      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	GroupEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	Mutation struct {
		ClearTodos       func(childComplexity int) int
		CreateCategory   func(childComplexity int, input ent.CreateCategoryInput) int
		CreateTodo       func(childComplexity int, input ent.CreateTodoInput) int
		UpdateFriendship func(childComplexity int, id pulid.ID, input UpdateFriendshipInput) int
		UpdateTodo       func(childComplexity int, id pulid.ID, input ent.UpdateTodoInput) int
	}

	OneToMany struct {
		Children func(childComplexity int) int
		Field2   func(childComplexity int) int
		ID       func(childComplexity int) int
		Name     func(childComplexity int) int
		Parent   func(childComplexity int) int
	}

	OneToManyConnection struct {
		Edges      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	OneToManyEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	PageInfo struct {
		EndCursor       func(childComplexity int) int
		HasNextPage     func(childComplexity int) int
		HasPreviousPage func(childComplexity int) int
		StartCursor     func(childComplexity int) int
	}

	Project struct {
		ID    func(childComplexity int) int
		Todos func(childComplexity int, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int
	}

	Query struct {
		BillProducts func(childComplexity int) int
		Categories   func(childComplexity int, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) int
		Groups       func(childComplexity int, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, where *ent.GroupWhereInput) int
		Node         func(childComplexity int, id pulid.ID) int
		Nodes        func(childComplexity int, ids []pulid.ID) int
		OneToMany    func(childComplexity int, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy *OneToManyOrder, where *OneToManyWhereInput) int
		Ping         func(childComplexity int) int
		Todos        func(childComplexity int, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int
		Users        func(childComplexity int, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int
	}

	Todo struct {
		Category      func(childComplexity int) int
		CategoryID    func(childComplexity int) int
		Children      func(childComplexity int, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int
		CreatedAt     func(childComplexity int) int
		Custom        func(childComplexity int) int
		Customp       func(childComplexity int) int
		ExtendedField func(childComplexity int) int
		ID            func(childComplexity int) int
		Init          func(childComplexity int) int
		Parent        func(childComplexity int) int
		Priority      func(childComplexity int) int
		Status        func(childComplexity int) int
		Text          func(childComplexity int) int
	}

	TodoConnection struct {
		Edges      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	TodoEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	User struct {
		Friends     func(childComplexity int, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int
		Friendships func(childComplexity int, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, where *ent.FriendshipWhereInput) int
		Groups      func(childComplexity int, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, where *ent.GroupWhereInput) int
		ID          func(childComplexity int) int
		Metadata    func(childComplexity int) int
		Name        func(childComplexity int) int
		Username    func(childComplexity int) int
	}

	UserConnection struct {
		Edges      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	UserEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type CreateCategoryInputResolver

type CreateCategoryInputResolver interface {
	CreateTodos(ctx context.Context, obj *ent.CreateCategoryInput, data []*ent.CreateTodoInput) error
}

type CreateTodoInputResolver

type CreateTodoInputResolver interface {
	Status(ctx context.Context, obj *ent.CreateTodoInput, data todo.Status) error
}

type CreateUserInputResolver

type CreateUserInputResolver interface {
	Username(ctx context.Context, obj *ent.CreateUserInput, data *string) error
}

type DirectiveRoot

type DirectiveRoot struct {
	HasPermissions func(ctx context.Context, obj interface{}, next graphql.Resolver, permissions []string) (res interface{}, err error)
}

type MutationResolver

type MutationResolver interface {
	CreateCategory(ctx context.Context, input ent.CreateCategoryInput) (*ent.Category, error)
	CreateTodo(ctx context.Context, input ent.CreateTodoInput) (*ent.Todo, error)
	UpdateTodo(ctx context.Context, id pulid.ID, input ent.UpdateTodoInput) (*ent.Todo, error)
	ClearTodos(ctx context.Context) (int, error)
	UpdateFriendship(ctx context.Context, id pulid.ID, input UpdateFriendshipInput) (*ent.Friendship, error)
}

type OneToMany

type OneToMany struct {
	ID       pulid.ID     `json:"id"`
	Name     string       `json:"name"`
	Field2   *string      `json:"field2"`
	Parent   *OneToMany   `json:"parent"`
	Children []*OneToMany `json:"children"`
}

func (OneToMany) IsNode

func (OneToMany) IsNode()

type OneToManyConnection

type OneToManyConnection struct {
	// A list of edges.
	Edges []*OneToManyEdge `json:"edges"`
	// Information to aid in pagination.
	PageInfo *entgql.PageInfo[pulid.ID] `json:"pageInfo"`
	// Identifies the total count of items in the connection.
	TotalCount int `json:"totalCount"`
}

A connection to a list of items.

type OneToManyEdge

type OneToManyEdge struct {
	// The item at the end of the edge.
	Node *OneToMany `json:"node"`
	// A cursor for use in pagination.
	Cursor entgql.Cursor[pulid.ID] `json:"cursor"`
}

An edge in a connection.

type OneToManyOrder

type OneToManyOrder struct {
	// The ordering direction.
	Direction entgql.OrderDirection `json:"direction"`
	// The field by which to order OneToManies.
	Field OneToManyOrderField `json:"field"`
}

Ordering options for OneToMany connections

type OneToManyOrderField

type OneToManyOrderField string

Properties by which OneToMany connections can be ordered.

const (
	OneToManyOrderFieldName OneToManyOrderField = "NAME"
)

func (OneToManyOrderField) IsValid

func (e OneToManyOrderField) IsValid() bool

func (OneToManyOrderField) MarshalGQL

func (e OneToManyOrderField) MarshalGQL(w io.Writer)

func (OneToManyOrderField) String

func (e OneToManyOrderField) String() string

func (*OneToManyOrderField) UnmarshalGQL

func (e *OneToManyOrderField) UnmarshalGQL(v interface{}) error

type OneToManyWhereInput

type OneToManyWhereInput struct {
	Not *OneToManyWhereInput   `json:"not"`
	And []*OneToManyWhereInput `json:"and"`
	Or  []*OneToManyWhereInput `json:"or"`
	// id field predicates
	ID      *pulid.ID  `json:"id"`
	IDNeq   *pulid.ID  `json:"idNEQ"`
	IDIn    []pulid.ID `json:"idIn"`
	IDNotIn []pulid.ID `json:"idNotIn"`
	IDGt    *pulid.ID  `json:"idGT"`
	IDGte   *pulid.ID  `json:"idGTE"`
	IDLt    *pulid.ID  `json:"idLT"`
	IDLte   *pulid.ID  `json:"idLTE"`
	// name field predicates
	Name             *string  `json:"name"`
	NameNeq          *string  `json:"nameNEQ"`
	NameIn           []string `json:"nameIn"`
	NameNotIn        []string `json:"nameNotIn"`
	NameGt           *string  `json:"nameGT"`
	NameGte          *string  `json:"nameGTE"`
	NameLt           *string  `json:"nameLT"`
	NameLte          *string  `json:"nameLTE"`
	NameContains     *string  `json:"nameContains"`
	NameHasPrefix    *string  `json:"nameHasPrefix"`
	NameHasSuffix    *string  `json:"nameHasSuffix"`
	NameEqualFold    *string  `json:"nameEqualFold"`
	NameContainsFold *string  `json:"nameContainsFold"`
	// field2 field predicates
	Field2             *string  `json:"field2"`
	Field2neq          *string  `json:"field2NEQ"`
	Field2In           []string `json:"field2In"`
	Field2NotIn        []string `json:"field2NotIn"`
	Field2gt           *string  `json:"field2GT"`
	Field2gte          *string  `json:"field2GTE"`
	Field2lt           *string  `json:"field2LT"`
	Field2lte          *string  `json:"field2LTE"`
	Field2Contains     *string  `json:"field2Contains"`
	Field2HasPrefix    *string  `json:"field2HasPrefix"`
	Field2HasSuffix    *string  `json:"field2HasSuffix"`
	Field2IsNil        *bool    `json:"field2IsNil"`
	Field2NotNil       *bool    `json:"field2NotNil"`
	Field2EqualFold    *string  `json:"field2EqualFold"`
	Field2ContainsFold *string  `json:"field2ContainsFold"`
	// parent edge predicates
	HasParent     *bool                  `json:"hasParent"`
	HasParentWith []*OneToManyWhereInput `json:"hasParentWith"`
	// children edge predicates
	HasChildren     *bool                  `json:"hasChildren"`
	HasChildrenWith []*OneToManyWhereInput `json:"hasChildrenWith"`
}

OneToManyWhereInput is used for filtering OneToMany objects. Input was generated by ent.

type Project

type Project struct {
	ID    pulid.ID            `json:"id"`
	Todos *ent.TodoConnection `json:"todos"`
}

func (Project) IsNode

func (Project) IsNode()

type ProjectWhereInput

type ProjectWhereInput struct {
	Not *ProjectWhereInput   `json:"not"`
	And []*ProjectWhereInput `json:"and"`
	Or  []*ProjectWhereInput `json:"or"`
	// id field predicates
	ID      *pulid.ID  `json:"id"`
	IDNeq   *pulid.ID  `json:"idNEQ"`
	IDIn    []pulid.ID `json:"idIn"`
	IDNotIn []pulid.ID `json:"idNotIn"`
	IDGt    *pulid.ID  `json:"idGT"`
	IDGte   *pulid.ID  `json:"idGTE"`
	IDLt    *pulid.ID  `json:"idLT"`
	IDLte   *pulid.ID  `json:"idLTE"`
	// todos edge predicates
	HasTodos     *bool                 `json:"hasTodos"`
	HasTodosWith []*ent.TodoWhereInput `json:"hasTodosWith"`
}

ProjectWhereInput is used for filtering Project objects. Input was generated by ent.

type QueryResolver

type QueryResolver interface {
	Node(ctx context.Context, id pulid.ID) (ent.Noder, error)
	Nodes(ctx context.Context, ids []pulid.ID) ([]ent.Noder, error)
	BillProducts(ctx context.Context) ([]*ent.BillProduct, error)
	Categories(ctx context.Context, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) (*ent.CategoryConnection, error)
	Groups(ctx context.Context, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, where *ent.GroupWhereInput) (*ent.GroupConnection, error)
	OneToMany(ctx context.Context, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy *OneToManyOrder, where *OneToManyWhereInput) (*OneToManyConnection, error)
	Todos(ctx context.Context, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoConnection, error)
	Users(ctx context.Context, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserConnection, error)
	Ping(ctx context.Context) (string, error)
}

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver is the resolver root.

func (*Resolver) Category

func (r *Resolver) Category() CategoryResolver

Category returns CategoryResolver implementation.

func (*Resolver) CreateCategoryInput

func (r *Resolver) CreateCategoryInput() CreateCategoryInputResolver

CreateCategoryInput returns CreateCategoryInputResolver implementation.

func (*Resolver) CreateTodoInput

func (r *Resolver) CreateTodoInput() CreateTodoInputResolver

CreateTodoInput returns CreateTodoInputResolver implementation.

func (*Resolver) CreateUserInput

func (r *Resolver) CreateUserInput() CreateUserInputResolver

CreateUserInput returns CreateUserInputResolver implementation.

func (*Resolver) Mutation

func (r *Resolver) Mutation() MutationResolver

Mutation returns MutationResolver implementation.

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

Query returns QueryResolver implementation.

func (*Resolver) Todo

func (r *Resolver) Todo() TodoResolver

Todo returns TodoResolver implementation.

func (*Resolver) TodoWhereInput

func (r *Resolver) TodoWhereInput() TodoWhereInputResolver

TodoWhereInput returns TodoWhereInputResolver implementation.

func (*Resolver) UpdateTodoInput

func (r *Resolver) UpdateTodoInput() UpdateTodoInputResolver

UpdateTodoInput returns UpdateTodoInputResolver implementation.

func (*Resolver) UpdateUserInput

func (r *Resolver) UpdateUserInput() UpdateUserInputResolver

UpdateUserInput returns UpdateUserInputResolver implementation.

func (*Resolver) User

func (r *Resolver) User() UserResolver

User returns UserResolver implementation.

func (*Resolver) UserWhereInput

func (r *Resolver) UserWhereInput() UserWhereInputResolver

UserWhereInput returns UserWhereInputResolver implementation.

type ResolverRoot

type ResolverRoot interface {
	Category() CategoryResolver
	Mutation() MutationResolver
	Query() QueryResolver
	Todo() TodoResolver
	User() UserResolver
	CreateCategoryInput() CreateCategoryInputResolver
	CreateTodoInput() CreateTodoInputResolver
	CreateUserInput() CreateUserInputResolver
	TodoWhereInput() TodoWhereInputResolver
	UpdateTodoInput() UpdateTodoInputResolver
	UpdateUserInput() UpdateUserInputResolver
	UserWhereInput() UserWhereInputResolver
}

type TodoResolver

type TodoResolver interface {
	Status(ctx context.Context, obj *ent.Todo) (todo.Status, error)

	ExtendedField(ctx context.Context, obj *ent.Todo) (*string, error)
}

type TodoWhereInputResolver

type TodoWhereInputResolver interface {
	Status(ctx context.Context, obj *ent.TodoWhereInput, data *todo.Status) error
	StatusNeq(ctx context.Context, obj *ent.TodoWhereInput, data *todo.Status) error
	StatusIn(ctx context.Context, obj *ent.TodoWhereInput, data []todo.Status) error
	StatusNotIn(ctx context.Context, obj *ent.TodoWhereInput, data []todo.Status) error

	CreatedToday(ctx context.Context, obj *ent.TodoWhereInput, data *bool) error
}

type UpdateFriendshipInput

type UpdateFriendshipInput struct {
	CreatedAt *time.Time `json:"createdAt"`
	UserID    *pulid.ID  `json:"userID"`
	FriendID  *pulid.ID  `json:"friendID"`
}

UpdateFriendshipInput is used for update Friendship object. Input was generated by ent.

type UpdateTodoInputResolver

type UpdateTodoInputResolver interface {
	Status(ctx context.Context, obj *ent.UpdateTodoInput, data *todo.Status) error
}

type UpdateUserInputResolver

type UpdateUserInputResolver interface {
	Username(ctx context.Context, obj *ent.UpdateUserInput, data *string) error
}

type UserResolver

type UserResolver interface {
	Username(ctx context.Context, obj *ent.User) (string, error)

	Friends(ctx context.Context, obj *ent.User, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserConnection, error)
	Friendships(ctx context.Context, obj *ent.User, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, where *ent.FriendshipWhereInput) (*ent.FriendshipConnection, error)
}

type UserWhereInputResolver

type UserWhereInputResolver interface {
	Username(ctx context.Context, obj *ent.UserWhereInput, data *string) error
	UsernameNeq(ctx context.Context, obj *ent.UserWhereInput, data *string) error
	UsernameIn(ctx context.Context, obj *ent.UserWhereInput, data []string) error
	UsernameNotIn(ctx context.Context, obj *ent.UserWhereInput, data []string) error
	UsernameGt(ctx context.Context, obj *ent.UserWhereInput, data *string) error
	UsernameGte(ctx context.Context, obj *ent.UserWhereInput, data *string) error
	UsernameLt(ctx context.Context, obj *ent.UserWhereInput, data *string) error
	UsernameLte(ctx context.Context, obj *ent.UserWhereInput, data *string) error
}

Directories

Path Synopsis
ent
schema/pulid
Package pulid implements the pulid type.
Package pulid implements the pulid type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL