Skip to content

Commit

Permalink
Merge pull request #34 from happylinks/master
Browse files Browse the repository at this point in the history
Pass info param to child resolvers
  • Loading branch information
thebigredgeek authored Jun 6, 2018
2 parents f0a1267 + 6428799 commit 95b8176
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const createResolver: CreateResolverFunction = <R, E>(resFn: ResultFuncti
// 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);
});
};

Expand Down
11 changes: 11 additions & 0 deletions test/unit/resolver_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' })
})
})
});

0 comments on commit 95b8176

Please sign in to comment.