Created
January 20, 2020 15:58
-
-
Save fwojciec/1a5ec088c9f8c1f9f378c5c91ead541d to your computer and use it in GitHub Desktop.
gqlserver2: dataloaders3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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