Back to godoc.org

Package todo

v0.13.0
Latest Go to latest

The latest major version is .

Published: 2 days ago | License: MIT | Module: github.com/99designs/gqlgen

Index

Variables

var AllRole = []Role{
	RoleAdmin,
	RoleOwner,
}

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

type ComplexityRoot

type ComplexityRoot struct {
	MyMutation struct {
		CreateTodo func(childComplexity int, todo TodoInput) int
		UpdateTodo func(childComplexity int, id int, changes map[string]interface{}) int
	}

	MyQuery struct {
		LastTodo func(childComplexity int) int
		Todo     func(childComplexity int, id int) int
		Todos    func(childComplexity int) int
	}

	Todo struct {
		Done func(childComplexity int) int
		ID   func(childComplexity int) int
		Text func(childComplexity int) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

func New

func New() Config

type DirectiveRoot

type DirectiveRoot struct {
	HasRole func(ctx context.Context, obj interface{}, next graphql.Resolver, role Role) (res interface{}, err error)
	User    func(ctx context.Context, obj interface{}, next graphql.Resolver, id int) (res interface{}, err error)
}

type MutationResolver

type MutationResolver resolvers

func (*MutationResolver) CreateTodo

func (r *MutationResolver) CreateTodo(ctx context.Context, todo TodoInput) (*Todo, error)

func (*MutationResolver) UpdateTodo

func (r *MutationResolver) UpdateTodo(ctx context.Context, id int, changes map[string]interface{}) (*Todo, error)

type MyMutationResolver

type MyMutationResolver interface {
	CreateTodo(ctx context.Context, todo TodoInput) (*Todo, error)
	UpdateTodo(ctx context.Context, id int, changes map[string]interface{}) (*Todo, error)
}

type MyQueryResolver

type MyQueryResolver interface {
	Todo(ctx context.Context, id int) (*Todo, error)
	LastTodo(ctx context.Context) (*Todo, error)
	Todos(ctx context.Context) ([]*Todo, error)
}

type Ownable

type Ownable interface {
	Owner() *User
}

type QueryResolver

type QueryResolver resolvers

func (*QueryResolver) LastTodo

func (r *QueryResolver) LastTodo(ctx context.Context) (*Todo, error)

func (*QueryResolver) Todo

func (r *QueryResolver) Todo(ctx context.Context, id int) (*Todo, error)

func (*QueryResolver) Todos

func (r *QueryResolver) Todos(ctx context.Context) ([]*Todo, error)

type ResolverRoot

type ResolverRoot interface {
	MyMutation() MyMutationResolver
	MyQuery() MyQueryResolver
}

type Role

type Role string
const (
	RoleAdmin Role = "ADMIN"
	RoleOwner Role = "OWNER"
)

func (Role) IsValid

func (e Role) IsValid() bool

func (Role) MarshalGQL

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

func (Role) String

func (e Role) String() string

func (*Role) UnmarshalGQL

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

type Todo

type Todo struct {
	ID   int
	Text string
	Done bool
	// contains filtered or unexported fields
}

func (Todo) Owner

func (t Todo) Owner() *User

type TodoInput

type TodoInput struct {
	// The body text
	Text string `json:"text"`
	// Is it done already?
	Done *bool `json:"done"`
}

Passed to createTodo to create a new todo

type User

type User struct {
	ID   int
	Name string
}

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier