You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Loads a key, returning a `Promise` for the value represented by that key.
'''
ifkeyisNone:
raiseTypeError((
'The loader.load() function must be called with a value,'+
'but got: {}.'
).format(key))
Which is rather limiting, consider an ORM with nullable FK:
classSomeObject(models.Model):
friend=models.ForeignKey(SomeObject, null=True, blank=True)
friends=models.ManyToManyField(SomeObject, blank=True)
defsome_object_resolver(parent, info, **kwargs):
# raises error when load is None! sad :(returndataloader.load(parent.friend_id)
defsome_object_resolver(parent, info, **kwargs):
# empty iterable is fine? yay? :)returndataloader.load_many([
friend.idforfriendinparent.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.
The text was updated successfully, but these errors were encountered:
This refers to this section of code:
promise/promise/dataloader.py
Lines 52 to 60 in b055d1e
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.The text was updated successfully, but these errors were encountered: