From 18de31554021762dfdae9df9079bf8939ba4bc3b Mon Sep 17 00:00:00 2001 From: Glenn Sonna Date: Mon, 21 May 2018 18:43:56 -0500 Subject: [PATCH 1/6] Added concrete types and generics to define resolvers --- dist/resolver.js.map | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/resolver.js.map b/dist/resolver.js.map index ef15a6c..ee7ae40 100644 --- a/dist/resolver.js.map +++ b/dist/resolver.js.map @@ -1 +1 @@ -{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AACvC,iCAAqE;AAGxD,QAAA,cAAc,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IAC7C,MAAM,OAAO,GAAG,oBAAU,EAAE,CAAC;IAC7B,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;QAChE,wFAAwF;QACxF,IAAI,CAAC,iBAAU,CAAC,KAAK,CAAC;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACrD,OAAO,gBAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YAC3D,kFAAkF;YAClF,IAAI,CAAC,iBAAU,CAAC,KAAK,CAAC;gBAAE,MAAM,CAAC,CAAC;YAChC,0BAA0B;YAC1B,OAAO,gBAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;gBACjE,mEAAmE;gBACnE,MAAM,WAAW,IAAI,CAAC,CAAA;YACxB,CAAC,EAAE,WAAW,CAAC,EAAE;gBACf,iEAAiE;gBACjE,MAAM,WAAW,IAAI,CAAC,CAAA;YACxB,CAAC,CAAC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F,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG;YAC1C,sEAAsE;YACtE,MAAM,KAAK,GAAG,iBAAU,CAAC,MAAM,CAAC,GAAG,gBAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAEvG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACjB,yCAAyC;gBACzC,EAAE,CAAC,CAAC,2BAAoB,CAAC,CAAC,CAAC,CAAC;oBAAC,MAAM,CAAC,CAAC;gBACrC,0DAA0D;gBAC1D,MAAM,CAAC,iBAAU,CAAC,KAAK,CAAC,GAAG,gBAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;oBAC1E,kEAAkE;oBAClE,MAAM,CAAC,IAAI,GAAG,CAAC;gBACjB,CAAC,EAAE,CAAC;oBACF,iEAAiE;oBACjE,MAAM,CAAC,IAAI,GAAG,CAAC;gBACjB,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,0CAA0C;QAC1C,MAAM,CAAC,sBAAc,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC,CAAA;IAED,MAAM,CAAC,YAAY,CAAC;AACtB,CAAC,CAAC"} \ No newline at end of file From ce3f39381877b49f729c55657d140530d104332c Mon Sep 17 00:00:00 2001 From: Glenn Sonna Date: Mon, 21 May 2018 18:44:20 -0500 Subject: [PATCH 2/6] Added concrete types and generics to define resolvers --- src/resolver.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/resolver.ts b/src/resolver.ts index 61c4957..d316493 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -1,10 +1,24 @@ import { getPromise } from './promise'; import { isFunction, Promisify, isNotNullOrUndefined } from './util'; +const Promise = getPromise(); -export const createResolver = (resFn, errFn) => { +export interface ResultFunction { + (root, args, context, info): Promise | ResulType | void +} + +export interface ErrorFunction { + (root, args, context, err): ErrorType | void +} + +export interface Resolver { + (root, args: {}, context: {}, info: {}): Promise + createResolver?: (resFn: ResultFunction, errFn?: ErrorFunction) => Resolver +} + +export const createResolver = (resFn: ResultFunction, errFn: ErrorFunction) => { const Promise = getPromise(); - const baseResolver = (root, args = {}, context = {}, info = {}) => { + const baseResolver: Resolver = (root, args = {}, context = {}, info = {}) => { // Return resolving promise with `null` if the resolver function param is not a function if (!isFunction(resFn)) return Promise.resolve(null); return Promisify(resFn)(root, args, context, info).catch(e => { @@ -20,7 +34,7 @@ export const createResolver = (resFn, errFn) => { }); }); }; - baseResolver['createResolver'] = (cResFn, cErrFn) => { + baseResolver.createResolver = (cResFn, cErrFn) => { const Promise = getPromise(); const childResFn = (root, args, context, info = {}) => { From 2af690838f4ab2427d2bfd8c430093d629380286 Mon Sep 17 00:00:00 2001 From: Glenn Sonna Date: Mon, 21 May 2018 18:44:50 -0500 Subject: [PATCH 3/6] Revert "Added concrete types and generics to define resolvers" This reverts commit 18de31554021762dfdae9df9079bf8939ba4bc3b. --- dist/resolver.js.map | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/resolver.js.map b/dist/resolver.js.map index ee7ae40..ef15a6c 100644 --- a/dist/resolver.js.map +++ b/dist/resolver.js.map @@ -1 +1 @@ -{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AACvC,iCAAqE;AAErE,MAAM,OAAO,GAAG,oBAAU,EAAE,CAAC;AAehB,QAAA,cAAc,GAAG,CAAO,KAAwB,EAAE,KAAuB;IACpF,MAAM,OAAO,GAAG,oBAAU,EAAE,CAAC;IAC7B,MAAM,YAAY,GAAg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C,IAAI,CAAC,CAAC,CAAC,EAAE;oBAC7E,kEAAkE;oBAClE,MAAM,CAAC,IAAI,GAAG,CAAC;gBACjB,CAAC,EAAE,CAAC,CAAC,EAAE;oBACL,iEAAiE;oBACjE,MAAM,CAAC,IAAI,GAAG,CAAC;gBACjB,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,0CAA0C;QAC1C,OAAO,sBAAc,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC,CAAA;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC"} \ No newline at end of file From 1f94782ecc7b9de9bdca690b47374ee2dbcebbed Mon Sep 17 00:00:00 2001 From: Glenn Sonna Date: Mon, 21 May 2018 18:47:48 -0500 Subject: [PATCH 4/6] Added typescript function check to utils at isFunction --- dist/context.js.map | 2 +- dist/helper.js.map | 2 +- dist/index.d.ts | 4 ++-- dist/index.js | 2 ++ dist/index.js.map | 2 +- dist/promise.js.map | 2 +- dist/resolver.d.ts | 12 +++++++++++- dist/resolver.js | 3 ++- dist/resolver.js.map | 2 +- dist/util.d.ts | 2 +- dist/util.js | 4 ++-- dist/util.js.map | 2 +- src/util.ts | 2 +- 13 files changed, 27 insertions(+), 14 deletions(-) diff --git a/dist/context.js.map b/dist/context.js.map index a0aa1eb..ad30cef 100644 --- a/dist/context.js.map +++ b/dist/context.js.map @@ -1 +1 @@ -{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAIhC,CAAC;AACW,QAAA,oBAAoB,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IAChD,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;IAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,C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map b/dist/helper.js.map index 6602270..420eeb5 100644 --- a/dist/helper.js.map +++ b/dist/helper.js.map @@ -1 +1 @@ -{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":";;AAAA,mCAAmC;AAEnC,oIAAoI;AACvH,QAAA,gBAAgB,GAAG,CAAC,SAAS,GAAG,EAAE,EAAE,EAAE,CAAC,SAAS;KAC1D,MAAM,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE7D,wFAAwF;AACxF,yFAAyF;AAC5E,QAAA,GAAG,GAAG,CAAC,GAAG,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE;IAC/C,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACrC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC,EAAE,QAAQ,CAAC,CAAA;AACd,CAAC,CAAA;AAED,wFAAwF;AACxF,wFAAwF;AAC3E,QAAA,EAAE,GAAG,CAAC,GAAG,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,EAAE,EAAE;IAC5D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,KAAK,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG,CAAC,CAAC,EAAE,EAAE,CACpB,UAAU,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,GAAG,KAAK,CAAC;aAC7C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;aACzB,KAAK,CAAC,GAAG,CAAC,EAAE;YACX,IAAG,CAAC,KAAK,KAAK;gBAAE,MAAM,CAAC,GAAG,CAAC,CAA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AO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;QACP,OAAO,CAAC,CAAC,CAAC,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts index 8be43e8..1034f5d 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -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 }; diff --git a/dist/index.js b/dist/index.js index c1bd5b2..b8915cc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4,6 +4,8 @@ const promise_1 = require("./promise"); exports.usePromise = promise_1.usePromise; const helper_1 = require("./helper"); exports.combineResolvers = helper_1.combineResolvers; +exports.and = helper_1.and; +exports.or = helper_1.or; const context_1 = require("./context"); exports.createExpressContext = context_1.createExpressContext; const resolver_1 = require("./resolver"); diff --git a/dist/index.js.map b/dist/index.js.map index 24bc5a2..3c385fd 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAMrC,qBANO,oBAAU,CAMP;AALZ,qCAA4C;AAM1C,2BANO,yBAAgB,CAMP;AALlB,uCAAiD;AAM/C,+BANO,8BAAoB,CAMP;AALtB,yCAA4C;AAM1C,yBANO,yBAAc,CAMP"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAMrC,qBANO,oBAAU,CAMP;AALZ,qCAAqD;AAMnD,2BANO,yBAAgB,CAMP;AAGhB,cATyB,YAAG,CASzB;AACH,aAV8B,WAAE,CAU9B;AATJ,uCAAiD;AAM/C,+BANO,8BAAoB,CAMP;AALtB,yCAA4C;AAM1C,yBANO,yBAAc,CAMP"} \ No newline at end of file diff --git a/dist/promise.js.map b/dist/promise.js.map index 164c5ba..647345e 100644 --- a/dist/promise.js.map +++ b/dist/promise.js.map @@ -1 +1 @@ -{"version":3,"file":"promise.js","sourceRoot":"","sources":["../src/promise.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAEjC,gGAAgG;AAChG,IAAI,CAAC,GAAG,OAAO,CAAC;AAEhB,4CAA4C;AAC/B,QAAA,UAAU,GAAG,IAAI,CAAC,EAAE;IAC/B,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,0DAA0D,CAAC,CAAC;IAC3F,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,oGAAoG,CAAC,CAAC;IAC7H,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,mGAAmG,CAAC,CAAC;IAC3H,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,gGAAgG,CAAC,CAAC;IACrH,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,uHAAuH,CAAC,CAAC;IACvJ,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,wHAAwH,CAAC,CAAC;IACzJ,CAAC,GAAG,IAAI,CAAC;AACX,CAAC,CAAC;AAEF,4CAA4C;AAC/B,QAAA,UAAU,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"promise.js","sourceRoot":"","sources":["../src/promise.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAEjC,gGAAgG;AAChG,IAAI,CAAC,GAAG,OAAO,CAAC;AAEhB,4CAA4C;AAC/B,QAAA,UAAU,GAAG,IAAI;IAC5B,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,0DAA0D,CAAC,CAAC;IAC3F,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,oGAAoG,CAAC,CAAC;IAC7H,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,mGAAmG,CAAC,CAAC;IAC3H,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,gGAAgG,CAAC,CAAC;IACrH,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,uHAAuH,CAAC,CAAC;IACvJ,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,wHAAwH,CAAC,CAAC;IACzJ,CAAC,GAAG,IAAI,CAAC;AACX,CAAC,CAAC;AAEF,4CAA4C;AAC/B,QAAA,UAAU,GAAG,MAAM,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/resolver.d.ts b/dist/resolver.d.ts index 0f966db..4e421b1 100644 --- a/dist/resolver.d.ts +++ b/dist/resolver.d.ts @@ -1 +1,11 @@ -export declare const createResolver: (resFn: any, errFn: any) => (root: any, args?: {}, context?: {}, info?: {}) => Promise; +export interface ResultFunction { + (root: any, args: any, context: any, info: any): Promise | ResulType | void; +} +export interface ErrorFunction { + (root: any, args: any, context: any, err: any): ErrorType | void; +} +export interface Resolver { + (root: any, args: {}, context: {}, info: {}): Promise; + createResolver?: (resFn: ResultFunction, errFn?: ErrorFunction) => Resolver; +} +export declare const createResolver: (resFn: ResultFunction, errFn: ErrorFunction) => Resolver; diff --git a/dist/resolver.js b/dist/resolver.js index d505d4d..f23fb8f 100644 --- a/dist/resolver.js +++ b/dist/resolver.js @@ -2,6 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const promise_1 = require("./promise"); const util_1 = require("./util"); +const Promise = promise_1.getPromise(); exports.createResolver = (resFn, errFn) => { const Promise = promise_1.getPromise(); const baseResolver = (root, args = {}, context = {}, info = {}) => { @@ -22,7 +23,7 @@ exports.createResolver = (resFn, errFn) => { }); }); }; - baseResolver['createResolver'] = (cResFn, cErrFn) => { + baseResolver.createResolver = (cResFn, cErrFn) => { const Promise = promise_1.getPromise(); const childResFn = (root, args, context, info = {}) => { // Start with either the parent resolver function or a no-op (returns null) diff --git a/dist/resolver.js.map b/dist/resolver.js.map index ef15a6c..ee7ae40 100644 --- a/dist/resolver.js.map +++ b/dist/resolver.js.map @@ -1 +1 @@ -{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AACvC,iCAAqE;AAGxD,QAAA,cAAc,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IAC7C,MAAM,OAAO,GAAG,oBAAU,EAAE,CAAC;IAC7B,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;QAChE,wFAAwF;QACxF,IAAI,CAAC,iBAAU,CAAC,KAAK,CAAC;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACrD,OAAO,gBAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YAC3D,kFAAkF;YAClF,IAAI,CAAC,iBAAU,CAAC,KAAK,CAAC;gBAAE,MAAM,CAAC,CAAC;YAChC,0BAA0B;YAC1B,OAAO,gBAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;gBACjE,mEAAmE;gBACnE,MAAM,WAAW,IAAI,CAAC,CAAA;YACxB,CAAC,EAAE,WAAW,CAAC,EAAE;gBACf,iEAAiE;gBACjE,MAAM,WAAW,IAAI,CAAC,CAAA;YACxB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IACF,YAAY,CAAC,gBAAgB,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1C,sEAAsE;YACtE,MAAM,KAAK,GAAG,iBAAU,CAAC,MAAM,CAAC,GAAG,gBAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAEvG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACjB,yCAAyC;gBACzC,EAAE,CAAC,CAAC,2BAAoB,CAAC,CAAC,CAAC,CAAC;oBAAC,MAAM,CAAC,CAAC;gBACrC,0DAA0D;gBAC1D,MAAM,CAAC,iBAAU,CAAC,KAAK,CAAC,GAAG,gBAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;oBAC1E,kEAAkE;oBAClE,MAAM,CAAC,IAAI,GAAG,CAAC;gBACjB,CAAC,EAAE,CAAC;oBACF,iEAAiE;oBACjE,MAAM,CAAC,IAAI,GAAG,CAAC;gBACjB,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,0CAA0C;QAC1C,MAAM,CAAC,sBAAc,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC,CAAA;IAED,MAAM,CAAC,YAAY,CAAC;AACtB,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/util.d.ts b/dist/util.d.ts index 1d83213..6c7ffb0 100644 --- a/dist/util.d.ts +++ b/dist/util.d.ts @@ -1,3 +1,3 @@ export declare const isFunction: (fn: any) => boolean; -export declare const Promisify: (fn: any) => (...args: any[]) => Promise<{}>; +export declare const Promisify: (fn: any) => (...args: any[]) => Promise<{}>; export declare const isNotNullOrUndefined: (val: any) => boolean; diff --git a/dist/util.js b/dist/util.js index 30313ca..c1aedd7 100644 --- a/dist/util.js +++ b/dist/util.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const promise_1 = require("./promise"); -exports.isFunction = fn => typeof fn === 'function'; -exports.Promisify = fn => { +exports.isFunction = fn => typeof fn === 'function' || fn instanceof Function; +exports.Promisify = (fn) => { const Promise = promise_1.getPromise(); return (...args) => new Promise((resolve, reject) => { try { diff --git a/dist/util.js.map b/dist/util.js.map index d1a4263..16e1529 100644 --- a/dist/util.js.map +++ b/dist/util.js.map @@ -1 +1 @@ -{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAE1B,QAAA,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,UAAU,CAAC;AAE5C,QAAA,SAAS,GAAG,EAAE,CAAC,EAAE;IAC5B,MAAM,OAAO,GAAG,oBAAU,EAAE,CAAC;IAC7B,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAClD,IAAI;YACF,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3E;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;SAClB;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEW,QAAA,oBAAoB,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,CAAC"} \ No newline at end of file +{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAE1B,QAAA,UAAU,GAAG,EAAE,IAAI,OAAO,EAAE,KAAK,UAAU,IAAI,EAAE,YAAY,QAAQ,CAAA;AAErE,QAAA,SAAS,GAAG,CAAI,EAAE;IAC7B,MAAM,OAAO,GAAG,oBAAU,EAAE,CAAC;IAC7B,MAAM,CAAC,CAAC,GAAG,IAAI,KAAK,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM;QAC9C,IAAI,CAAC;YACH,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,CAAC;QAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACX,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEW,QAAA,oBAAoB,GAAG,GAAG,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,CAAC"} \ No newline at end of file diff --git a/src/util.ts b/src/util.ts index 8fad04c..55a28d2 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,6 +1,6 @@ import { getPromise } from './promise'; -export const isFunction = fn => typeof fn === 'function'; +export const isFunction = fn => typeof fn === 'function' || fn instanceof Function; export const Promisify = fn => { const Promise = getPromise(); From 0c82166e471f6356c8904d560c000b6f1ee5d7b9 Mon Sep 17 00:00:00 2001 From: Glenn Sonna Date: Mon, 21 May 2018 19:27:37 -0500 Subject: [PATCH 5/6] Added CreateResolverFunction type for more consistency --- dist/resolver.d.ts | 7 +++++-- dist/resolver.js.map | 2 +- dist/util.d.ts | 2 +- dist/util.js | 2 +- dist/util.js.map | 2 +- src/resolver.ts | 8 ++++++-- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/dist/resolver.d.ts b/dist/resolver.d.ts index 4e421b1..5b7ef50 100644 --- a/dist/resolver.d.ts +++ b/dist/resolver.d.ts @@ -4,8 +4,11 @@ export interface ResultFunction { export interface ErrorFunction { (root: any, args: any, context: any, err: any): ErrorType | void; } +export interface CreateResolverFunction { + (resFn: ResultFunction, errFn?: ErrorFunction): Resolver; +} export interface Resolver { (root: any, args: {}, context: {}, info: {}): Promise; - createResolver?: (resFn: ResultFunction, errFn?: ErrorFunction) => Resolver; + createResolver?: CreateResolverFunction; } -export declare const createResolver: (resFn: ResultFunction, errFn: ErrorFunction) => Resolver; +export declare const createResolver: CreateResolverFunction; diff --git a/dist/resolver.js.map b/dist/resolver.js.map index ee7ae40..a330ce7 100644 --- a/dist/resolver.js.map +++ b/dist/resolver.js.map @@ -1 +1 @@ -{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AACvC,iCAAqE;AAErE,MAAM,OAAO,GAAG,oBAAU,EAAE,CAAC;AAehB,QAAA,cAAc,GAAG,CAAO,KAAwB,EAAE,KAAuB;IACpF,MAAM,OAAO,GAAG,oBAAU,EAAE,CAAC;IAC7B,MAAM,YAAY,GAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE;QACzE,wFAAwF;QACxF,EAAE,CAAC,CAAC,CAAC,iBAAU,CAAC,KAAK,CAAC,CAAC;YAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACrD,MAAM,CAAC,gBAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;YACxD,kFAAkF;YAClF,EAAE,CAAC,CAAC,CAAC,iBAAU,CAAC,KAAK,CAAC,CAAC;gBAAC,MAAM,CAAC,CAAC;YAChC,0BAA0B;YAC1B,MAAM,CAAC,gBAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAA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CAAC;YAC7F,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG;YAC1C,sEAAsE;YACtE,MAAM,KAAK,GAAG,iBAAU,CAAC,MAAM,CAAC,GAAG,gBAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAEvG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACjB,yCAAyC;gBACzC,EAAE,CAAC,CAAC,2BAAoB,CAAC,CAAC,CAAC,CAAC;oBAAC,MAAM,CAAC,CAAC;gBACrC,0DAA0D;gBAC1D,MAAM,CAAC,iBAAU,CAAC,KAAK,CAAC,GAAG,gBAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;oBAC1E,kEAAkE;oBAClE,MAAM,CAAC,IAAI,GAAG,CAAC;gBACjB,CAAC,EAAE,CAAC;oBACF,iEAAiE;oBACjE,MAAM,CAAC,IAAI,GAAG,CAAC;gBACjB,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,0CAA0C;QAC1C,MAAM,CAAC,sBAAc,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC,CAAA;IAED,MAAM,CAAC,YAAY,CAAC;AACtB,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/util.d.ts b/dist/util.d.ts index 6c7ffb0..1d83213 100644 --- a/dist/util.d.ts +++ b/dist/util.d.ts @@ -1,3 +1,3 @@ export declare const isFunction: (fn: any) => boolean; -export declare const Promisify: (fn: any) => (...args: any[]) => Promise<{}>; +export declare const Promisify: (fn: any) => (...args: any[]) => Promise<{}>; export declare const isNotNullOrUndefined: (val: any) => boolean; diff --git a/dist/util.js b/dist/util.js index c1aedd7..c9b3396 100644 --- a/dist/util.js +++ b/dist/util.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const promise_1 = require("./promise"); exports.isFunction = fn => typeof fn === 'function' || fn instanceof Function; -exports.Promisify = (fn) => { +exports.Promisify = fn => { const Promise = promise_1.getPromise(); return (...args) => new Promise((resolve, reject) => { try { diff --git a/dist/util.js.map b/dist/util.js.map index 16e1529..69ebbda 100644 --- a/dist/util.js.map +++ b/dist/util.js.map @@ -1 +1 @@ -{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAE1B,QAAA,UAAU,GAAG,EAAE,IAAI,OAAO,EAAE,KAAK,UAAU,IAAI,EAAE,YAAY,QAAQ,CAAA;AAErE,QAAA,SAAS,GAAG,CAAI,EAAE;IAC7B,MAAM,OAAO,GAAG,oBAAU,EAAE,CAAC;IAC7B,MAAM,CAAC,CAAC,GAAG,IAAI,KAAK,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM;QAC9C,IAAI,CAAC;YACH,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,CAAC;QAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACX,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEW,QAAA,oBAAoB,GAAG,GAAG,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,CAAC"} \ No newline at end of file +{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAE1B,QAAA,UAAU,GAAG,EAAE,IAAI,OAAO,EAAE,KAAK,UAAU,IAAI,EAAE,YAAY,QAAQ,CAAC;AAEtE,QAAA,SAAS,GAAG,EAAE;IACzB,MAAM,OAAO,GAAG,oBAAU,EAAE,CAAC;IAC7B,MAAM,CAAC,CAAC,GAAG,IAAI,KAAK,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM;QAC9C,IAAI,CAAC;YACH,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,CAAC;QAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACX,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEW,QAAA,oBAAoB,GAAG,GAAG,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,CAAC"} \ No newline at end of file diff --git a/src/resolver.ts b/src/resolver.ts index d316493..86fae97 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -11,12 +11,16 @@ export interface ErrorFunction { (root, args, context, err): ErrorType | void } +export interface CreateResolverFunction { + (resFn: ResultFunction, errFn?: ErrorFunction): Resolver +} + export interface Resolver { (root, args: {}, context: {}, info: {}): Promise - createResolver?: (resFn: ResultFunction, errFn?: ErrorFunction) => Resolver + createResolver?: CreateResolverFunction } -export const createResolver = (resFn: ResultFunction, errFn: ErrorFunction) => { +export const createResolver: CreateResolverFunction = (resFn: ResultFunction, errFn: ErrorFunction) => { const Promise = getPromise(); const baseResolver: Resolver = (root, args = {}, context = {}, info = {}) => { // Return resolving promise with `null` if the resolver function param is not a function From d137a18b3bfb5c0f137cfddd7604ce989a9a8819 Mon Sep 17 00:00:00 2001 From: Glenn Sonna Date: Wed, 6 Jun 2018 12:32:19 +0200 Subject: [PATCH 6/6] Dist removed --- dist/context.d.ts | 11 -------- dist/context.js | 33 ------------------------ dist/context.js.map | 1 - dist/helper.d.ts | 3 --- dist/helper.js | 30 ---------------------- dist/helper.js.map | 1 - dist/index.d.ts | 5 ---- dist/index.js | 13 ---------- dist/index.js.map | 1 - dist/promise.d.ts | 2 -- dist/promise.js | 18 ------------- dist/promise.js.map | 1 - dist/resolver.d.ts | 14 ---------- dist/resolver.js | 61 -------------------------------------------- dist/resolver.js.map | 1 - dist/util.d.ts | 3 --- dist/util.js | 17 ------------ dist/util.js.map | 1 - 18 files changed, 216 deletions(-) delete mode 100644 dist/context.d.ts delete mode 100644 dist/context.js delete mode 100644 dist/context.js.map delete mode 100644 dist/helper.d.ts delete mode 100644 dist/helper.js delete mode 100644 dist/helper.js.map delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 dist/promise.d.ts delete mode 100644 dist/promise.js delete mode 100644 dist/promise.js.map delete mode 100644 dist/resolver.d.ts delete mode 100644 dist/resolver.js delete mode 100644 dist/resolver.js.map delete mode 100644 dist/util.d.ts delete mode 100644 dist/util.js delete mode 100644 dist/util.js.map diff --git a/dist/context.d.ts b/dist/context.d.ts deleted file mode 100644 index 1ff7390..0000000 --- a/dist/context.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export interface ContextData { - models: Object; - user: Object; -} -export declare const createExpressContext: (data: any, res: any) => Context; -export declare class Context { - models: Object; - user: Object; - constructor(data: ContextData); - dispose(): void; -} diff --git a/dist/context.js b/dist/context.js deleted file mode 100644 index 88b36eb..0000000 --- a/dist/context.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const assert = require("assert"); -; -exports.createExpressContext = (data, res) => { - data = data || {}; - data.user = data.user || null; - data.models = data.models || {}; - const context = new Context(data); - if (res) { - assert(typeof res.once === 'function', 'createExpressContext takes response as second parameter that implements "res.once"'); - // Bind the response finish event to the context disposal method - res.once('finish', () => context && context.dispose ? context.dispose() : null); - } - return context; -}; -class Context { - constructor(data) { - Object.keys(data).forEach(key => { - this[key] = data[key]; - }); - } - dispose() { - const models = this.models; - const user = this.user; - this.models = null; - this.user = null; - // Call dispose on every attached model that contains a dispose method - Object.keys(models).forEach((key) => models[key].dispose ? models[key].dispose() : null); - } -} -exports.Context = Context; -//# sourceMappingURL=context.js.map \ No newline at end of file diff --git a/dist/context.js.map b/dist/context.js.map deleted file mode 100644 index ad30cef..0000000 --- a/dist/context.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAIhC,CAAC;AACW,QAAA,oBAAoB,GAAG,CAAC,IAAI,EAAE,GAAG;IAC5C,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;IAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;IAChC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACR,MAAM,CAAC,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE,oFAAoF,CAAC,CAAC;QAC7H,gEAAgE;QAChE,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,OAAO,IAAI,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAClF,CAAC;IACD,MAAM,CAAC,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;IAGE,YAAa,IAAiB;QAC5B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG;YAC3B,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAA;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO;QACL,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,sEAAsE;QACtE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC3F,CAAC;CACF;AAhBD,0BAgBC"} \ No newline at end of file diff --git a/dist/helper.d.ts b/dist/helper.d.ts deleted file mode 100644 index 606f240..0000000 --- a/dist/helper.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare const combineResolvers: (resolvers?: any[]) => any; -export declare const and: (...conditions: any[]) => (resolver: any) => any; -export declare const or: (...conditions: any[]) => (resolver: any) => (...query: any[]) => Promise<{}>; diff --git a/dist/helper.js b/dist/helper.js deleted file mode 100644 index c8c136e..0000000 --- a/dist/helper.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const merge = require("deepmerge"); -// Helper function to combine multiple resolver definition hashes into a single hash for consumption by Apollostack's graphql-server -exports.combineResolvers = (resolvers = []) => resolvers - .reduce((combined, resolver) => merge(combined, resolver)); -// Accepts multiple authentication resolvers and returns a function which will be called -// if all of the authentication resolvers succeed, or throw an error if one of them fails -exports.and = (...conditions) => resolver => { - return conditions.reduceRight((p, c) => { - return c.createResolver(p); - }, resolver); -}; -// Accepts multiple authentication resolvers and returns a function which will be called -// if any of the authentication resolvers succeed, or throw an error if all of them fail -exports.or = (...conditions) => resolver => (...query) => { - return new Promise((resolve, reject) => { - let limit = conditions.length - 1; - const attempt = (i) => conditions[i].createResolver(resolver)(...query) - .then(res => resolve(res)) - .catch(err => { - if (i === limit) - reject(err); - else - attempt(i + 1); - }); - attempt(0); - }); -}; -//# sourceMappingURL=helper.js.map \ No newline at end of file diff --git a/dist/helper.js.map b/dist/helper.js.map deleted file mode 100644 index 420eeb5..0000000 --- a/dist/helper.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":";;AAAA,mCAAmC;AAEnC,oIAAoI;AACvH,QAAA,gBAAgB,GAAG,CAAC,SAAS,GAAG,EAAE,KAAK,SAAS;KAC1D,MAAM,CAAC,CAAC,QAAQ,EAAE,QAAQ,KAAK,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE7D,wFAAwF;AACxF,yFAAyF;AAC5E,QAAA,GAAG,GAAG,CAAC,GAAG,UAAU,KAAK,QAAQ;IAC5C,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC,EAAE,QAAQ,CAAC,CAAA;AACd,CAAC,CAAA;AAED,wFAAwF;AACxF,wFAAwF;AAC3E,QAAA,EAAE,GAAG,CAAC,GAAG,UAAU,KAAK,QAAQ,IAAI,CAAC,GAAG,KAAK;IACxD,MAAM,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM;QACjC,IAAI,KAAK,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG,CAAC,CAAC,KAChB,UAAU,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,GAAG,KAAK,CAAC;aAC7C,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;aACzB,KAAK,CAAC,GAAG;YACR,EAAE,CAAA,CAAC,CAAC,KAAK,KAAK,CAAC;gBAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC5B,IAAI;gBAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;QACP,OAAO,CAAC,CAAC,CAAC,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 1034f5d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { usePromise } from './promise'; -import { combineResolvers, and, or } from './helper'; -import { createExpressContext } from './context'; -import { createResolver } from './resolver'; -export { usePromise, combineResolvers, createExpressContext, createResolver, and, or }; diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b8915cc..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const promise_1 = require("./promise"); -exports.usePromise = promise_1.usePromise; -const helper_1 = require("./helper"); -exports.combineResolvers = helper_1.combineResolvers; -exports.and = helper_1.and; -exports.or = helper_1.or; -const context_1 = require("./context"); -exports.createExpressContext = context_1.createExpressContext; -const resolver_1 = require("./resolver"); -exports.createResolver = resolver_1.createResolver; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3c385fd..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAMrC,qBANO,oBAAU,CAMP;AALZ,qCAAqD;AAMnD,2BANO,yBAAgB,CAMP;AAGhB,cATyB,YAAG,CASzB;AACH,aAV8B,WAAE,CAU9B;AATJ,uCAAiD;AAM/C,+BANO,8BAAoB,CAMP;AALtB,yCAA4C;AAM1C,yBANO,yBAAc,CAMP"} \ No newline at end of file diff --git a/dist/promise.d.ts b/dist/promise.d.ts deleted file mode 100644 index c69594c..0000000 --- a/dist/promise.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare const usePromise: (pLib: any) => void; -export declare const getPromise: () => PromiseConstructor; diff --git a/dist/promise.js b/dist/promise.js deleted file mode 100644 index a8ffab7..0000000 --- a/dist/promise.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const assert = require("assert"); -// Expose the Promise constructor so that it can be overwritten by a different lib like Bluebird -let p = Promise; -// Allow overload with compliant promise lib -exports.usePromise = pLib => { - assert(pLib && pLib.prototype, 'apollo-errors#usePromise expects a valid Promise library'); - assert(!!pLib.resolve, 'apollo-errors#usePromise expects a Promise library that implements static method "Promise.resolve"'); - assert(!!pLib.reject, 'apollo-errors#usePromise expects a Promise library that implements static method "Promise.reject"'); - assert(!!pLib.all, 'apollo-errors#usePromise expects a Promise library that implements static method "Promise.all"'); - assert(!!pLib.prototype.then, 'apollo-errors#usePromise expects a Promise library that implements method "promise.then" on the constructor prototype'); - assert(!!pLib.prototype.catch, 'apollo-errors#usePromise expects a Promise library that implements method "promise.catch" on the constructor prototype'); - p = pLib; -}; -// Return the currently selected promise lib -exports.getPromise = () => p; -//# sourceMappingURL=promise.js.map \ No newline at end of file diff --git a/dist/promise.js.map b/dist/promise.js.map deleted file mode 100644 index 647345e..0000000 --- a/dist/promise.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"promise.js","sourceRoot":"","sources":["../src/promise.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAEjC,gGAAgG;AAChG,IAAI,CAAC,GAAG,OAAO,CAAC;AAEhB,4CAA4C;AAC/B,QAAA,UAAU,GAAG,IAAI;IAC5B,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,0DAA0D,CAAC,CAAC;IAC3F,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,oGAAoG,CAAC,CAAC;IAC7H,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,mGAAmG,CAAC,CAAC;IAC3H,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,gGAAgG,CAAC,CAAC;IACrH,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,uHAAuH,CAAC,CAAC;IACvJ,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,wHAAwH,CAAC,CAAC;IACzJ,CAAC,GAAG,IAAI,CAAC;AACX,CAAC,CAAC;AAEF,4CAA4C;AAC/B,QAAA,UAAU,GAAG,MAAM,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/resolver.d.ts b/dist/resolver.d.ts deleted file mode 100644 index 5b7ef50..0000000 --- a/dist/resolver.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -export interface ResultFunction { - (root: any, args: any, context: any, info: any): Promise | ResulType | void; -} -export interface ErrorFunction { - (root: any, args: any, context: any, err: any): ErrorType | void; -} -export interface CreateResolverFunction { - (resFn: ResultFunction, errFn?: ErrorFunction): Resolver; -} -export interface Resolver { - (root: any, args: {}, context: {}, info: {}): Promise; - createResolver?: CreateResolverFunction; -} -export declare const createResolver: CreateResolverFunction; diff --git a/dist/resolver.js b/dist/resolver.js deleted file mode 100644 index f23fb8f..0000000 --- a/dist/resolver.js +++ /dev/null @@ -1,61 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const promise_1 = require("./promise"); -const util_1 = require("./util"); -const Promise = promise_1.getPromise(); -exports.createResolver = (resFn, errFn) => { - const Promise = promise_1.getPromise(); - const baseResolver = (root, args = {}, context = {}, info = {}) => { - // Return resolving promise with `null` if the resolver function param is not a function - if (!util_1.isFunction(resFn)) - return Promise.resolve(null); - return util_1.Promisify(resFn)(root, args, context, info).catch(e => { - // On error, check if there is an error handler. If not, throw the original error - if (!util_1.isFunction(errFn)) - throw e; - // Call the error handler. - return util_1.Promisify(errFn)(root, args, context, e).then(parsedError => { - // If it resolves, throw the resolving value or the original error. - throw parsedError || e; - }, parsedError => { - // If it rejects, throw the rejecting value or the original error - throw parsedError || e; - }); - }); - }; - baseResolver.createResolver = (cResFn, cErrFn) => { - const Promise = promise_1.getPromise(); - const childResFn = (root, args, context, info = {}) => { - // Start with either the parent resolver function or a no-op (returns null) - const entry = util_1.isFunction(resFn) ? util_1.Promisify(resFn)(root, args, context, info) : Promise.resolve(null); - return entry.then(r => { - // If the parent returns a value, continue - if (util_1.isNotNullOrUndefined(r)) - return r; - // Call the child resolver function or a no-op (returns null) - return util_1.isFunction(cResFn) ? util_1.Promisify(cResFn)(root, args, context) : Promise.resolve(null); - }); - }; - const childErrFn = (root, args, context, err) => { - // Start with either the child error handler or a no-op (returns null) - const entry = util_1.isFunction(cErrFn) ? util_1.Promisify(cErrFn)(root, args, context, err) : Promise.resolve(null); - return entry.then(r => { - // If the child returns a value, throw it - if (util_1.isNotNullOrUndefined(r)) - throw r; - // Call the parent error handler or a no-op (returns null) - return util_1.isFunction(errFn) ? util_1.Promisify(errFn)(root, args, context, err).then(e => { - // If it resolves, throw the resolving value or the original error - throw e || err; - }, e => { - // If it rejects, throw the rejecting value or the original error - throw e || err; - }) : Promise.resolve(null); - }); - }; - // Create the child resolver and return it - return exports.createResolver(childResFn, childErrFn); - }; - return baseResolver; -}; -//# sourceMappingURL=resolver.js.map \ No newline at end of file diff --git a/dist/resolver.js.map b/dist/resolver.js.map deleted file mode 100644 index a330ce7..0000000 --- a/dist/resolver.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AACvC,iCAAqE;AAErE,MAAM,OAAO,GAAG,oBAAU,EAAE,CAAC;AAmBhB,QAAA,cAAc,GAA2B,CAAO,KAAwB,EAAE,KAAuB;IAC5G,MAAM,OAAO,GAAG,oBAAU,EAAE,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AAC,CAAC;IAChD,CAAC,CAAA;IAED,MAAM,CAAC,YAAY,CAAC;AACtB,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/util.d.ts b/dist/util.d.ts deleted file mode 100644 index 1d83213..0000000 --- a/dist/util.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare const isFunction: (fn: any) => boolean; -export declare const Promisify: (fn: any) => (...args: any[]) => Promise<{}>; -export declare const isNotNullOrUndefined: (val: any) => boolean; diff --git a/dist/util.js b/dist/util.js deleted file mode 100644 index c9b3396..0000000 --- a/dist/util.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const promise_1 = require("./promise"); -exports.isFunction = fn => typeof fn === 'function' || fn instanceof Function; -exports.Promisify = fn => { - const Promise = promise_1.getPromise(); - return (...args) => new Promise((resolve, reject) => { - try { - return Promise.resolve(fn(...args)).then(r => resolve(r), e => reject(e)); - } - catch (e) { - return reject(e); - } - }); -}; -exports.isNotNullOrUndefined = val => val !== null && val !== undefined; -//# sourceMappingURL=util.js.map \ No newline at end of file diff --git a/dist/util.js.map b/dist/util.js.map deleted file mode 100644 index 69ebbda..0000000 --- a/dist/util.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAE1B,QAAA,UAAU,GAAG,EAAE,IAAI,OAAO,EAAE,KAAK,UAAU,IAAI,EAAE,YAAY,QAAQ,CAAC;AAEtE,QAAA,SAAS,GAAG,EAAE;IACzB,MAAM,OAAO,GAAG,oBAAU,EAAE,CAAC;IAC7B,MAAM,CAAC,CAAC,GAAG,IAAI,KAAK,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM;QAC9C,IAAI,CAAC;YACH,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,CAAC;QAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACX,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEW,QAAA,oBAAoB,GAAG,GAAG,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,CAAC"} \ No newline at end of file