Skip to content

Instantly share code, notes, and snippets.

@fwojciec
Created January 20, 2020 15:58
Show Gist options
  • Save fwojciec/1a5ec088c9f8c1f9f378c5c91ead541d to your computer and use it in GitHub Desktop.
Save fwojciec/1a5ec088c9f8c1f9f378c5c91ead541d to your computer and use it in GitHub Desktop.
gqlserver2: dataloaders3
// Retriever retrieves dataloaders from the request context.
type Retriever interface {
Retrieve(context.Context) *Loaders
}
type retriever struct {
key contextKey
}
func (r *retriever) Retrieve(ctx context.Context) *Loaders {
return ctx.Value(r.key).(*Loaders)
}
// NewRetriever instantiates a new implementation of Retriever.
func NewRetriever() Retriever {
return &retriever{key: key}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment