From 6166cc499d0d1a3cff0e788950d8dba9f9c7555d Mon Sep 17 00:00:00 2001 From: Glenn Sonna Date: Thu, 31 May 2018 16:26:48 +0200 Subject: [PATCH 1/4] Updated package.json urls --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 8e02d1c..b7e6514 100644 --- a/package.json +++ b/package.json @@ -31,10 +31,10 @@ }, "repository": { "type": "git", - "url": "https://github.com/theGlenn/graphql-resolvers-chain.git" + "url": "https://github.com/theGlenn/graphql-resolved.git" }, "bugs": { - "url": "https://github.com/theGlenn/graphql-resolvers-chain/issues" + "url": "https://github.com/theGlenn/graphql-resolved/issues" }, - "homepage": "https://github.com/theGlenn/graphql-resolvers-chain" + "homepage": "https://github.com/theGlenn/graphql-resolved" } From 21e8a339234bc917444c0becc4b1b220ae311460 Mon Sep 17 00:00:00 2001 From: Glenn Sonna Date: Thu, 31 May 2018 16:35:38 +0200 Subject: [PATCH 2/4] 1.0.3 dist --- dist/resolvers/Chainable.d.ts | 11 ++++++++++ .../{resolvers.assembler.js => Chainable.js} | 22 ++++++++++++++----- dist/resolvers/Chainable.js.map | 1 + dist/resolvers/apis/apply.js.map | 2 +- dist/resolvers/apis/chain.d.ts | 4 ++-- dist/resolvers/apis/chain.js | 4 ++-- dist/resolvers/apis/chain.js.map | 2 +- dist/resolvers/apis/protect.d.ts | 4 ++-- dist/resolvers/index.d.ts | 3 +-- dist/resolvers/index.js | 3 +-- dist/resolvers/index.js.map | 2 +- dist/resolvers/resolvers.assembler.d.ts | 8 ------- dist/resolvers/resolvers.assembler.js.map | 1 - dist/resolvers/resolvers.chain.d.ts | 6 ----- dist/resolvers/resolvers.chain.js | 19 ---------------- dist/resolvers/resolvers.chain.js.map | 1 - dist/resolvers/resolvers.types.d.ts | 2 +- tsconfig.json | 1 + 18 files changed, 41 insertions(+), 55 deletions(-) create mode 100644 dist/resolvers/Chainable.d.ts rename dist/resolvers/{resolvers.assembler.js => Chainable.js} (51%) create mode 100644 dist/resolvers/Chainable.js.map delete mode 100644 dist/resolvers/resolvers.assembler.d.ts delete mode 100644 dist/resolvers/resolvers.assembler.js.map delete mode 100644 dist/resolvers/resolvers.chain.d.ts delete mode 100644 dist/resolvers/resolvers.chain.js delete mode 100644 dist/resolvers/resolvers.chain.js.map diff --git a/dist/resolvers/Chainable.d.ts b/dist/resolvers/Chainable.d.ts new file mode 100644 index 0000000..59850a4 --- /dev/null +++ b/dist/resolvers/Chainable.d.ts @@ -0,0 +1,11 @@ +import { ResolverFunction, Resolvers, ChainedFunction } from './resolvers.types'; +export interface ChainableArgs { + before: ResolverFunction; + next: ResolverFunction; +} +export default class Chainable { + private resolver; + constructor(resolver: ResolverFunction); + after(resolversToApply: Resolvers): ChainedFunction; + static assemble({before, next}: ChainableArgs): ChainedFunction; +} diff --git a/dist/resolvers/resolvers.assembler.js b/dist/resolvers/Chainable.js similarity index 51% rename from dist/resolvers/resolvers.assembler.js rename to dist/resolvers/Chainable.js index 4424431..9dddca1 100644 --- a/dist/resolvers/resolvers.assembler.js +++ b/dist/resolvers/Chainable.js @@ -1,10 +1,20 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); ; -var ResolversAssembler = /** @class */ (function () { - function ResolversAssembler() { +var Chainable = /** @class */ (function () { + function Chainable(resolver) { + this.resolver = resolver; } - ResolversAssembler.assemble = function (_a) { + Chainable.prototype.after = function (resolversToApply) { + var resolvers = resolversToApply.concat([this.resolver]); + return resolvers.reduce(function (previousResolver, currentResolver) { + return Chainable.assemble({ + before: previousResolver, + next: currentResolver + }); + }); + }; + Chainable.assemble = function (_a) { var before = _a.before, next = _a.next; return function (root, args, context, info) { return new Promise(function (resolve, reject) { try { @@ -17,7 +27,7 @@ var ResolversAssembler = /** @class */ (function () { } }); }; }; - return ResolversAssembler; + return Chainable; }()); -exports.ResolversAssembler = ResolversAssembler; -//# sourceMappingURL=resolvers.assembler.js.map \ No newline at end of file +exports.default = Chainable; +//# sourceMappingURL=Chainable.js.map \ No newline at end of file diff --git a/dist/resolvers/Chainable.js.map b/dist/resolvers/Chainable.js.map new file mode 100644 index 0000000..d117146 --- /dev/null +++ b/dist/resolvers/Chainable.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Chainable.js","sourceRoot":"","sources":["../../src/resolvers/Chainable.ts"],"names":[],"mappings":";;AAKC,CAAC;AAEF;IAEE,mBAAoB,QAAuC;QAAvC,aAAQ,GAAR,QAAQ,CAA+B;IAAI,CAAC;IAEhE,yBAAK,GAAL,UAAS,gBAA2B;QAClC,IAAM,SAAS,GAAO,gBAAgB,SAAE,IAAI,CAAC,QAAQ,EAAC,CAAC;QACvD,OAAO,SAAS,CAAC,MAAM,CAAC,UAAC,gBAAgB,EAAE,eAAe;YACxD,OAAO,SAAS,CAAC,QAAQ,CAAC;gBACxB,MAAM,EAAE,gBAAgB;gBACxB,IAAI,EAAE,eAAe;aACtB,CAAC,CAAA;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,kBAAQ,GAAf,UAAmB,EAAkC;YAAhC,kBAAM,EAAE,cAAI;QAC/B,OAAO,UAAC,IAAI,EAAE,IAAQ,EAAE,OAAW,EAAE,IAAQ,IAAK,OAAA,IAAI,OAAO,CAAI,UAAC,OAAO,EAAE,MAAM;YAC/E,IAAI;gBACF,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;qBACxD,IAAI,CAAC,cAAM,OAAA,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAA/B,CAA+B,CAAC;qBAC3C,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,OAAO,CAAC,MAAM,CAAC,EAAf,CAAe,EAAE,UAAA,KAAK,IAAI,OAAA,MAAM,CAAC,KAAK,CAAC,EAAb,CAAa,CAAC,CAAC;aAC1D;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;aAClB;QACH,CAAC,CAAC,EARgD,CAQhD,CAAC;IACL,CAAC;IACH,gBAAC;AAAD,CAAC,AAzBD,IAyBC"} \ No newline at end of file diff --git a/dist/resolvers/apis/apply.js.map b/dist/resolvers/apis/apply.js.map index 23a83d4..9d4cdc4 100644 --- a/dist/resolvers/apis/apply.js.map +++ b/dist/resolvers/apis/apply.js.map @@ -1 +1 @@ -{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../src/resolvers/apis/apply.ts"],"names":[],"mappings":";;AAEA,wDAA4D;AAE5D,iCAAgC;AAOnB,QAAA,KAAK,GAAG,UAAI,IAAkB;IACjC,IAAA,iCAA2B,EAAE,8BAAwB,CAAU;IACvE,IAAG,6BAAW,CAAC,IAAI,CAAC,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,2HAId,CAAC,CAAC;KACL;IAED,IAAM,gBAAgB,GAAiB,EAAE,CAAC;IAE1C,KAAK,IAAI,GAAG,IAAI,oBAAoB,EAAE;QACpC,IAAM,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAC3C,gBAAgB,CAAC,GAAG,CAAC,GAAG,aAAK,CAAK,gBAAgB,SAAE,QAAQ,GAAE,CAAA;KAC/D;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../src/resolvers/apis/apply.ts"],"names":[],"mappings":";;AACA,wDAA4D;AAC5D,iCAAgC;AAOnB,QAAA,KAAK,GAAG,UAAI,IAAkB;IACjC,IAAA,iCAA2B,EAAE,8BAAwB,CAAU;IACvE,IAAG,6BAAW,CAAC,IAAI,CAAC,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,2HAId,CAAC,CAAC;KACL;IAED,IAAM,gBAAgB,GAAiB,EAAE,CAAC;IAE1C,KAAK,IAAI,GAAG,IAAI,oBAAoB,EAAE;QACpC,IAAM,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAC3C,gBAAgB,CAAC,GAAG,CAAC,GAAG,aAAK,CAAK,gBAAgB,SAAE,QAAQ,GAAE,CAAA;KAC/D;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/resolvers/apis/chain.d.ts b/dist/resolvers/apis/chain.d.ts index 6316363..663b08d 100644 --- a/dist/resolvers/apis/chain.d.ts +++ b/dist/resolvers/apis/chain.d.ts @@ -1,2 +1,2 @@ -import { ResolverFunction, ResolverChained } from './../resolvers.types'; -export declare const chain: (resolvers: ResolverFunction[]) => ResolverChained | ResolverChained; +import { ResolverFunction, ChainedFunction } from './../resolvers.types'; +export declare const chain: (resolvers: ResolverFunction[]) => ChainedFunction | ChainedFunction; diff --git a/dist/resolvers/apis/chain.js b/dist/resolvers/apis/chain.js index ba78669..6343241 100644 --- a/dist/resolvers/apis/chain.js +++ b/dist/resolvers/apis/chain.js @@ -1,11 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var resolvers_chain_1 = require("./../resolvers.chain"); var resolvers_check_1 = require("./../resolvers.check"); +var Chainable_1 = require("./../Chainable"); exports.chain = function (resolvers) { if (resolvers_check_1.isArray(resolvers)) { var lastToResolve = resolvers.pop(); - return new resolvers_chain_1.ResolversChain([lastToResolve]).with(resolvers)[0]; + return new Chainable_1.default(lastToResolve).after(resolvers); } throw new Error("Invalid arguments: should be an Array or object of shape\n {\n using: Resolvers\n into : ResolversMap\n }"); }; diff --git a/dist/resolvers/apis/chain.js.map b/dist/resolvers/apis/chain.js.map index 7e50ede..20158ac 100644 --- a/dist/resolvers/apis/chain.js.map +++ b/dist/resolvers/apis/chain.js.map @@ -1 +1 @@ -{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../src/resolvers/apis/chain.ts"],"names":[],"mappings":";;AACA,wDAAqD;AACrD,wDAA4D;AAE/C,QAAA,KAAK,GAAG,UAAK,SAAoB;IAC5C,IAAG,yBAAO,CAAC,SAAS,CAAC,EAAC;QACpB,IAAM,aAAa,GAAG,SAAS,CAAC,GAAG,EAAE,CAAA;QACrC,OAAO,IAAI,gCAAc,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;KAClE;IAED,MAAM,IAAI,KAAK,CAAC,mHAId,CAAC,CAAC;AACN,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../src/resolvers/apis/chain.ts"],"names":[],"mappings":";;AACA,wDAA4D;AAC5D,4CAAuC;AAE1B,QAAA,KAAK,GAAG,UAAK,SAAoB;IAC5C,IAAG,yBAAO,CAAC,SAAS,CAAC,EAAC;QACpB,IAAM,aAAa,GAAG,SAAS,CAAC,GAAG,EAAE,CAAA;QACrC,OAAO,IAAI,mBAAS,CAAC,aAAa,CAAC,CAAC,KAAK,CAAI,SAAS,CAAC,CAAC;KACzD;IAED,MAAM,IAAI,KAAK,CAAC,mHAId,CAAC,CAAC;AACN,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/resolvers/apis/protect.d.ts b/dist/resolvers/apis/protect.d.ts index 74527f6..2941fc7 100644 --- a/dist/resolvers/apis/protect.d.ts +++ b/dist/resolvers/apis/protect.d.ts @@ -1,7 +1,7 @@ -import { ResolverChained, ResolverFunction, ResolversMap, Resolvers } from './../resolvers.types'; +import { ResolverFunction, ResolversMap, Resolvers, ChainedFunction } from './../resolvers.types'; export interface ProtectArgs { it?: ResolverFunction; all?: ResolversMap; using: Resolvers; } -export declare const protect: ({ it, all, using }: ProtectArgs) => ResolversMap | ResolverChained; +export declare const protect: ({ it, all, using }: ProtectArgs) => ResolversMap | ChainedFunction; diff --git a/dist/resolvers/index.d.ts b/dist/resolvers/index.d.ts index eaba623..4ed15f4 100644 --- a/dist/resolvers/index.d.ts +++ b/dist/resolvers/index.d.ts @@ -1,5 +1,4 @@ export * from './apis'; export * from './resolvers.types'; export * from './resolvers.check'; -export * from './resolvers.chain'; -export * from './resolvers.assembler'; +export * from './Chainable'; diff --git a/dist/resolvers/index.js b/dist/resolvers/index.js index ea4c155..e302d55 100644 --- a/dist/resolvers/index.js +++ b/dist/resolvers/index.js @@ -5,6 +5,5 @@ function __export(m) { Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./apis")); __export(require("./resolvers.check")); -__export(require("./resolvers.chain")); -__export(require("./resolvers.assembler")); +__export(require("./Chainable")); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/resolvers/index.js.map b/dist/resolvers/index.js.map index 5696962..6d0ae2f 100644 --- a/dist/resolvers/index.js.map +++ b/dist/resolvers/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resolvers/index.ts"],"names":[],"mappings":";;;;;AAAA,4BAAsB;AAEtB,uCAAiC;AACjC,uCAAiC;AACjC,2CAAqC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resolvers/index.ts"],"names":[],"mappings":";;;;;AAAA,4BAAsB;AAEtB,uCAAiC;AACjC,iCAA2B"} \ No newline at end of file diff --git a/dist/resolvers/resolvers.assembler.d.ts b/dist/resolvers/resolvers.assembler.d.ts deleted file mode 100644 index fab6ffd..0000000 --- a/dist/resolvers/resolvers.assembler.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ResolverFunction, ResolverChained } from './resolvers.types'; -export interface ResolversLinkArgs { - before: ResolverFunction; - next: ResolverFunction; -} -export declare class ResolversAssembler { - static assemble({before, next}: ResolversLinkArgs): ResolverChained; -} diff --git a/dist/resolvers/resolvers.assembler.js.map b/dist/resolvers/resolvers.assembler.js.map deleted file mode 100644 index cdad74a..0000000 --- a/dist/resolvers/resolvers.assembler.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"resolvers.assembler.js","sourceRoot":"","sources":["../../src/resolvers/resolvers.assembler.ts"],"names":[],"mappings":";;AAKC,CAAC;AAEF;IAAA;IAYA,CAAC;IAXQ,2BAAQ,GAAf,UAAmB,EAAsC;YAApC,kBAAM,EAAE,cAAI;QAC/B,OAAO,UAAC,IAAI,EAAE,IAAQ,EAAE,OAAW,EAAE,IAAQ,IAAK,OAAA,IAAI,OAAO,CAAI,UAAC,OAAO,EAAE,MAAM;YAC/E,IAAI;gBACF,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;qBACxD,IAAI,CAAC,cAAM,OAAA,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAA/B,CAA+B,CAAC;qBAC3C,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,OAAO,CAAC,MAAM,CAAC,EAAf,CAAe,EAAE,UAAA,KAAK,IAAI,OAAA,MAAM,CAAC,KAAK,CAAC,EAAb,CAAa,CAAC,CAAC;aAC1D;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;aAClB;QACH,CAAC,CAAC,EARgD,CAQhD,CAAA;IACJ,CAAC;IACH,yBAAC;AAAD,CAAC,AAZD,IAYC;AAZY,gDAAkB"} \ No newline at end of file diff --git a/dist/resolvers/resolvers.chain.d.ts b/dist/resolvers/resolvers.chain.d.ts deleted file mode 100644 index 81e65f2..0000000 --- a/dist/resolvers/resolvers.chain.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Resolvers, ResolverChained } from './resolvers.types'; -export declare class ResolversChain { - private independantsResolvers; - constructor(independantsResolvers: Resolvers); - with(resolversToApply: Resolvers): ResolverChained[]; -} diff --git a/dist/resolvers/resolvers.chain.js b/dist/resolvers/resolvers.chain.js deleted file mode 100644 index f4fc09b..0000000 --- a/dist/resolvers/resolvers.chain.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var resolvers_assembler_1 = require("./resolvers.assembler"); -var ResolversChain = /** @class */ (function () { - function ResolversChain(independantsResolvers) { - this.independantsResolvers = independantsResolvers; - } - ResolversChain.prototype.with = function (resolversToApply) { - return this.independantsResolvers.map(function (resolver) { return resolversToApply.concat([resolver]).reduce(function (previousResolver, currentResolver) { - return resolvers_assembler_1.ResolversAssembler.assemble({ - before: previousResolver, - next: currentResolver - }); - }); }); - }; - return ResolversChain; -}()); -exports.ResolversChain = ResolversChain; -//# sourceMappingURL=resolvers.chain.js.map \ No newline at end of file diff --git a/dist/resolvers/resolvers.chain.js.map b/dist/resolvers/resolvers.chain.js.map deleted file mode 100644 index fa42126..0000000 --- a/dist/resolvers/resolvers.chain.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"resolvers.chain.js","sourceRoot":"","sources":["../../src/resolvers/resolvers.chain.ts"],"names":[],"mappings":";;AACA,6DAA2D;AAE3D;IACE,wBAAoB,qBAAgC;QAAhC,0BAAqB,GAArB,qBAAqB,CAAW;IAAI,CAAC;IAEzD,6BAAI,GAAJ,UAAQ,gBAA2B;QACjC,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,UAAA,QAAQ,IAAI,OAAI,gBAAgB,SAAE,QAAQ,GAAE,MAAM,CAAC,UAAC,gBAAgB,EAAE,eAAe;YACzH,OAAO,wCAAkB,CAAC,QAAQ,CAAC;gBACjC,MAAM,EAAE,gBAAgB;gBACxB,IAAI,EAAE,eAAe;aACtB,CAAuB,CAAA;QAC1B,CAAC,CAAC,EALgD,CAKhD,CAAC,CAAC;IACN,CAAC;IACH,qBAAC;AAAD,CAAC,AAXD,IAWC;AAXY,wCAAc"} \ No newline at end of file diff --git a/dist/resolvers/resolvers.types.d.ts b/dist/resolvers/resolvers.types.d.ts index ec0202f..8b26db9 100644 --- a/dist/resolvers/resolvers.types.d.ts +++ b/dist/resolvers/resolvers.types.d.ts @@ -1,7 +1,7 @@ export interface ResolverFunction { (root: any, args: {}, context: {}, info: {}): Promise | Result | never; } -export interface ResolverChained extends ResolverFunction { +export interface ChainedFunction extends ResolverFunction { (root: any, args: {}, context: {}, info: {}): Promise; } export declare type Resolvers = Array>; diff --git a/tsconfig.json b/tsconfig.json index dfbc2e7..8dca53b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,7 @@ ] }, "exclude": [ + "./test", "./dist", "./node_modules", "./src/**/*.spec.ts", From 8c27a8732a27e5c49a0ff9c8c237ee49fc8c378b Mon Sep 17 00:00:00 2001 From: Glenn Sonna Date: Thu, 31 May 2018 16:35:40 +0200 Subject: [PATCH 3/4] 1.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b7e6514..b81c537 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "graphql-resolved", - "version": "1.0.2", + "version": "1.0.3", "description": "Framework agnostic resolvers creation/composition for GraphQL", "main": "dist/index.js", "types": "dist/index.d.ts", From 4cd868fd209f1fb8ef024b33d45cb6486dceff71 Mon Sep 17 00:00:00 2001 From: Glenn Sonna Date: Thu, 31 May 2018 16:36:06 +0200 Subject: [PATCH 4/4] 1.0.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b81c537..90e1dfc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "graphql-resolved", - "version": "1.0.3", + "version": "1.0.4", "description": "Framework agnostic resolvers creation/composition for GraphQL", "main": "dist/index.js", "types": "dist/index.d.ts",