server

package
v0.0.0-...-5be41ad Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MsgNotAuthenticated is the constant for Not Authenticated message
	MsgNotAuthenticated string = "NotAuthenticated"
	// CtxUserIDKey holds the key for 'userid' value
	CtxUserIDKey CtxUserID = "userid"
	// IDSize is the size of the UIDs generated for DB columns
	IDSize int = 4
)

Variables

Functions

func NewCookieStorer

func NewCookieStorer(cookieStoreKey []byte, isSecure bool) abclientstate.CookieStorer

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

func NewSessionStorer

func NewSessionStorer(cookieName string, sessionStoreKey []byte) abclientstate.SessionStorer

Types

type Action

type Action string
const (
	ActionCreated Action = "CREATED"
	ActionDeleted Action = "DELETED"
	ActionUpdated Action = "UPDATED"
)

func (Action) IsValid

func (e Action) IsValid() bool

func (Action) MarshalGQL

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

func (Action) String

func (e Action) String() string

func (*Action) UnmarshalGQL

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

type ComplexityRoot

type ComplexityRoot struct {
	Label struct {
		ID   func(childComplexity int) int
		Name func(childComplexity int) int
	}

	LabelAction struct {
		Action func(childComplexity int) int
		Label  func(childComplexity int) int
	}

	Mutation struct {
		CopyTodo    func(childComplexity int, sourceID string) int
		CreateLabel func(childComplexity int, name string) int
		CreateTodo  func(childComplexity int, title string, notes []string, labels []*string, color *string, isCheckboxMode *bool) int
		DeleteLabel func(childComplexity int, id string) int
		DeleteTodo  func(childComplexity int, id string) int
		UpdateTodo  func(childComplexity int, id string, title *string, notes []*NotesInput, labels []*string, color *string, isCheckboxMode *bool) int
		UpdateUser  func(childComplexity int, listMode *bool, darkMode *bool) int
	}

	Note struct {
		IsCompleted func(childComplexity int) int
		Text        func(childComplexity int) int
	}

	Query struct {
		Labels func(childComplexity int) int
		Todos  func(childComplexity int) int
		User   func(childComplexity int) int
	}

	Subscription struct {
		LabelStream func(childComplexity int) int
		TodoStream  func(childComplexity int) int
	}

	Todo struct {
		Color          func(childComplexity int) int
		ID             func(childComplexity int) int
		IsCheckboxMode func(childComplexity int) int
		Labels         func(childComplexity int) int
		Notes          func(childComplexity int) int
		Title          func(childComplexity int) int
	}

	TodoAction struct {
		Action func(childComplexity int) int
		Todo   func(childComplexity int) int
	}

	User struct {
		DarkMode func(childComplexity int) int
		Email    func(childComplexity int) int
		ID       func(childComplexity int) int
		ListMode func(childComplexity int) int
		Name     func(childComplexity int) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type CtxUserID

type CtxUserID string

type DirectiveRoot

type DirectiveRoot struct {
}

type Label

type Label struct {
	ID     string  `json:"id"`
	Name   string  `json:"name"`
	Todos  []*Todo `gorm:"many2many:todos_labels"` // many-to-many
	UserID string  `sql:"type:TEXT REFERENCES users(id) ON DELETE CASCADE"`
}

type LabelAction

type LabelAction struct {
	Action Action `json:"action"`
	Label  *Label `json:"label"`
}

type MutationResolver

type MutationResolver interface {
	CreateTodo(ctx context.Context, title string, notes []string, labels []*string, color *string, isCheckboxMode *bool) (*Todo, error)
	UpdateTodo(ctx context.Context, id string, title *string, notes []*NotesInput, labels []*string, color *string, isCheckboxMode *bool) (*Todo, error)
	DeleteTodo(ctx context.Context, id string) (*Todo, error)
	CopyTodo(ctx context.Context, sourceID string) (*Todo, error)
	CreateLabel(ctx context.Context, name string) (*Label, error)
	DeleteLabel(ctx context.Context, id string) (*Label, error)
	UpdateUser(ctx context.Context, listMode *bool, darkMode *bool) (*User, error)
}

type Note

type Note struct {
	ID          string `gorm:"primary_key"`
	TodoID      string `sql:"type:TEXT REFERENCES todos(id) ON DELETE CASCADE"`
	Text        string `json:"text"`
	IsCompleted bool   `json:"isCompleted"`
}

type NotesInput

type NotesInput struct {
	Text        string `json:"text"`
	IsCompleted bool   `json:"isCompleted"`
}

type QueryResolver

type QueryResolver interface {
	Todos(ctx context.Context) ([]*Todo, error)
	Labels(ctx context.Context) ([]*Label, error)
	User(ctx context.Context) (*User, error)
}

type Resolver

type Resolver struct {
	DB *gorm.DB
}

Resolver holds the Query, mutation and subscription resolvers

func (*Resolver) Mutation

func (r *Resolver) Mutation() MutationResolver

Mutation returns an instance of mutationResolver

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

Query returns an instance of queryResolver

func (*Resolver) Subscription

func (r *Resolver) Subscription() SubscriptionResolver

Subscription returns an instance of subscriptionResolver

type ResolverRoot

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

type SQLiteStorer

type SQLiteStorer struct {
	authboss.CreatingServerStorer
	DB *gorm.DB
}

func NewSQLiteStorer

func NewSQLiteStorer(db *gorm.DB) *SQLiteStorer

func (SQLiteStorer) Create

func (s SQLiteStorer) Create(ctx context.Context, user authboss.User) error

func (SQLiteStorer) Load

func (s SQLiteStorer) Load(ctx context.Context, key string) (authboss.User, error)

func (SQLiteStorer) New

func (s SQLiteStorer) New(ctx context.Context) authboss.User

func (SQLiteStorer) Save

func (s SQLiteStorer) Save(ctx context.Context, user authboss.User) error

type SubscriptionResolver

type SubscriptionResolver interface {
	TodoStream(ctx context.Context) (<-chan *TodoAction, error)
	LabelStream(ctx context.Context) (<-chan *LabelAction, error)
}

type Todo

type Todo struct {
	ID             string   `json:"id"`
	Title          string   `json:"title"`
	Notes          []*Note  `json:"notes" gorm:"foreignkey:TodoID"`       // has-many
	Labels         []*Label `json:"labels" gorm:"many2many:todos_labels"` // many-to-many
	Color          string   `json:"color"`
	IsCheckboxMode bool     `json:"isCheckboxMode"`
	UserID         string   `sql:"type:TEXT REFERENCES users(id) ON DELETE CASCADE"`
}

type TodoAction

type TodoAction struct {
	Action Action `json:"action"`
	Todo   *Todo  `json:"todo"`
}

type User

type User struct {
	authboss.ArbitraryUser
	ID       string   `json:"id"`
	Name     string   `json:"name"`
	Email    string   `json:"email"`
	Password string   `json:"password"`
	ListMode bool     `json:"listMode"`
	DarkMode bool     `json:"darkMode"`
	Todos    []*Todo  `gorm:"foreignkey:UserID"` // has-many
	Labels   []*Label `gorm:"foreignkey:UserID"` // has-many
}

func (*User) GetArbitrary

func (u *User) GetArbitrary() map[string]string

func (*User) GetPID

func (u *User) GetPID() string

func (*User) GetPassword

func (u *User) GetPassword() string

func (*User) PutArbitrary

func (u *User) PutArbitrary(values map[string]string)

func (*User) PutPID

func (u *User) PutPID(pid string)

func (*User) PutPassword

func (u *User) PutPassword(password string)

func (*User) Validate

func (u *User) Validate() []error

Jump to

Keyboard shortcuts

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