@webiny/handler-graphql 6.0.0-beta.0 → 6.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/ResolverDecoration.d.ts +6 -0
- package/ResolverDecoration.js +19 -0
- package/ResolverDecoration.js.map +1 -0
- package/builtInTypes/AnyScalar.d.ts +1 -1
- package/builtInTypes/AnyScalar.js +2 -8
- package/builtInTypes/AnyScalar.js.map +1 -1
- package/builtInTypes/DateScalar.d.ts +1 -1
- package/builtInTypes/DateScalar.js +7 -10
- package/builtInTypes/DateScalar.js.map +1 -1
- package/builtInTypes/DateTimeScalar.d.ts +1 -1
- package/builtInTypes/DateTimeScalar.js +7 -10
- package/builtInTypes/DateTimeScalar.js.map +1 -1
- package/builtInTypes/DateTimeZScalar.d.ts +1 -1
- package/builtInTypes/DateTimeZScalar.js +8 -15
- package/builtInTypes/DateTimeZScalar.js.map +1 -1
- package/builtInTypes/IconScalar.d.ts +10 -0
- package/builtInTypes/IconScalar.js +93 -0
- package/builtInTypes/IconScalar.js.map +1 -0
- package/builtInTypes/JsonScalar.d.ts +1 -1
- package/builtInTypes/JsonScalar.js +2 -8
- package/builtInTypes/JsonScalar.js.map +1 -1
- package/builtInTypes/LongScalar.d.ts +1 -1
- package/builtInTypes/LongScalar.js +8 -15
- package/builtInTypes/LongScalar.js.map +1 -1
- package/builtInTypes/NumberScalar.d.ts +1 -1
- package/builtInTypes/NumberScalar.js +9 -16
- package/builtInTypes/NumberScalar.js.map +1 -1
- package/builtInTypes/RefInputScalar.d.ts +1 -1
- package/builtInTypes/RefInputScalar.js +8 -8
- package/builtInTypes/RefInputScalar.js.map +1 -1
- package/builtInTypes/TimeScalar.d.ts +1 -1
- package/builtInTypes/TimeScalar.js +9 -16
- package/builtInTypes/TimeScalar.js.map +1 -1
- package/builtInTypes/index.d.ts +10 -9
- package/builtInTypes/index.js +10 -104
- package/builtInTypes/index.js.map +1 -1
- package/createGraphQLHandler.d.ts +3 -3
- package/createGraphQLHandler.js +25 -35
- package/createGraphQLHandler.js.map +1 -1
- package/createGraphQLSchema.d.ts +4 -4
- package/createGraphQLSchema.js +68 -41
- package/createGraphQLSchema.js.map +1 -1
- package/createRequestBody.d.ts +2 -0
- package/createRequestBody.js +26 -0
- package/createRequestBody.js.map +1 -0
- package/createResolverDecorator.d.ts +2 -0
- package/createResolverDecorator.js +5 -0
- package/createResolverDecorator.js.map +1 -0
- package/debugPlugins.d.ts +2 -2
- package/debugPlugins.js +4 -11
- package/debugPlugins.js.map +1 -1
- package/errors.js +2 -10
- package/errors.js.map +1 -1
- package/exports/api/graphql.d.ts +2 -0
- package/exports/api/graphql.js +4 -0
- package/exports/api/graphql.js.map +1 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.d.ts +16 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js +64 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js.map +1 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.d.ts +13 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js +29 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js.map +1 -0
- package/features/GraphQLSchemaBuilder/abstractions.d.ts +34 -0
- package/features/GraphQLSchemaBuilder/abstractions.js +5 -0
- package/features/GraphQLSchemaBuilder/abstractions.js.map +1 -0
- package/features/GraphQLSchemaBuilder/feature.d.ts +1 -0
- package/features/GraphQLSchemaBuilder/feature.js +10 -0
- package/features/GraphQLSchemaBuilder/feature.js.map +1 -0
- package/graphql/abstractions.core.d.ts +11 -0
- package/graphql/abstractions.core.js +10 -0
- package/graphql/abstractions.core.js.map +1 -0
- package/graphql/abstractions.d.ts +2 -0
- package/graphql/abstractions.js +4 -0
- package/graphql/abstractions.js.map +1 -0
- package/graphql/abstractions.public.d.ts +19 -0
- package/graphql/abstractions.public.js +12 -0
- package/graphql/abstractions.public.js.map +1 -0
- package/index.d.ts +10 -6
- package/index.js +11 -59
- package/index.js.map +1 -1
- package/interceptConsole.js +1 -8
- package/interceptConsole.js.map +1 -1
- package/package.json +23 -26
- package/plugins/GraphQLSchemaPlugin.d.ts +7 -3
- package/plugins/GraphQLSchemaPlugin.js +11 -12
- package/plugins/GraphQLSchemaPlugin.js.map +1 -1
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +1 -16
- package/plugins/index.js.map +1 -1
- package/processRequestBody.d.ts +4 -4
- package/processRequestBody.js +10 -10
- package/processRequestBody.js.map +1 -1
- package/responses.js +5 -16
- package/responses.js.map +1 -1
- package/types.d.ts +20 -13
- package/types.js +1 -5
- package/types.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +3 -0
- package/utils/index.js.map +1 -0
- package/utils/resolve.d.ts +21 -0
- package/utils/resolve.js +19 -0
- package/utils/resolve.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createResolverDecorator","decorator"],"sources":["createResolverDecorator.ts"],"sourcesContent":["import type { ResolverDecorator } from \"./types.js\";\n\nexport const createResolverDecorator = <TSource = any, TContext = any, TArgs = any>(\n decorator: ResolverDecorator<TSource, TContext, TArgs>\n) => {\n return decorator;\n};\n"],"mappings":"AAEA,OAAO,MAAMA,uBAAuB,GAChCC,SAAsD,IACrD;EACD,OAAOA,SAAS;AACpB,CAAC","ignoreList":[]}
|
package/debugPlugins.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GraphQLAfterQueryPlugin } from "./types";
|
|
2
|
-
import { Context } from "@webiny/api/types";
|
|
1
|
+
import type { GraphQLAfterQueryPlugin } from "./types.js";
|
|
2
|
+
import type { Context } from "@webiny/api/types.js";
|
|
3
3
|
import { ContextPlugin } from "@webiny/api";
|
|
4
4
|
interface Log {
|
|
5
5
|
method: string;
|
package/debugPlugins.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _interceptConsole = require("./interceptConsole");
|
|
8
|
-
var _api = require("@webiny/api");
|
|
9
|
-
var _default = () => [new _api.ContextPlugin(async context => {
|
|
1
|
+
import { interceptConsole } from "./interceptConsole.js";
|
|
2
|
+
import { ContextPlugin } from "@webiny/api";
|
|
3
|
+
export default () => [new ContextPlugin(async context => {
|
|
10
4
|
if (!context.debug) {
|
|
11
5
|
context.debug = {};
|
|
12
6
|
}
|
|
13
7
|
if (!context.debug.logs) {
|
|
14
8
|
context.debug.logs = [];
|
|
15
9
|
}
|
|
16
|
-
|
|
10
|
+
interceptConsole((method, args) => {
|
|
17
11
|
context.debug.logs.push({
|
|
18
12
|
method,
|
|
19
13
|
args
|
|
@@ -33,6 +27,5 @@ var _default = () => [new _api.ContextPlugin(async context => {
|
|
|
33
27
|
}
|
|
34
28
|
}
|
|
35
29
|
}];
|
|
36
|
-
exports.default = _default;
|
|
37
30
|
|
|
38
31
|
//# sourceMappingURL=debugPlugins.js.map
|
package/debugPlugins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["interceptConsole","ContextPlugin","context","debug","logs","method","args","push","type","apply","result","console","length"],"sources":["debugPlugins.ts"],"sourcesContent":["import { interceptConsole } from \"./interceptConsole.js\";\nimport type { GraphQLAfterQueryPlugin } from \"./types.js\";\nimport type { Context } from \"@webiny/api/types.js\";\nimport { ContextPlugin } from \"@webiny/api\";\n\ninterface Log {\n method: string;\n args: any;\n}\ninterface DebugContext extends Context {\n debug: {\n logs?: Log[];\n };\n}\n\nexport default () => [\n new ContextPlugin<DebugContext>(async context => {\n if (!context.debug) {\n context.debug = {};\n }\n\n if (!context.debug.logs) {\n context.debug.logs = [];\n }\n\n interceptConsole((method, args) => {\n (context.debug.logs as Log[]).push({ method, args });\n });\n }),\n {\n type: \"graphql-after-query\",\n apply({ result, context }) {\n result[\"extensions\"] = { console: [...(context.debug.logs || [])] };\n if (context.debug.logs) {\n context.debug.logs.length = 0;\n }\n }\n } as GraphQLAfterQueryPlugin<DebugContext>\n];\n"],"mappings":"AAAA,SAASA,gBAAgB;AAGzB,SAASC,aAAa,QAAQ,aAAa;AAY3C,eAAe,MAAM,CACjB,IAAIA,aAAa,CAAe,MAAMC,OAAO,IAAI;EAC7C,IAAI,CAACA,OAAO,CAACC,KAAK,EAAE;IAChBD,OAAO,CAACC,KAAK,GAAG,CAAC,CAAC;EACtB;EAEA,IAAI,CAACD,OAAO,CAACC,KAAK,CAACC,IAAI,EAAE;IACrBF,OAAO,CAACC,KAAK,CAACC,IAAI,GAAG,EAAE;EAC3B;EAEAJ,gBAAgB,CAAC,CAACK,MAAM,EAAEC,IAAI,KAAK;IAC9BJ,OAAO,CAACC,KAAK,CAACC,IAAI,CAAWG,IAAI,CAAC;MAAEF,MAAM;MAAEC;IAAK,CAAC,CAAC;EACxD,CAAC,CAAC;AACN,CAAC,CAAC,EACF;EACIE,IAAI,EAAE,qBAAqB;EAC3BC,KAAKA,CAAC;IAAEC,MAAM;IAAER;EAAQ,CAAC,EAAE;IACvBQ,MAAM,CAAC,YAAY,CAAC,GAAG;MAAEC,OAAO,EAAE,CAAC,IAAIT,OAAO,CAACC,KAAK,CAACC,IAAI,IAAI,EAAE,CAAC;IAAE,CAAC;IACnE,IAAIF,OAAO,CAACC,KAAK,CAACC,IAAI,EAAE;MACpBF,OAAO,CAACC,KAAK,CAACC,IAAI,CAACQ,MAAM,GAAG,CAAC;IACjC;EACJ;AACJ,CAAC,CACJ","ignoreList":[]}
|
package/errors.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.NotFoundError = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
class NotFoundError extends _error.default {
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
export class NotFoundError extends WebinyError {
|
|
10
3
|
constructor(message = "Not found.") {
|
|
11
4
|
super(message, "NOT_FOUND");
|
|
12
5
|
}
|
|
13
6
|
}
|
|
14
|
-
exports.NotFoundError = NotFoundError;
|
|
15
7
|
|
|
16
8
|
//# sourceMappingURL=errors.js.map
|
package/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","NotFoundError","constructor","message"],"sources":["errors.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nexport class NotFoundError extends WebinyError {\n constructor(message = \"Not found.\") {\n super(message, \"NOT_FOUND\");\n }\n}\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AAEvC,OAAO,MAAMC,aAAa,SAASD,WAAW,CAAC;EAC3CE,WAAWA,CAACC,OAAO,GAAG,YAAY,EAAE;IAChC,KAAK,CAACA,OAAO,EAAE,WAAW,CAAC;EAC/B;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GraphQLSchemaFactory","ErrorResponse","ListResponse","Response","NotFoundResponse","ListErrorResponse"],"sources":["graphql.ts"],"sourcesContent":["export { GraphQLSchemaFactory } from \"~/graphql/abstractions.js\";\n\nexport {\n ErrorResponse,\n ListResponse,\n Response,\n NotFoundResponse,\n ListErrorResponse\n} from \"~/responses.js\";\n"],"mappings":"AAAA,SAASA,oBAAoB;AAE7B,SACIC,aAAa,EACbC,YAAY,EACZC,QAAQ,EACRC,gBAAgB,EAChBC,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GraphQLSchemaBuilder as Abstraction } from "./abstractions.js";
|
|
2
|
+
import type { IGraphQLSchema } from "../../graphql/abstractions.public.js";
|
|
3
|
+
import type { ResolverDecorator } from "../../types.js";
|
|
4
|
+
export declare class GraphQLSchemaBuilder implements Abstraction.Interface {
|
|
5
|
+
private readonly typeDefsArray;
|
|
6
|
+
private readonly resolvers;
|
|
7
|
+
private readonly resolverDecorators;
|
|
8
|
+
addTypeDefs(typeDefs: string): this;
|
|
9
|
+
addResolver<TArgs = any>(config: Abstraction.Config<TArgs>): this;
|
|
10
|
+
/**
|
|
11
|
+
* @internal This method needs revisiting, to align with DI concepts.
|
|
12
|
+
*/
|
|
13
|
+
addResolverDecorator(path: string, decorator: ResolverDecorator): this;
|
|
14
|
+
build(): IGraphQLSchema;
|
|
15
|
+
private setResolverAtPath;
|
|
16
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export class GraphQLSchemaBuilder {
|
|
2
|
+
typeDefsArray = [];
|
|
3
|
+
resolvers = {};
|
|
4
|
+
resolverDecorators = {};
|
|
5
|
+
addTypeDefs(typeDefs) {
|
|
6
|
+
this.typeDefsArray.push(typeDefs);
|
|
7
|
+
return this;
|
|
8
|
+
}
|
|
9
|
+
addResolver(config) {
|
|
10
|
+
const {
|
|
11
|
+
path,
|
|
12
|
+
dependencies = [],
|
|
13
|
+
resolver
|
|
14
|
+
} = config;
|
|
15
|
+
const pathParts = path.split(".");
|
|
16
|
+
const graphqlResolver = (parent, args, context, info) => {
|
|
17
|
+
const resolvedDeps = dependencies.map(dep => {
|
|
18
|
+
const [abstraction] = Array.isArray(dep) ? dep : [dep];
|
|
19
|
+
return context.container.resolve(abstraction);
|
|
20
|
+
});
|
|
21
|
+
const actualResolver = resolver(...resolvedDeps);
|
|
22
|
+
return actualResolver({
|
|
23
|
+
parent,
|
|
24
|
+
args,
|
|
25
|
+
context,
|
|
26
|
+
info
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
this.setResolverAtPath(pathParts, graphqlResolver);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @internal This method needs revisiting, to align with DI concepts.
|
|
35
|
+
*/
|
|
36
|
+
addResolverDecorator(path, decorator) {
|
|
37
|
+
if (!this.resolverDecorators[path]) {
|
|
38
|
+
this.resolverDecorators[path] = [];
|
|
39
|
+
}
|
|
40
|
+
this.resolverDecorators[path].push(decorator);
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
build() {
|
|
44
|
+
return {
|
|
45
|
+
typeDefs: this.typeDefsArray.join("\n"),
|
|
46
|
+
resolvers: this.resolvers,
|
|
47
|
+
resolverDecorators: this.resolverDecorators
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
setResolverAtPath(pathParts, resolver) {
|
|
51
|
+
let current = this.resolvers;
|
|
52
|
+
for (let i = 0; i < pathParts.length - 1; i++) {
|
|
53
|
+
const part = pathParts[i];
|
|
54
|
+
if (!current[part]) {
|
|
55
|
+
current[part] = {};
|
|
56
|
+
}
|
|
57
|
+
current = current[part];
|
|
58
|
+
}
|
|
59
|
+
const finalKey = pathParts[pathParts.length - 1];
|
|
60
|
+
current[finalKey] = resolver;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=GraphQLSchemaBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GraphQLSchemaBuilder","typeDefsArray","resolvers","resolverDecorators","addTypeDefs","typeDefs","push","addResolver","config","path","dependencies","resolver","pathParts","split","graphqlResolver","parent","args","context","info","resolvedDeps","map","dep","abstraction","Array","isArray","container","resolve","actualResolver","setResolverAtPath","addResolverDecorator","decorator","build","join","current","i","length","part","finalKey"],"sources":["GraphQLSchemaBuilder.ts"],"sourcesContent":["import type { GraphQLSchemaBuilder as Abstraction } from \"./abstractions.js\";\nimport type { IGraphQLSchema } from \"~/graphql/abstractions.public.js\";\nimport type { ResolverDecorator, ResolverDecorators, Resolvers } from \"~/types.js\";\nimport type { Dependency } from \"@webiny/di\";\n\nexport class GraphQLSchemaBuilder implements Abstraction.Interface {\n private readonly typeDefsArray: string[] = [];\n private readonly resolvers: Resolvers<any> = {};\n private readonly resolverDecorators: ResolverDecorators = {};\n\n addTypeDefs(typeDefs: string): this {\n this.typeDefsArray.push(typeDefs);\n return this;\n }\n\n addResolver<TArgs = any>(config: Abstraction.Config<TArgs>): this {\n const { path, dependencies = [], resolver } = config;\n\n const pathParts = path.split(\".\");\n\n const graphqlResolver = (parent: any, args: TArgs, context: any, info: any) => {\n const resolvedDeps = dependencies.map((dep: Dependency) => {\n const [abstraction] = Array.isArray(dep) ? dep : [dep];\n return context.container.resolve(abstraction);\n });\n\n const actualResolver = resolver(...resolvedDeps);\n\n return actualResolver({ parent, args, context, info });\n };\n\n this.setResolverAtPath(pathParts, graphqlResolver);\n\n return this;\n }\n\n /**\n * @internal This method needs revisiting, to align with DI concepts.\n */\n addResolverDecorator(path: string, decorator: ResolverDecorator): this {\n if (!this.resolverDecorators[path]) {\n this.resolverDecorators[path] = [];\n }\n this.resolverDecorators[path].push(decorator);\n return this;\n }\n\n build(): IGraphQLSchema {\n return {\n typeDefs: this.typeDefsArray.join(\"\\n\"),\n resolvers: this.resolvers,\n resolverDecorators: this.resolverDecorators\n };\n }\n\n private setResolverAtPath(pathParts: string[], resolver: any): void {\n let current: any = this.resolvers;\n\n for (let i = 0; i < pathParts.length - 1; i++) {\n const part = pathParts[i];\n if (!current[part]) {\n current[part] = {};\n }\n current = current[part];\n }\n\n const finalKey = pathParts[pathParts.length - 1];\n current[finalKey] = resolver;\n }\n}\n"],"mappings":"AAKA,OAAO,MAAMA,oBAAoB,CAAkC;EAC9CC,aAAa,GAAa,EAAE;EAC5BC,SAAS,GAAmB,CAAC,CAAC;EAC9BC,kBAAkB,GAAuB,CAAC,CAAC;EAE5DC,WAAWA,CAACC,QAAgB,EAAQ;IAChC,IAAI,CAACJ,aAAa,CAACK,IAAI,CAACD,QAAQ,CAAC;IACjC,OAAO,IAAI;EACf;EAEAE,WAAWA,CAAcC,MAAiC,EAAQ;IAC9D,MAAM;MAAEC,IAAI;MAAEC,YAAY,GAAG,EAAE;MAAEC;IAAS,CAAC,GAAGH,MAAM;IAEpD,MAAMI,SAAS,GAAGH,IAAI,CAACI,KAAK,CAAC,GAAG,CAAC;IAEjC,MAAMC,eAAe,GAAGA,CAACC,MAAW,EAAEC,IAAW,EAAEC,OAAY,EAAEC,IAAS,KAAK;MAC3E,MAAMC,YAAY,GAAGT,YAAY,CAACU,GAAG,CAAEC,GAAe,IAAK;QACvD,MAAM,CAACC,WAAW,CAAC,GAAGC,KAAK,CAACC,OAAO,CAACH,GAAG,CAAC,GAAGA,GAAG,GAAG,CAACA,GAAG,CAAC;QACtD,OAAOJ,OAAO,CAACQ,SAAS,CAACC,OAAO,CAACJ,WAAW,CAAC;MACjD,CAAC,CAAC;MAEF,MAAMK,cAAc,GAAGhB,QAAQ,CAAC,GAAGQ,YAAY,CAAC;MAEhD,OAAOQ,cAAc,CAAC;QAAEZ,MAAM;QAAEC,IAAI;QAAEC,OAAO;QAAEC;MAAK,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,CAACU,iBAAiB,CAAChB,SAAS,EAAEE,eAAe,CAAC;IAElD,OAAO,IAAI;EACf;;EAEA;AACJ;AACA;EACIe,oBAAoBA,CAACpB,IAAY,EAAEqB,SAA4B,EAAQ;IACnE,IAAI,CAAC,IAAI,CAAC3B,kBAAkB,CAACM,IAAI,CAAC,EAAE;MAChC,IAAI,CAACN,kBAAkB,CAACM,IAAI,CAAC,GAAG,EAAE;IACtC;IACA,IAAI,CAACN,kBAAkB,CAACM,IAAI,CAAC,CAACH,IAAI,CAACwB,SAAS,CAAC;IAC7C,OAAO,IAAI;EACf;EAEAC,KAAKA,CAAA,EAAmB;IACpB,OAAO;MACH1B,QAAQ,EAAE,IAAI,CAACJ,aAAa,CAAC+B,IAAI,CAAC,IAAI,CAAC;MACvC9B,SAAS,EAAE,IAAI,CAACA,SAAS;MACzBC,kBAAkB,EAAE,IAAI,CAACA;IAC7B,CAAC;EACL;EAEQyB,iBAAiBA,CAAChB,SAAmB,EAAED,QAAa,EAAQ;IAChE,IAAIsB,OAAY,GAAG,IAAI,CAAC/B,SAAS;IAEjC,KAAK,IAAIgC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGtB,SAAS,CAACuB,MAAM,GAAG,CAAC,EAAED,CAAC,EAAE,EAAE;MAC3C,MAAME,IAAI,GAAGxB,SAAS,CAACsB,CAAC,CAAC;MACzB,IAAI,CAACD,OAAO,CAACG,IAAI,CAAC,EAAE;QAChBH,OAAO,CAACG,IAAI,CAAC,GAAG,CAAC,CAAC;MACtB;MACAH,OAAO,GAAGA,OAAO,CAACG,IAAI,CAAC;IAC3B;IAEA,MAAMC,QAAQ,GAAGzB,SAAS,CAACA,SAAS,CAACuB,MAAM,GAAG,CAAC,CAAC;IAChDF,OAAO,CAACI,QAAQ,CAAC,GAAG1B,QAAQ;EAChC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GraphQLSchemaComposer as Abstraction } from "./abstractions.js";
|
|
2
|
+
import { GraphQLSchemaFactory, CoreGraphQLSchemaFactory } from "../../graphql/abstractions.js";
|
|
3
|
+
import type { IGraphQLSchema } from "../../graphql/abstractions.public.js";
|
|
4
|
+
declare class GraphQLSchemaComposerImpl implements Abstraction.Interface {
|
|
5
|
+
private coreSchemas;
|
|
6
|
+
private userSchemas;
|
|
7
|
+
constructor(coreSchemas: CoreGraphQLSchemaFactory.Interface[], userSchemas: GraphQLSchemaFactory.Interface[]);
|
|
8
|
+
build(): Promise<IGraphQLSchema>;
|
|
9
|
+
}
|
|
10
|
+
export declare const GraphQLSchemaComposer: typeof GraphQLSchemaComposerImpl & {
|
|
11
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGraphQLSchemaComposer>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { GraphQLSchemaComposer as Abstraction } from "./abstractions.js";
|
|
2
|
+
import { GraphQLSchemaFactory, CoreGraphQLSchemaFactory } from "../../graphql/abstractions.js";
|
|
3
|
+
import { GraphQLSchemaBuilder } from "./GraphQLSchemaBuilder.js";
|
|
4
|
+
class GraphQLSchemaComposerImpl {
|
|
5
|
+
constructor(coreSchemas, userSchemas) {
|
|
6
|
+
this.coreSchemas = coreSchemas;
|
|
7
|
+
this.userSchemas = userSchemas;
|
|
8
|
+
}
|
|
9
|
+
async build() {
|
|
10
|
+
const builder = new GraphQLSchemaBuilder();
|
|
11
|
+
for (const factory of this.coreSchemas) {
|
|
12
|
+
await factory.execute(builder);
|
|
13
|
+
}
|
|
14
|
+
for (const factory of this.userSchemas) {
|
|
15
|
+
await factory.execute(builder);
|
|
16
|
+
}
|
|
17
|
+
return builder.build();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export const GraphQLSchemaComposer = Abstraction.createImplementation({
|
|
21
|
+
implementation: GraphQLSchemaComposerImpl,
|
|
22
|
+
dependencies: [[CoreGraphQLSchemaFactory, {
|
|
23
|
+
multiple: true
|
|
24
|
+
}], [GraphQLSchemaFactory, {
|
|
25
|
+
multiple: true
|
|
26
|
+
}]]
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=GraphQLSchemaComposer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GraphQLSchemaComposer","Abstraction","GraphQLSchemaFactory","CoreGraphQLSchemaFactory","GraphQLSchemaBuilder","GraphQLSchemaComposerImpl","constructor","coreSchemas","userSchemas","build","builder","factory","execute","createImplementation","implementation","dependencies","multiple"],"sources":["GraphQLSchemaComposer.ts"],"sourcesContent":["import { GraphQLSchemaComposer as Abstraction } from \"./abstractions.js\";\nimport { GraphQLSchemaFactory, CoreGraphQLSchemaFactory } from \"~/graphql/abstractions.js\";\nimport { GraphQLSchemaBuilder } from \"./GraphQLSchemaBuilder.js\";\nimport type { IGraphQLSchema } from \"~/graphql/abstractions.public.js\";\n\nclass GraphQLSchemaComposerImpl implements Abstraction.Interface {\n constructor(\n private coreSchemas: CoreGraphQLSchemaFactory.Interface[],\n private userSchemas: GraphQLSchemaFactory.Interface[]\n ) {}\n\n async build(): Promise<IGraphQLSchema> {\n const builder = new GraphQLSchemaBuilder();\n\n for (const factory of this.coreSchemas) {\n await factory.execute(builder);\n }\n\n for (const factory of this.userSchemas) {\n await factory.execute(builder);\n }\n\n return builder.build();\n }\n}\n\nexport const GraphQLSchemaComposer = Abstraction.createImplementation({\n implementation: GraphQLSchemaComposerImpl,\n dependencies: [\n [CoreGraphQLSchemaFactory, { multiple: true }],\n [GraphQLSchemaFactory, { multiple: true }]\n ]\n});\n"],"mappings":"AAAA,SAASA,qBAAqB,IAAIC,WAAW;AAC7C,SAASC,oBAAoB,EAAEC,wBAAwB;AACvD,SAASC,oBAAoB;AAG7B,MAAMC,yBAAyB,CAAkC;EAC7DC,WAAWA,CACCC,WAAiD,EACjDC,WAA6C,EACvD;IAAA,KAFUD,WAAiD,GAAjDA,WAAiD;IAAA,KACjDC,WAA6C,GAA7CA,WAA6C;EACtD;EAEH,MAAMC,KAAKA,CAAA,EAA4B;IACnC,MAAMC,OAAO,GAAG,IAAIN,oBAAoB,CAAC,CAAC;IAE1C,KAAK,MAAMO,OAAO,IAAI,IAAI,CAACJ,WAAW,EAAE;MACpC,MAAMI,OAAO,CAACC,OAAO,CAACF,OAAO,CAAC;IAClC;IAEA,KAAK,MAAMC,OAAO,IAAI,IAAI,CAACH,WAAW,EAAE;MACpC,MAAMG,OAAO,CAACC,OAAO,CAACF,OAAO,CAAC;IAClC;IAEA,OAAOA,OAAO,CAACD,KAAK,CAAC,CAAC;EAC1B;AACJ;AAEA,OAAO,MAAMT,qBAAqB,GAAGC,WAAW,CAACY,oBAAoB,CAAC;EAClEC,cAAc,EAAET,yBAAyB;EACzCU,YAAY,EAAE,CACV,CAACZ,wBAAwB,EAAE;IAAEa,QAAQ,EAAE;EAAK,CAAC,CAAC,EAC9C,CAACd,oBAAoB,EAAE;IAAEc,QAAQ,EAAE;EAAK,CAAC,CAAC;AAElD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ResolverDecorator, TypeDefs } from "../../types.js";
|
|
2
|
+
import type { Dependency } from "@webiny/di";
|
|
3
|
+
import type { IGraphQLSchema } from "../../graphql/abstractions.public.js";
|
|
4
|
+
export interface ResolverConfig<TArgs = any, TParent = any> {
|
|
5
|
+
path: string;
|
|
6
|
+
dependencies?: Dependency[];
|
|
7
|
+
resolver: (...resolvedDeps: any[]) => (params: {
|
|
8
|
+
parent: TParent;
|
|
9
|
+
args: TArgs;
|
|
10
|
+
context: any;
|
|
11
|
+
info: any;
|
|
12
|
+
}) => any;
|
|
13
|
+
}
|
|
14
|
+
export interface IGraphQLSchemaBuilder {
|
|
15
|
+
addTypeDefs(typeDefs: TypeDefs): this;
|
|
16
|
+
addResolver<TArgs = any, TParent = any>(config: ResolverConfig<TArgs, TParent>): this;
|
|
17
|
+
/**
|
|
18
|
+
* @internal This method needs revisiting, to align with DI concepts.
|
|
19
|
+
*/
|
|
20
|
+
addResolverDecorator(path: string, decorator: ResolverDecorator): this;
|
|
21
|
+
build(): IGraphQLSchema;
|
|
22
|
+
}
|
|
23
|
+
export declare const GraphQLSchemaBuilder: import("@webiny/di").Abstraction<IGraphQLSchemaBuilder>;
|
|
24
|
+
export declare namespace GraphQLSchemaBuilder {
|
|
25
|
+
type Interface = IGraphQLSchemaBuilder;
|
|
26
|
+
type Config<TArgs = any> = ResolverConfig<TArgs>;
|
|
27
|
+
}
|
|
28
|
+
export interface IGraphQLSchemaComposer {
|
|
29
|
+
build(): Promise<IGraphQLSchema>;
|
|
30
|
+
}
|
|
31
|
+
export declare const GraphQLSchemaComposer: import("@webiny/di").Abstraction<IGraphQLSchemaComposer>;
|
|
32
|
+
export declare namespace GraphQLSchemaComposer {
|
|
33
|
+
type Interface = IGraphQLSchemaComposer;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","GraphQLSchemaBuilder","GraphQLSchemaComposer"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { ResolverDecorator, TypeDefs } from \"~/types.js\";\nimport type { Dependency } from \"@webiny/di\";\nimport type { IGraphQLSchema } from \"~/graphql/abstractions.public.js\";\n\nexport interface ResolverConfig<TArgs = any, TParent = any> {\n path: string;\n dependencies?: Dependency[];\n resolver: (\n ...resolvedDeps: any[]\n ) => (params: { parent: TParent; args: TArgs; context: any; info: any }) => any;\n}\n\nexport interface IGraphQLSchemaBuilder {\n addTypeDefs(typeDefs: TypeDefs): this;\n addResolver<TArgs = any, TParent = any>(config: ResolverConfig<TArgs, TParent>): this;\n /**\n * @internal This method needs revisiting, to align with DI concepts.\n */\n addResolverDecorator(path: string, decorator: ResolverDecorator): this;\n build(): IGraphQLSchema;\n}\n\nexport const GraphQLSchemaBuilder =\n createAbstraction<IGraphQLSchemaBuilder>(\"GraphQLSchemaBuilder\");\n\nexport namespace GraphQLSchemaBuilder {\n export type Interface = IGraphQLSchemaBuilder;\n export type Config<TArgs = any> = ResolverConfig<TArgs>;\n}\n\nexport interface IGraphQLSchemaComposer {\n build(): Promise<IGraphQLSchema>;\n}\n\nexport const GraphQLSchemaComposer =\n createAbstraction<IGraphQLSchemaComposer>(\"GraphQLSchemaComposer\");\n\nexport namespace GraphQLSchemaComposer {\n export type Interface = IGraphQLSchemaComposer;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAuBvD,OAAO,MAAMC,oBAAoB,GAC7BD,iBAAiB,CAAwB,sBAAsB,CAAC;AAWpE,OAAO,MAAME,qBAAqB,GAC9BF,iBAAiB,CAAyB,uBAAuB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GraphQLSchemaComposerFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { GraphQLSchemaComposer } from "./GraphQLSchemaComposer.js";
|
|
3
|
+
export const GraphQLSchemaComposerFeature = createFeature({
|
|
4
|
+
name: "GraphQLSchemaComposer",
|
|
5
|
+
register(container) {
|
|
6
|
+
container.register(GraphQLSchemaComposer);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","GraphQLSchemaComposer","GraphQLSchemaComposerFeature","name","register","container"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GraphQLSchemaComposer } from \"./GraphQLSchemaComposer.js\";\n\nexport const GraphQLSchemaComposerFeature = createFeature({\n name: \"GraphQLSchemaComposer\",\n register(container) {\n container.register(GraphQLSchemaComposer);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,4BAA4B,GAAGF,aAAa,CAAC;EACtDG,IAAI,EAAE,uBAAuB;EAC7BC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,qBAAqB,CAAC;EAC7C;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IGraphQLSchemaFactory } from "./abstractions.public.js";
|
|
2
|
+
import type { GraphQLSchemaBuilder } from "../features/GraphQLSchemaBuilder/abstractions.js";
|
|
3
|
+
/**
|
|
4
|
+
* CoreGraphQLSchemaFactory
|
|
5
|
+
*/
|
|
6
|
+
export declare const CoreGraphQLSchemaFactory: import("@webiny/di").Abstraction<IGraphQLSchemaFactory>;
|
|
7
|
+
export declare namespace CoreGraphQLSchemaFactory {
|
|
8
|
+
type Interface = IGraphQLSchemaFactory;
|
|
9
|
+
type SchemaBuilder = GraphQLSchemaBuilder.Interface;
|
|
10
|
+
type Return = Promise<GraphQLSchemaBuilder.Interface>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains abstraction for use by the core Webiny team, or anyone contributing to the webiny-js repository.
|
|
3
|
+
*/
|
|
4
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
5
|
+
/**
|
|
6
|
+
* CoreGraphQLSchemaFactory
|
|
7
|
+
*/
|
|
8
|
+
export const CoreGraphQLSchemaFactory = createAbstraction("CoreGraphQLSchemaFactory");
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=abstractions.core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","CoreGraphQLSchemaFactory"],"sources":["abstractions.core.ts"],"sourcesContent":["/**\n * This file contains abstraction for use by the core Webiny team, or anyone contributing to the webiny-js repository.\n */\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { IGraphQLSchemaFactory } from \"./abstractions.public.js\";\nimport type { GraphQLSchemaBuilder } from \"~/features/GraphQLSchemaBuilder/abstractions.js\";\n\n/**\n * CoreGraphQLSchemaFactory\n */\nexport const CoreGraphQLSchemaFactory = createAbstraction<IGraphQLSchemaFactory>(\n \"CoreGraphQLSchemaFactory\"\n);\nexport namespace CoreGraphQLSchemaFactory {\n export type Interface = IGraphQLSchemaFactory;\n export type SchemaBuilder = GraphQLSchemaBuilder.Interface;\n export type Return = Promise<GraphQLSchemaBuilder.Interface>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,iBAAiB,QAAQ,qBAAqB;AAIvD;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAGD,iBAAiB,CACrD,0BACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["abstractions.ts"],"sourcesContent":["export * from \"./abstractions.core.js\";\nexport * from \"./abstractions.public.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Resolvers as IResolvers, TypeDefs as ITypeDefs, ResolverDecorators as IResolverDecorators } from "../types.js";
|
|
2
|
+
import type { GraphQLSchemaBuilder } from "../features/GraphQLSchemaBuilder/abstractions.js";
|
|
3
|
+
export interface IGraphQLSchema {
|
|
4
|
+
typeDefs?: ITypeDefs;
|
|
5
|
+
resolvers?: IResolvers<any>;
|
|
6
|
+
resolverDecorators?: IResolverDecorators;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* GraphQLSchemaFactory
|
|
10
|
+
*/
|
|
11
|
+
export interface IGraphQLSchemaFactory {
|
|
12
|
+
execute(builder: GraphQLSchemaBuilder.Interface): Promise<GraphQLSchemaBuilder.Interface>;
|
|
13
|
+
}
|
|
14
|
+
export declare const GraphQLSchemaFactory: import("@webiny/di").Abstraction<IGraphQLSchemaFactory>;
|
|
15
|
+
export declare namespace GraphQLSchemaFactory {
|
|
16
|
+
type Interface = IGraphQLSchemaFactory;
|
|
17
|
+
type SchemaBuilder = GraphQLSchemaBuilder.Interface;
|
|
18
|
+
type Return = Promise<GraphQLSchemaBuilder.Interface>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains abstraction for use by third party developers.
|
|
3
|
+
*/
|
|
4
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* GraphQLSchemaFactory
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const GraphQLSchemaFactory = createAbstraction("GraphQLSchemaFactory");
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=abstractions.public.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","GraphQLSchemaFactory"],"sources":["abstractions.public.ts"],"sourcesContent":["/**\n * This file contains abstraction for use by third party developers.\n */\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type {\n Resolvers as IResolvers,\n TypeDefs as ITypeDefs,\n ResolverDecorators as IResolverDecorators\n} from \"~/types.js\";\nimport type { GraphQLSchemaBuilder } from \"~/features/GraphQLSchemaBuilder/abstractions.js\";\n\nexport interface IGraphQLSchema {\n typeDefs?: ITypeDefs;\n resolvers?: IResolvers<any>;\n resolverDecorators?: IResolverDecorators;\n}\n\n/**\n * GraphQLSchemaFactory\n */\nexport interface IGraphQLSchemaFactory {\n execute(builder: GraphQLSchemaBuilder.Interface): Promise<GraphQLSchemaBuilder.Interface>;\n}\n\nexport const GraphQLSchemaFactory =\n createAbstraction<IGraphQLSchemaFactory>(\"GraphQLSchemaFactory\");\n\nexport namespace GraphQLSchemaFactory {\n export type Interface = IGraphQLSchemaFactory;\n export type SchemaBuilder = GraphQLSchemaBuilder.Interface;\n export type Return = Promise<GraphQLSchemaBuilder.Interface>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAcvD;AACA;AACA;;AAKA,OAAO,MAAMC,oBAAoB,GAC7BD,iBAAiB,CAAwB,sBAAsB,CAAC","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
6
|
-
|
|
1
|
+
import type { Plugin } from "@webiny/plugins/types.js";
|
|
2
|
+
import type { HandlerGraphQLOptions } from "./types.js";
|
|
3
|
+
export * from "./errors.js";
|
|
4
|
+
export * from "./responses.js";
|
|
5
|
+
export * from "./utils/index.js";
|
|
6
|
+
export * from "./plugins/index.js";
|
|
7
|
+
export * from "./processRequestBody.js";
|
|
8
|
+
export * from "./createResolverDecorator.js";
|
|
9
|
+
export * from "./ResolverDecoration.js";
|
|
10
|
+
declare const _default: (options?: HandlerGraphQLOptions) => Plugin[];
|
|
7
11
|
export default _default;
|
package/index.js
CHANGED
|
@@ -1,61 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (key === "default" || key === "__esModule") return;
|
|
13
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
14
|
-
if (key in exports && exports[key] === _errors[key]) return;
|
|
15
|
-
Object.defineProperty(exports, key, {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () {
|
|
18
|
-
return _errors[key];
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
var _responses = require("./responses");
|
|
23
|
-
Object.keys(_responses).forEach(function (key) {
|
|
24
|
-
if (key === "default" || key === "__esModule") return;
|
|
25
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
26
|
-
if (key in exports && exports[key] === _responses[key]) return;
|
|
27
|
-
Object.defineProperty(exports, key, {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function () {
|
|
30
|
-
return _responses[key];
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
var _plugins = require("./plugins");
|
|
35
|
-
Object.keys(_plugins).forEach(function (key) {
|
|
36
|
-
if (key === "default" || key === "__esModule") return;
|
|
37
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
38
|
-
if (key in exports && exports[key] === _plugins[key]) return;
|
|
39
|
-
Object.defineProperty(exports, key, {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
get: function () {
|
|
42
|
-
return _plugins[key];
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
var _processRequestBody = require("./processRequestBody");
|
|
47
|
-
Object.keys(_processRequestBody).forEach(function (key) {
|
|
48
|
-
if (key === "default" || key === "__esModule") return;
|
|
49
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
50
|
-
if (key in exports && exports[key] === _processRequestBody[key]) return;
|
|
51
|
-
Object.defineProperty(exports, key, {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: function () {
|
|
54
|
-
return _processRequestBody[key];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
var _default = (options = {}) => [(0, _createGraphQLHandler.default)(options)];
|
|
59
|
-
exports.default = _default;
|
|
1
|
+
import createGraphQLHandler from "./createGraphQLHandler.js";
|
|
2
|
+
export * from "./errors.js";
|
|
3
|
+
export * from "./responses.js";
|
|
4
|
+
export * from "./utils/index.js";
|
|
5
|
+
export * from "./plugins/index.js";
|
|
6
|
+
export * from "./processRequestBody.js";
|
|
7
|
+
export * from "./createResolverDecorator.js";
|
|
8
|
+
export * from "./ResolverDecoration.js";
|
|
9
|
+
export default (options = {}) => {
|
|
10
|
+
return createGraphQLHandler(options);
|
|
11
|
+
};
|
|
60
12
|
|
|
61
13
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createGraphQLHandler","options"],"sources":["index.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\nimport type { HandlerGraphQLOptions } from \"./types.js\";\nimport createGraphQLHandler from \"./createGraphQLHandler.js\";\n\nexport * from \"./errors.js\";\nexport * from \"./responses.js\";\nexport * from \"./utils/index.js\";\nexport * from \"./plugins/index.js\";\nexport * from \"./processRequestBody.js\";\nexport * from \"./createResolverDecorator.js\";\nexport * from \"./ResolverDecoration.js\";\n\nexport default (options: HandlerGraphQLOptions = {}): Plugin[] => {\n return createGraphQLHandler(options);\n};\n"],"mappings":"AAEA,OAAOA,oBAAoB;AAE3B;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,eAAe,CAACC,OAA8B,GAAG,CAAC,CAAC,KAAe;EAC9D,OAAOD,oBAAoB,CAACC,OAAO,CAAC;AACxC,CAAC","ignoreList":[]}
|
package/interceptConsole.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.interceptConsole = void 0;
|
|
7
1
|
const consoleMethods = ["assert", "debug", "dir", "error", "group", "groupCollapsed", "groupEnd", "info", "log", "table", "warn"];
|
|
8
2
|
const originalMethods = {};
|
|
9
3
|
const skipOriginal = ["table"];
|
|
@@ -13,7 +7,7 @@ const restoreOriginalMethods = () => {
|
|
|
13
7
|
console[method] = originalMethods[method];
|
|
14
8
|
}
|
|
15
9
|
};
|
|
16
|
-
const interceptConsole = callback => {
|
|
10
|
+
export const interceptConsole = callback => {
|
|
17
11
|
// @ts-expect-error
|
|
18
12
|
if (console["__WEBINY__"] === true) {
|
|
19
13
|
restoreOriginalMethods();
|
|
@@ -34,6 +28,5 @@ const interceptConsole = callback => {
|
|
|
34
28
|
};
|
|
35
29
|
}
|
|
36
30
|
};
|
|
37
|
-
exports.interceptConsole = interceptConsole;
|
|
38
31
|
|
|
39
32
|
//# sourceMappingURL=interceptConsole.js.map
|
package/interceptConsole.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["consoleMethods","originalMethods","skipOriginal","restoreOriginalMethods","method","console","interceptConsole","callback","args","includes"
|
|
1
|
+
{"version":3,"names":["consoleMethods","originalMethods","skipOriginal","restoreOriginalMethods","method","console","interceptConsole","callback","args","includes"],"sources":["interceptConsole.ts"],"sourcesContent":["const consoleMethods = [\n \"assert\",\n \"debug\",\n \"dir\",\n \"error\",\n \"group\",\n \"groupCollapsed\",\n \"groupEnd\",\n \"info\",\n \"log\",\n \"table\",\n \"warn\"\n];\n\nconst originalMethods: Record<string, any> = {};\nconst skipOriginal: string[] = [\"table\"];\n\nconst restoreOriginalMethods = () => {\n for (const method of consoleMethods) {\n // @ts-expect-error\n console[method] = originalMethods[method];\n }\n};\n\ninterface InterceptConsoleCallable {\n (method: string, args: any[]): void;\n}\n\nexport const interceptConsole = (callback: InterceptConsoleCallable) => {\n // @ts-expect-error\n if (console[\"__WEBINY__\"] === true) {\n restoreOriginalMethods();\n }\n\n // @ts-expect-error\n console[\"__WEBINY__\"] = true;\n\n for (const method of consoleMethods) {\n // @ts-expect-error\n originalMethods[method] = console[method];\n // @ts-expect-error\n console[method] = (...args) => {\n callback(method, args);\n if (skipOriginal.includes(method)) {\n return;\n }\n originalMethods[method](...args);\n };\n }\n};\n"],"mappings":"AAAA,MAAMA,cAAc,GAAG,CACnB,QAAQ,EACR,OAAO,EACP,KAAK,EACL,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,KAAK,EACL,OAAO,EACP,MAAM,CACT;AAED,MAAMC,eAAoC,GAAG,CAAC,CAAC;AAC/C,MAAMC,YAAsB,GAAG,CAAC,OAAO,CAAC;AAExC,MAAMC,sBAAsB,GAAGA,CAAA,KAAM;EACjC,KAAK,MAAMC,MAAM,IAAIJ,cAAc,EAAE;IACjC;IACAK,OAAO,CAACD,MAAM,CAAC,GAAGH,eAAe,CAACG,MAAM,CAAC;EAC7C;AACJ,CAAC;AAMD,OAAO,MAAME,gBAAgB,GAAIC,QAAkC,IAAK;EACpE;EACA,IAAIF,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,EAAE;IAChCF,sBAAsB,CAAC,CAAC;EAC5B;;EAEA;EACAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;EAE5B,KAAK,MAAMD,MAAM,IAAIJ,cAAc,EAAE;IACjC;IACAC,eAAe,CAACG,MAAM,CAAC,GAAGC,OAAO,CAACD,MAAM,CAAC;IACzC;IACAC,OAAO,CAACD,MAAM,CAAC,GAAG,CAAC,GAAGI,IAAI,KAAK;MAC3BD,QAAQ,CAACH,MAAM,EAAEI,IAAI,CAAC;MACtB,IAAIN,YAAY,CAACO,QAAQ,CAACL,MAAM,CAAC,EAAE;QAC/B;MACJ;MACAH,eAAe,CAACG,MAAM,CAAC,CAAC,GAAGI,IAAI,CAAC;IACpC,CAAC;EACL;AACJ,CAAC","ignoreList":[]}
|