generated

package
v0.0.0-...-084ef01 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2020 License: MIT Imports: 12 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 {
		TodoComplete func(childComplexity int, id int, updatedBy int) int
		TodoCreate   func(childComplexity int, todo models.TodoInput) int
		TodoDelete   func(childComplexity int, id int, updatedBy int) int
		UserCreate   func(childComplexity int, user models.UserInput) int
	}

	Query struct {
		Todo  func(childComplexity int, id int) int
		Todos func(childComplexity int, limit *int, offset *int) int
		User  func(childComplexity int, id int) int
		Users func(childComplexity int, limit *int, offset *int) int
	}

	Todo struct {
		CreatedAt  func(childComplexity int) int
		CreatedBy  func(childComplexity int) int
		ID         func(childComplexity int) int
		IsComplete func(childComplexity int) int
		IsDeleted  func(childComplexity int) int
		Name       func(childComplexity int) int
		UpdatedAt  func(childComplexity int) int
		UpdatedBy  func(childComplexity int) int
	}

	User struct {
		CreatedAt func(childComplexity int) int
		Email     func(childComplexity int) int
		FirstName func(childComplexity int) int
		ID        func(childComplexity int) int
		LastName  func(childComplexity int) int
		UpdatedAt func(childComplexity int) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DirectiveRoot

type DirectiveRoot struct {
}

type MutationResolver

type MutationResolver interface {
	TodoCreate(ctx context.Context, todo models.TodoInput) (*models.Todo, error)
	TodoComplete(ctx context.Context, id int, updatedBy int) (*models.Todo, error)
	TodoDelete(ctx context.Context, id int, updatedBy int) (*models.Todo, error)
	UserCreate(ctx context.Context, user models.UserInput) (*models.User, error)
}

type QueryResolver

type QueryResolver interface {
	Todo(ctx context.Context, id int) (*models.Todo, error)
	Todos(ctx context.Context, limit *int, offset *int) ([]models.Todo, error)
	User(ctx context.Context, id int) (*models.User, error)
	Users(ctx context.Context, limit *int, offset *int) ([]models.User, error)
}

type ResolverRoot

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

type TodoResolver

type TodoResolver interface {
	CreatedBy(ctx context.Context, obj *models.Todo) (*models.User, error)
	UpdatedBy(ctx context.Context, obj *models.Todo) (*models.User, error)
}

type UserLoader

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

UserLoader batches and caches requests

func NewUserLoader

func NewUserLoader(config UserLoaderConfig) *UserLoader

NewUserLoader creates a new UserLoader given a fetch, wait, and maxBatch

func (*UserLoader) Clear

func (l *UserLoader) Clear(key int)

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

func (*UserLoader) Load

func (l *UserLoader) Load(key int) (*models.User, error)

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

func (*UserLoader) LoadAll

func (l *UserLoader) LoadAll(keys []int) ([]*models.User, []error)

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

func (*UserLoader) LoadAllThunk

func (l *UserLoader) LoadAllThunk(keys []int) func() ([]*models.User, []error)

LoadAllThunk returns a function that when called will block waiting for a Users. 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 (*UserLoader) LoadThunk

func (l *UserLoader) LoadThunk(key int) func() (*models.User, error)

LoadThunk returns a function that when called will block waiting for a User. 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 (*UserLoader) Prime

func (l *UserLoader) Prime(key int, value *models.User) 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 UserLoaderConfig

type UserLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []int) ([]*models.User, []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
}

UserLoaderConfig captures the config to create a new UserLoader

Jump to

Keyboard shortcuts

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