Closed frederikhors closed 3 years ago
I think I found a strange thing here:
type DataLoader struct { ctx context.Context userLoader *dataloader.Loader } func (i *DataLoader) GetUser(userID string) (*model.User, error) { thunk := i.userLoader.Load(i.ctx, gopher_dataloader.StringKey(userID)) result, err := thunk() if err != nil { return nil, err } return result.(*model.User), nil }
You are calling i.ctx but that ctx on DataLoader type is never assigned in all your code in dataloader.go.
i.ctx
ctx
dataloader.go
Am I wrong?
Nice catch. Since the data loader is no longer request scoped, we should pass in the request context to the GetUser method
I think I found a strange thing here:
You are calling
i.ctx
but thatctx
on DataLoader type is never assigned in all your code indataloader.go
.Am I wrong?