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

Aperta
#233 5 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
20/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
javascript, mongodb
Ambito
backend, databases

Direzione di ricerca

Non viene indicato alcun file né test. Inizia dal costruttore di DataLoader e dalla validazione della funzione batch che emette l’errore citato, quindi esamina il comportamento esistente per i documenti mancanti. Per l’issue è necessario concordare una scelta tra la rimozione del controllo della lunghezza e il riempimento automatico dei risultati mancanti, oltre a test che definiscano il comportamento previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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?
Lingua principale
JavaScript
Stelle
13.4k
Fork
522
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di graphql/dataloader

Tutte le issue di graphql/dataloader

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.