Which is rather limiting, consider an ORM with nullable FK:
class SomeObject(models.Model):
friend = models.ForeignKey(SomeObject, null=True, blank=True)
friends = models.ManyToManyField(SomeObject, blank=True)
def some_object_resolver(parent, info, **kwargs):
# raises error when load is None! sad :(
return dataloader.load(parent.friend_id)
def some_object_resolver(parent, info, **kwargs):
# empty iterable is fine? yay? :)
return dataloader.load_many([
friend.id for friend in parent.friends.all()
])
For the most reusable DataLoaders it would be nice to allow None to pass through such that batch_load_fn() handles empty values without an issue.
I suppose the alternative is just to return None directly from the resolver if the friend_id is None, but for reusableness' sake it would be awesome to not add that conditional.
This refers to this section of code:
https://github.com/syrusakbary/promise/blob/b055d1e2aa1368062bc4f265b525bf2e48fadc47/promise/dataloader.py#L52-L60
Which is rather limiting, consider an ORM with nullable FK:
For the most reusable DataLoaders it would be nice to allow
None
to pass through such thatbatch_load_fn()
handles empty values without an issue.I suppose the alternative is just to return
None
directly from the resolver if thefriend_id
isNone
, but for reusableness' sake it would be awesome to not add that conditional.