Documentation ¶
Index ¶
- func NewExecutableSchema(cfg Config) graphql.ExecutableSchema
- type ComplexityRoot
- type Config
- type DirectiveRoot
- type MutationResolver
- type ProductLoader
- func (l *ProductLoader) Clear(key int)
- func (l *ProductLoader) Load(key int) (*model.Product, error)
- func (l *ProductLoader) LoadAll(keys []int) ([]*model.Product, []error)
- func (l *ProductLoader) LoadAllThunk(keys []int) func() ([]*model.Product, []error)
- func (l *ProductLoader) LoadThunk(key int) func() (*model.Product, error)
- func (l *ProductLoader) Prime(key int, value *model.Product) bool
- type ProductLoaderConfig
- type ProductResolver
- type QueryResolver
- type ResolverRoot
- type SkuResolver
- type SkuSliceLoader
- func (l *SkuSliceLoader) Clear(key int)
- func (l *SkuSliceLoader) Load(key int) ([]*model.Sku, error)
- func (l *SkuSliceLoader) LoadAll(keys []int) ([][]*model.Sku, []error)
- func (l *SkuSliceLoader) LoadAllThunk(keys []int) func() ([][]*model.Sku, []error)
- func (l *SkuSliceLoader) LoadThunk(key int) func() ([]*model.Sku, error)
- func (l *SkuSliceLoader) Prime(key int, value []*model.Sku) bool
- type SkuSliceLoaderConfig
- type SubscriptionResolver
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 ResolverRoot ¶
type ResolverRoot interface { Mutation() MutationResolver Product() ProductResolver Query() QueryResolver Sku() SkuResolver Subscription() SubscriptionResolver }
type SkuResolver ¶
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