Skip to content

Commit

Permalink
fix: typo in dataloader code sample (#1954)
Browse files Browse the repository at this point in the history
* fix: typo in dataloader code sample

* rename k to key for sample to compile
  • Loading branch information
plog3050 authored Feb 8, 2022
1 parent a054373 commit 9262b35
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/content/reference/dataloaders.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ type UserReader struct {
func (u *UserReader) GetUsers(ctx context.Context, keys dataloader.Keys) []*dataloader.Result {
// read all requested users in a single query
userIDs := make([]string, len(keys))
for ix, k := range keys {
for ix, key := range keys {
userIDs[ix] = key.String()
}
res := u.db.Exec(
Expand Down Expand Up @@ -140,7 +140,7 @@ func NewLoaders(conn *sql.DB) *Loaders {
func Middleware(loaders *Loaders, next http.Handler) http.Handler {
// return a middleware that injects the loader to the request context
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
nextCtx := context.WithValue(r.Context(), loadersKey, loader)
nextCtx := context.WithValue(r.Context(), loadersKey, loaders)
r = r.WithContext(nextCtx)
next.ServeHTTP(w, r)
})
Expand Down

0 comments on commit 9262b35

Please sign in to comment.