dataloader-bundle icon indicating copy to clipboard operation
dataloader-bundle copied to clipboard

Allow to add a null value in the list of keys

Open jourdan-qe opened this issue 4 years ago • 2 comments

Hello,

I'm using your excellent GraphQL bundle and so the dataloader.

In one of my type, I need to load another type using the dataloader. To do that, I use a property of my first type, but this property can be null sometimes. Of course, the result for this key would be null and this is what I'm looking for. But now, this throws an error because of the checkKey method of overblog/dataloader-php/src/DataLoader.php

Thank you a lot Jourdan

jourdan-qe avatar Mar 27 '20 14:03 jourdan-qe

Faced the same problem

pvlg avatar Jul 07 '21 09:07 pvlg

Shouldn't you do a check in the resolver

if(!$root->nullable) {
   return null;
}
return $this->dataLoader->load($root->nullable);

Warxcell avatar Apr 12 '22 17:04 Warxcell