loader

package
v0.0.0-...-59ea8a7 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUser

func GetUser(ctx context.Context, userID string) (*model.User, error)

GetUser returns single user by id efficiently

func GetUsers

func GetUsers(ctx context.Context, userIDs []string) ([]*model.User, error)

GetUsers returns many users by ids efficiently

func Middleware

func Middleware(userStorage *storage.UserStorage, next http.Handler) http.Handler

Middleware injects data loaders into the context

func PrimeUser

func PrimeUser(ctx context.Context, user *model.User) bool

PrimeUser primes the user loader cache

Types

type Loaders

type Loaders struct {
	UserLoader *dataloadgen.Loader[string, *model.User]
}

Loaders wrap your data loaders to inject via middleware

func For

func For(ctx context.Context) *Loaders

For returns the dataloader for a given context

func NewLoaders

func NewLoaders(s *storage.UserStorage) *Loaders

NewLoaders instantiates data loaders for the middleware

Jump to

Keyboard shortcuts

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