graphql

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllTaskType = []TaskType{
	TaskTypeCopyDir,
}

Functions

func GinContextFrom

func GinContextFrom(ctx context.Context) *gin.Context

GinContextFrom retrieve gin.Context from request's context inspired from https://gqlgen.com/recipes/gin/#accessing-gincontext

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

func WithInGinCtx

func WithInGinCtx() gin.HandlerFunc

WithInGinCtx set gin context into request's context with key ginCtxKey inspired from https://gqlgen.com/recipes/gin/#accessing-gincontext

Types

type ComplexityRoot

type ComplexityRoot struct {
	Mutation struct {
		CreateTask func(childComplexity int, input *CreateTask) int
		DeleteTask func(childComplexity int, input *DeleteTask) int
		RunTask    func(childComplexity int, id string) int
	}

	Pair struct {
		Key   func(childComplexity int) int
		Value func(childComplexity int) int
	}

	Query struct {
		Task  func(childComplexity int, id string) int
		Tasks func(childComplexity int) int
	}

	Staff struct {
		ID func(childComplexity int) int
	}

	Storage struct {
		Options func(childComplexity int) int
		Type    func(childComplexity int) int
	}

	Task struct {
		CreatedAt func(childComplexity int) int
		ID        func(childComplexity int) int
		Name      func(childComplexity int) int
		Options   func(childComplexity int) int
		Staffs    func(childComplexity int) int
		Status    func(childComplexity int) int
		Storages  func(childComplexity int) int
		Type      func(childComplexity int) int
		UpdatedAt func(childComplexity int) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type CreateTask

type CreateTask struct {
	Name     string          `json:"name"`
	Type     TaskType        `json:"type"`
	Storages []*StorageInput `json:"storages"`
	Options  []*PairInput    `json:"options"`
	Staffs   []*StaffInput   `json:"staffs"`
}

type DeleteTask

type DeleteTask struct {
	ID string `json:"id"`
}

type DirectiveRoot

type DirectiveRoot struct {
}

type MutationResolver

type MutationResolver interface {
	CreateTask(ctx context.Context, input *CreateTask) (*Task, error)
	DeleteTask(ctx context.Context, input *DeleteTask) (*Task, error)
	RunTask(ctx context.Context, id string) (*Task, error)
}

type Pair added in v0.2.0

type Pair struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type PairInput added in v0.2.0

type PairInput struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type QueryResolver

type QueryResolver interface {
	Task(ctx context.Context, id string) (*Task, error)
	Tasks(ctx context.Context) ([]*Task, error)
}

type Resolver

type Resolver struct {
	DB      *models.DB
	Manager *task.Manager
}

func (*Resolver) Mutation

func (r *Resolver) Mutation() MutationResolver

Mutation returns MutationResolver implementation.

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

Query returns QueryResolver implementation.

type ResolverRoot

type ResolverRoot interface {
	Mutation() MutationResolver
	Query() QueryResolver
}

type Server

type Server struct {
	Path  string
	Debug bool

	DB      *models.DB
	Manager *task.Manager
}

func (*Server) RegisterRouter

func (s *Server) RegisterRouter(r *gin.Engine)

type Staff added in v0.2.0

type Staff struct {
	ID string `json:"id"`
}

type StaffInput added in v0.2.0

type StaffInput struct {
	ID string `json:"id"`
}

type Storage added in v0.2.0

type Storage struct {
	Type    StorageType `json:"type"`
	Options []*Pair     `json:"options"`
}

type StorageInput added in v0.2.0

type StorageInput struct {
	Type    StorageType  `json:"type"`
	Options []*PairInput `json:"options"`
}

type StorageType added in v0.2.0

type StorageType string
const (
	StorageTypeFs       StorageType = "Fs"
	StorageTypeQingstor StorageType = "Qingstor"
)

func (StorageType) IsValid added in v0.2.0

func (e StorageType) IsValid() bool

func (StorageType) MarshalGQL added in v0.2.0

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

func (StorageType) String added in v0.2.0

func (e StorageType) String() string

func (*StorageType) UnmarshalGQL added in v0.2.0

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

type Task added in v0.2.0

type Task struct {
	ID        string     `json:"id"`
	Name      string     `json:"name"`
	Type      TaskType   `json:"type"`
	Status    TaskStatus `json:"status"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	Storages  []*Storage `json:"storages"`
	Options   []*Pair    `json:"options"`
	Staffs    []*Staff   `json:"staffs"`
}

type TaskStatus added in v0.2.0

type TaskStatus string
const (
	TaskStatusCreated  TaskStatus = "Created"
	TaskStatusReady    TaskStatus = "Ready"
	TaskStatusRunning  TaskStatus = "Running"
	TaskStatusFinished TaskStatus = "Finished"
	TaskStatusStopped  TaskStatus = "Stopped"
	TaskStatusError    TaskStatus = "Error"
)

func (TaskStatus) IsValid added in v0.2.0

func (e TaskStatus) IsValid() bool

func (TaskStatus) MarshalGQL added in v0.2.0

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

func (TaskStatus) String added in v0.2.0

func (e TaskStatus) String() string

func (*TaskStatus) UnmarshalGQL added in v0.2.0

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

type TaskType added in v0.2.0

type TaskType string
const (
	TaskTypeCopyDir TaskType = "copyDir"
)

func (TaskType) IsValid added in v0.2.0

func (e TaskType) IsValid() bool

func (TaskType) MarshalGQL added in v0.2.0

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

func (TaskType) String added in v0.2.0

func (e TaskType) String() string

func (*TaskType) UnmarshalGQL added in v0.2.0

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

Jump to

Keyboard shortcuts

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