model

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownType  = errors.New("unknown type")
	ErrTypeNotFound = errors.New("type not found")
)

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

Types

type ComplexityRoot

type ComplexityRoot struct {
	Entity struct {
		FindUserByID func(childComplexity int, id string) int
	}

	Mutation struct {
		ChangePassword func(childComplexity int, oldPassword string, newPassword string) int
		Disable        func(childComplexity int, userID string) int
		Enable         func(childComplexity int, userID string) int
		Grant          func(childComplexity int, userID string, permissions []string) int
		Revoke         func(childComplexity int, userID string, permissions []string) int
		SignIn         func(childComplexity int, login string, password string) int
		SignOut        func(childComplexity int) int
		SignUp         func(childComplexity int, name string, login string, password string) int
	}

	Query struct {
		CurrentUser func(childComplexity int) int
		Users       func(childComplexity int) int
		// contains filtered or unexported fields
	}

	Token struct {
		Token func(childComplexity int) int
	}

	User struct {
		Enabled     func(childComplexity int) int
		ID          func(childComplexity int) int
		Login       func(childComplexity int) int
		Name        func(childComplexity int) int
		Permissions func(childComplexity int) int
	}
	// contains filtered or unexported fields
}

type Config

type Config struct {
	Schema     *ast.Schema
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DirectiveRoot

type DirectiveRoot struct {
}

type EntityRepresentation

type EntityRepresentation map[string]any

EntityRepresentation is the JSON representation of an entity sent by the Router used as the inputs for us to resolve.

We make it a map because we know the top level JSON is always an object.

type EntityResolver

type EntityResolver interface {
	FindUserByID(ctx context.Context, id string) (*User, error)
}

type EntityWithIndex

type EntityWithIndex struct {
	// contains filtered or unexported fields
}

type Mutation

type Mutation struct {
}

type MutationResolver

type MutationResolver interface {
	SignIn(ctx context.Context, login string, password string) (*Token, error)
	SignUp(ctx context.Context, name string, login string, password string) (*Token, error)
	SignOut(ctx context.Context) (bool, error)
	ChangePassword(ctx context.Context, oldPassword string, newPassword string) (bool, error)
	Enable(ctx context.Context, userID string) (bool, error)
	Disable(ctx context.Context, userID string) (bool, error)
	Grant(ctx context.Context, userID string, permissions []string) (bool, error)
	Revoke(ctx context.Context, userID string, permissions []string) (bool, error)
}

type Query

type Query struct {
}

type QueryResolver

type QueryResolver interface {
	CurrentUser(ctx context.Context) (*User, error)
	Users(ctx context.Context) ([]*User, error)
}

type ResolverRoot

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

type Token

type Token struct {
	Token string `json:"token"`
}

type User

type User struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Permissions []string `json:"permissions"`
	Login       string   `json:"login"`
	Enabled     bool     `json:"enabled"`
}

func (User) IsEntity

func (User) IsEntity()

Jump to

Keyboard shortcuts

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