gqlgen: github.com/99designs/gqlgen/example/todo Index | Files | Directories

package todo

import "github.com/99designs/gqlgen/example/todo"

Index

Package Files

generated.go models.go models_gen.go todo.go

Variables

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

func NewExecutableSchema Uses

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

type ComplexityRoot Uses

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 Uses

type Config struct {
    Resolvers  ResolverRoot
    Directives DirectiveRoot
    Complexity ComplexityRoot
}

func New Uses

func New() Config

type DirectiveRoot Uses

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 Uses

type MutationResolver resolvers

func (*MutationResolver) CreateTodo Uses

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

func (*MutationResolver) UpdateTodo Uses

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

type MyMutationResolver Uses

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 Uses

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 Uses

type Ownable interface {
    Owner() *User
}

type QueryResolver Uses

type QueryResolver resolvers

func (*QueryResolver) LastTodo Uses

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

func (*QueryResolver) Todo Uses

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

func (*QueryResolver) Todos Uses

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

type ResolverRoot Uses

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

type Role Uses

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

func (Role) IsValid Uses

func (e Role) IsValid() bool

func (Role) MarshalGQL Uses

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

func (Role) String Uses

func (e Role) String() string

func (*Role) UnmarshalGQL Uses

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

type Todo Uses

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

func (Todo) Owner Uses

func (t Todo) Owner() *User

type TodoInput Uses

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 Uses

type User struct {
    ID   int
    Name string
}

Directories

PathSynopsis
server

Package todo imports 14 packages (graph) and is imported by 2 packages. Updated 2020-09-22. Refresh now. Tools for package owners.