Skip to content

Commit

Permalink
composable funtion comment header
Browse files Browse the repository at this point in the history
  • Loading branch information
mringer committed May 18, 2018
1 parent fa0e13e commit 84696cf
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 12 deletions.
9 changes: 7 additions & 2 deletions dist/helper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ export declare const or: (...conditions: any[]) => (resolver: any) => (...query:
/**
* Constructs a composable resolver with the same arguments as createResolver.
* The composable resolver provides the compose method which takes an object of named resolver functions.
* @param resFn resolver function
* @param errFn error handler
* The resolvers object can contain, constructed resolver functions or { resolve: fn, error: fn } params
* to construct a new resolver. Compose returns an object of resolvers who inherit from the baseResolver
* on which compose was called.
*
* @param resFn: resolver function
* @param errFn: error handler
* @returns resolverFn: { createResolver(resFn, errFn), compose({ resolvers }): { composed resolvers } ...}
*/
export declare const composable: (resFn: any, errFn: any) => (root: any, args?: {}, context?: {}, info?: {}) => Promise<any>;
10 changes: 7 additions & 3 deletions dist/helper.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/helper.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { usePromise } from './promise';
import { combineResolvers } from './helper';
import { combineResolvers, and, or } from './helper';
import { createExpressContext } from './context';
import { createResolver } from './resolver';
export { usePromise, combineResolvers, createExpressContext, createResolver };
export { usePromise, combineResolvers, createExpressContext, createResolver, and, or };
2 changes: 2 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ export const or = (...conditions) => resolver => (...query) => {
/**
* Constructs a composable resolver with the same arguments as createResolver.
* The composable resolver provides the compose method which takes an object of named resolver functions.
* @param resFn resolver function
* @param errFn error handler
* The resolvers object can contain, constructed resolver functions or { resolve: fn, error: fn } params
* to construct a new resolver. Compose returns an object of resolvers who inherit from the baseResolver
* on which compose was called.
*
* @param resFn: resolver function
* @param errFn: error handler
* @returns resolverFn: { createResolver(resFn, errFn), compose({ resolvers }): { composed resolvers } ...}
*/
export const composable = (resFn, errFn) => {
const baseResolver = createResolver(resFn, errFn);
Expand All @@ -43,7 +48,6 @@ export const composable = (resFn, errFn) => {
const composed = {};
Object.keys(resolvers).forEach(key => {
const resolver = resolvers[key];
// composed[key] = baseResolver['createResolver'](resolver);
composed[key] = (resolver.resolve || resolver.error)
// supports syntax: compose( { myResolver: { resolve: resFn, error: errFn } } )
? baseResolver['createResolver'](resolver.resolve, resolver.error)
Expand Down

0 comments on commit 84696cf

Please sign in to comment.