todo

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2018 License: MIT Imports: 12 Imported by: 0

README

todo app

This is the simplest example of a graphql server.

to run this server

go run ./example/todo/server/server.go

and open http://localhost:8081 in your browser

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

Types

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
}

func New

func New() Config

type DirectiveRoot

type DirectiveRoot struct {
	HasRole func(ctx context.Context, next graphql.Resolver, role Role) (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)
	AuthenticatedTodo(ctx context.Context, id int) (*Todo, error)
	LastTodo(ctx context.Context) (*Todo, error)
	Todos(ctx context.Context) ([]Todo, error)
}

type QueryResolver

type QueryResolver resolvers

func (*QueryResolver) AuthenticatedTodo

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

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"
	RoleUser  Role = "USER"
)

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    `json:"id"`
	Text string `json:"text"`
	Done bool   `json:"done"`
}

type TodoInput

type TodoInput struct {
	Text string `json:"text"`
	Done *bool  `json:"done"`
}

func UnmarshalTodoInput

func UnmarshalTodoInput(v interface{}) (TodoInput, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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