jkimbo / graphql-sync-dataloaders

Use DataLoaders in your Python GraphQL servers that have to run in a sync context (i.e. Django).
MIT License
41 stars 21 forks source link

Iterable may not support len #14

Open genericmoniker opened 1 year ago

genericmoniker commented 1 year ago

Thanks for the library! I'm trying to update an application to a current set of GraphQL libraries and this one could be helpful in that effort.

I ran into a problem trying to use it with a resolver function that returns an iterable value, but the value doesn't have __len__. In my case, it is a SQLAlchemy Query object, though a simple generator ought to behave similarly.

The trouble comes at this line:

results: List[Any] = [None] * len(result)

Which raises an exception for the type not having len(). The check earlier in the function for is_iterable(result) passes fine.