[Feature request] Remove same length check or auto full fill

Đang mở
#233 5 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
20/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, mongodb
Lĩnh vực
backend, databases

Hướng nghiên cứu

Không có tệp hoặc test nào được nêu tên. Hãy bắt đầu từ constructor của DataLoader và phần validation của batch function phát ra lỗi được trích dẫn, sau đó xem xét hành vi hiện có đối với các document bị thiếu. Issue này cần một lựa chọn đã được thống nhất giữa việc loại bỏ kiểm tra độ dài và tự động điền các kết quả bị thiếu, cùng với các test xác định hành vi được mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

What problem are you trying to solve?

“DataLoader must be constructed with function which accepts Array and returns Promise>, but the function did not return a Promise of an Array of the same length as the Array of keys”

Describe the solution you'd like

In practice using a NoSql database like mongodb, some referenced document missing is not a serious problem, but this length check make things terrible, for example

user1 = { id: ObjectId(user1) }   
user2 = {id: ObjectId(user2) }
// user3 has been deleted, but associated data has not been cleaned yet.

post1 = {id: ObjectId(post1), author: ObjectId(user3) }  // here reference user3 is not exist now
post2= {id: ObjectId(post2), author: ObjectId(user1) }
post3= {id: ObjectId(post3), author: ObjectId(user2) }

// now if I make a dataloader for Users,  the array length obviously not equal !!
const usersLoader = new DataLoader(
keys => async (keys, {Users}) => {
  return await Users.find({id: {$in: keys}}).toArray()
}, 
{ cacheKeyFn: key => key.toString() }
)

Describe alternatives you've considered

My questions are:

  1. Is this length check necessary?or is a little bit over coupled feature?
  2. what's the correct pattern to deal with document missing with dataloader?
Ngôn ngữ chính
JavaScript
Star
13.4k
Fork
522
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của graphql/dataloader

Tất cả issue của graphql/dataloader

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.