Closed Daavidaviid closed 5 years ago
Hi, Thanks for the good work.
I was wondering, how would one proceed to have pagination with dataloaden (or dataloader more globally) ?
For instance with ordersByCustomer, we currently have :
ordersByCustomer
// 1:M loader ldrs.ordersByCustomer = &OrderSliceLoader{ wait: wait, maxBatch: 100, fetch: func(keys []int) ([][]Order, []error) { var keySql []string for _, key := range keys { keySql = append(keySql, strconv.Itoa(key)) } fmt.Printf("SELECT * FROM orders WHERE customer_id IN (%s)\n", strings.Join(keySql, ",")) time.Sleep(5 * time.Millisecond) // ... return orders, errors }, }
Could ordersByCustomer become something like this :
// 1:M loader ldrs.ordersByCustomer = &OrderSliceLoader{ wait: wait, maxBatch: 100, fetch: func(keys []int, last int, from Date) ([][]Order, []error) { // <-- HERE var keySql []string for _, key := range keys { keySql = append(keySql, strconv.Itoa(key)) } fmt.Printf("SELECT * FROM orders WHERE customer_id IN (%s) AND WHERE created_at > (%s) LIMIT (%d)", strings.Join(keySql, ","), from, last) // <-- HERE time.Sleep(5 * time.Millisecond) // ... return orders, errors }, }
Or do I need to hack something using the example with context ?
Regards, David.
I just realized that it was a pretty dumb question actually.... 😱
Hi, Thanks for the good work.
I was wondering, how would one proceed to have pagination with dataloaden (or dataloader more globally) ?
For instance with
ordersByCustomer
, we currently have :Could
ordersByCustomer
become something like this :Or do I need to hack something using the example with context ?
Regards, David.