From 5b877aad2003f83fe5c4bed23fef9350012d84d8 Mon Sep 17 00:00:00 2001 From: Michiel Westerbeek Date: Mon, 4 Jun 2018 22:56:32 +0200 Subject: [PATCH] Pass info param to child resolvers --- src/resolver.ts | 2 +- test/unit/resolver_spec.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/resolver.ts b/src/resolver.ts index 61c4957..c9c2207 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -30,7 +30,7 @@ export const createResolver = (resFn, errFn) => { // If the parent returns a value, continue if (isNotNullOrUndefined(r)) return r; // Call the child resolver function or a no-op (returns null) - return isFunction(cResFn) ? Promisify(cResFn)(root, args, context) : Promise.resolve(null); + return isFunction(cResFn) ? Promisify(cResFn)(root, args, context, info) : Promise.resolve(null); }); }; diff --git a/test/unit/resolver_spec.js b/test/unit/resolver_spec.js index eb3d17b..d4cdb9a 100644 --- a/test/unit/resolver_spec.js +++ b/test/unit/resolver_spec.js @@ -185,5 +185,16 @@ describe('(unit) dist/resolver.js', () => { baseResolver(null, null, null, { info: 'info' }) chainedResolver(null, null, null, { chained: 'info' }) }) + it('should pass the info parameter to child resolvers', () => { + const childHandle = (root, args, context, info) => { + expect(typeof info).to.equal('object') + expect(info.info).to.equal('info') + }; + + const baseResolver = createResolver(); + const childResolver = baseResolver.createResolver(childHandle) + + childResolver(null, null, null, { info: 'info' }) + }) }) });