VulcanJS / Vulcan

🌋 A toolkit to quickly build apps with React, GraphQL & Meteor
http://vulcanjs.org
MIT License
7.98k stars 1.89k forks source link

Async/await support in custom filters #2438

Open SachaG opened 5 years ago

SachaG commented 5 years ago

See: https://github.com/VulcanJS/Vulcan/blob/devel/packages/vulcan-lib/lib/modules/mongoParams.js#L143

If the filter function is async, it returns after the main filterFunction function instead of properly waiting, which means its return value is not taken into account and the filter doesn’t work.

The only way to make it work so far is to make sure no async operation happens inside the filter, and then remove the await altogether.

eric-burel commented 4 years ago

As discussed on the Slack this line Object.keys(filter).forEach( { (110) should be await Promise.all( Object.keys(filter).map( async fieldName => ... instead.