apollo-resolvers
apollo-resolvers copied to clipboard
Wrong resolvers condition when or(true, false) and final resolver throws
Hi, funny thing. Not all cases are covered in tests and there is a bug with one of these.
Here is an example of test with or
condition:
// test/unit/helper_spec.js
it('when (true, false) and resolver throws, it should return exactly that error', () => {
const resolver = or(successResolver, failureResolver);
const testError = new Error('test');
const finalResolver = resolver(() => {
throw testError;
});
return finalResolver()
.catch(err => {
expect(err).to.equal(testError);
});
});
So, if first resolver succeed it immediately runs query. But if query throws, second resolver runs after that and if it is throws, we receive that second error, but not the error that query throws
Just meet same issue few hours ago