apollo-resolvers icon indicating copy to clipboard operation
apollo-resolvers copied to clipboard

Wrong resolvers condition when or(true, false) and final resolver throws

Open newsiberian opened this issue 5 years ago • 1 comments

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

newsiberian avatar Nov 23 '18 09:11 newsiberian

Just meet same issue few hours ago

klymenko-serhii avatar Nov 23 '18 15:11 klymenko-serhii