Open touyu opened 4 years ago
i have the same problem,are you resolved it?
I came up with one solution.
$ go run github.com/vektah/dataloaden IssueConnectionLoader Param *model_path/model.IssueConnection
type Param struct {
Key uint
First *int
After *stirng
}
Loader := IssueConnectionLoader{
maxBatch: 100,
wait: 1 * time.Millisecond,
fetch: func(ids []Param) ([]*model.IssueConnection, []error) {
// You can use `first` or `last` param etc...
},
}
func (r *repositoryResolver) IssueConnection(ctx context.Context, obj *model.Repository, first *int) (*model.IssueConnection, error) {
param := dataloader.Param{
Key: obj.id,
First: first,
}
return dataloader.For(ctx).Loader.Load(param)
}
For example, if you request with GitHub GraphQL API with the following query, the result will be returned considering first and after.
Probably, if I implement something similar api with gqlgen, I should use dataloader for
issues
. However I can only pass keys to dataloader. How should I pass first, after, etc. information?