generated

package
v0.0.0-...-21288f6 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: MIT Imports: 13 Imported by: 0

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 ComplexityRoot

type ComplexityRoot struct {
	Mutation struct {
		CreateProduct func(childComplexity int, input model.NewProduct) int
		CreateSku     func(childComplexity int, input model.NewSku) int
		DeleteProduct func(childComplexity int, productID int) int
		UpdateProduct func(childComplexity int, input model.EditProduct) int
	}

	Product struct {
		Code      func(childComplexity int) int
		CreatedAt func(childComplexity int) int
		DeletedAt func(childComplexity int) int
		Detail    func(childComplexity int) int
		ID        func(childComplexity int) int
		Name      func(childComplexity int) int
		Price     func(childComplexity int) int
		Skus      func(childComplexity int) int
		UpdatedAt func(childComplexity int) int
	}

	Query struct {
		Product  func(childComplexity int, id string) int
		Products func(childComplexity int) int
		Skus     func(childComplexity int) int
	}

	Sku struct {
		Code      func(childComplexity int) int
		CreatedAt func(childComplexity int) int
		DeletedAt func(childComplexity int) int
		ID        func(childComplexity int) int
		Name      func(childComplexity int) int
		Product   func(childComplexity int) int
		Stock     func(childComplexity int) int
		UpdatedAt func(childComplexity int) int
	}

	Subscription struct {
		UpdateProduct func(childComplexity int, id string) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DirectiveRoot

type DirectiveRoot struct {
}

type MutationResolver

type MutationResolver interface {
	CreateProduct(ctx context.Context, input model.NewProduct) (*model.Product, error)
	UpdateProduct(ctx context.Context, input model.EditProduct) (*model.Product, error)
	DeleteProduct(ctx context.Context, productID int) (int, error)
	CreateSku(ctx context.Context, input model.NewSku) (*model.Sku, error)
}

type ProductLoader

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

ProductLoader batches and caches requests

func NewProductLoader

func NewProductLoader(config ProductLoaderConfig) *ProductLoader

NewProductLoader creates a new ProductLoader given a fetch, wait, and maxBatch

func (*ProductLoader) Clear

func (l *ProductLoader) Clear(key int)

Clear the value at key from the cache, if it exists

func (*ProductLoader) Load

func (l *ProductLoader) Load(key int) (*model.Product, error)

Load a Product by key, batching and caching will be applied automatically

func (*ProductLoader) LoadAll

func (l *ProductLoader) LoadAll(keys []int) ([]*model.Product, []error)

LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured

func (*ProductLoader) LoadAllThunk

func (l *ProductLoader) LoadAllThunk(keys []int) func() ([]*model.Product, []error)

LoadAllThunk returns a function that when called will block waiting for a Products. This method should be used if you want one goroutine to make requests to many different data loaders without blocking until the thunk is called.

func (*ProductLoader) LoadThunk

func (l *ProductLoader) LoadThunk(key int) func() (*model.Product, error)

LoadThunk returns a function that when called will block waiting for a Product. This method should be used if you want one goroutine to make requests to many different data loaders without blocking until the thunk is called.

func (*ProductLoader) Prime

func (l *ProductLoader) Prime(key int, value *model.Product) bool

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

type ProductLoaderConfig

type ProductLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []int) ([]*model.Product, []error)

	// Wait is how long wait before sending a batch
	Wait time.Duration

	// MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit
	MaxBatch int
}

ProductLoaderConfig captures the config to create a new ProductLoader

type ProductResolver

type ProductResolver interface {
	CreatedAt(ctx context.Context, obj *model.Product) (*string, error)
	UpdatedAt(ctx context.Context, obj *model.Product) (*string, error)
	DeletedAt(ctx context.Context, obj *model.Product) (*string, error)
	Skus(ctx context.Context, obj *model.Product) ([]*model.Sku, error)
}

type QueryResolver

type QueryResolver interface {
	Products(ctx context.Context) ([]*model.Product, error)
	Product(ctx context.Context, id string) (*model.Product, error)
	Skus(ctx context.Context) ([]*model.Sku, error)
}

type ResolverRoot

type ResolverRoot interface {
	Mutation() MutationResolver
	Product() ProductResolver
	Query() QueryResolver
	Sku() SkuResolver
	Subscription() SubscriptionResolver
}

type SkuResolver

type SkuResolver interface {
	CreatedAt(ctx context.Context, obj *model.Sku) (*string, error)
	UpdatedAt(ctx context.Context, obj *model.Sku) (*string, error)
	DeletedAt(ctx context.Context, obj *model.Sku) (*string, error)
	Product(ctx context.Context, obj *model.Sku) (*model.Product, error)
}

type SkuSliceLoader

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

SkuSliceLoader batches and caches requests

func NewSkuSliceLoader

func NewSkuSliceLoader(config SkuSliceLoaderConfig) *SkuSliceLoader

NewSkuSliceLoader creates a new SkuSliceLoader given a fetch, wait, and maxBatch

func (*SkuSliceLoader) Clear

func (l *SkuSliceLoader) Clear(key int)

Clear the value at key from the cache, if it exists

func (*SkuSliceLoader) Load

func (l *SkuSliceLoader) Load(key int) ([]*model.Sku, error)

Load a Sku by key, batching and caching will be applied automatically

func (*SkuSliceLoader) LoadAll

func (l *SkuSliceLoader) LoadAll(keys []int) ([][]*model.Sku, []error)

LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured

func (*SkuSliceLoader) LoadAllThunk

func (l *SkuSliceLoader) LoadAllThunk(keys []int) func() ([][]*model.Sku, []error)

LoadAllThunk returns a function that when called will block waiting for a Skus. This method should be used if you want one goroutine to make requests to many different data loaders without blocking until the thunk is called.

func (*SkuSliceLoader) LoadThunk

func (l *SkuSliceLoader) LoadThunk(key int) func() ([]*model.Sku, error)

LoadThunk returns a function that when called will block waiting for a Sku. This method should be used if you want one goroutine to make requests to many different data loaders without blocking until the thunk is called.

func (*SkuSliceLoader) Prime

func (l *SkuSliceLoader) Prime(key int, value []*model.Sku) bool

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

type SkuSliceLoaderConfig

type SkuSliceLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []int) ([][]*model.Sku, []error)

	// Wait is how long wait before sending a batch
	Wait time.Duration

	// MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit
	MaxBatch int
}

SkuSliceLoaderConfig captures the config to create a new SkuSliceLoader

type SubscriptionResolver

type SubscriptionResolver interface {
	UpdateProduct(ctx context.Context, id string) (<-chan *model.Product, error)
}

Jump to

Keyboard shortcuts

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