@webiny/handler-graphql 0.0.0-unstable.1e66d121db → 0.0.0-unstable.2696f9d9e8
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/builtInTypes/AnyScalar.d.ts +1 -1
- package/builtInTypes/AnyScalar.js +5 -6
- package/builtInTypes/AnyScalar.js.map +1 -1
- package/builtInTypes/DateScalar.js +6 -12
- package/builtInTypes/DateScalar.js.map +1 -1
- package/builtInTypes/DateTimeScalar.js +6 -12
- package/builtInTypes/DateTimeScalar.js.map +1 -1
- package/builtInTypes/DateTimeZScalar.js +3 -14
- package/builtInTypes/DateTimeZScalar.js.map +1 -1
- package/builtInTypes/JsonScalar.js +3 -3
- package/builtInTypes/JsonScalar.js.map +1 -1
- package/builtInTypes/LongScalar.d.ts +2 -1
- package/builtInTypes/LongScalar.js +50 -4
- package/builtInTypes/LongScalar.js.map +1 -1
- package/builtInTypes/NumberScalar.d.ts +1 -1
- package/builtInTypes/NumberScalar.js +10 -14
- package/builtInTypes/NumberScalar.js.map +1 -1
- package/builtInTypes/RefInputScalar.d.ts +1 -1
- package/builtInTypes/RefInputScalar.js +35 -23
- package/builtInTypes/RefInputScalar.js.map +1 -1
- package/builtInTypes/TimeScalar.js +3 -13
- package/builtInTypes/TimeScalar.js.map +1 -1
- package/builtInTypes/index.js +3 -19
- package/builtInTypes/index.js.map +1 -1
- package/createGraphQLHandler.d.ts +1 -1
- package/createGraphQLHandler.js +64 -21
- package/createGraphQLHandler.js.map +1 -1
- package/createGraphQLSchema.d.ts +2 -0
- package/createGraphQLSchema.js +29 -26
- package/createGraphQLSchema.js.map +1 -1
- package/debugPlugins.js +2 -9
- package/debugPlugins.js.map +1 -1
- package/errors.js +2 -5
- package/errors.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +12 -11
- package/index.js.map +1 -1
- package/interceptConsole.js +9 -13
- package/interceptConsole.js.map +1 -1
- package/package.json +17 -16
- package/plugins/GraphQLSchemaPlugin.js +3 -11
- package/plugins/GraphQLSchemaPlugin.js.map +1 -1
- package/plugins/index.js +3 -3
- package/plugins/index.js.map +1 -1
- package/processRequestBody.js +8 -12
- package/processRequestBody.js.map +1 -1
- package/responses.js +6 -36
- package/responses.js.map +1 -1
- package/types.d.ts +1 -1
- package/types.js +3 -1
- package/types.js.map +1 -1
package/interceptConsole.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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-
|
|
1
|
+
{"version":3,"names":["consoleMethods","originalMethods","skipOriginal","restoreOriginalMethods","method","console","interceptConsole","callback","args","includes","exports"],"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;AAMM,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;AAACE,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/handler-graphql",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.2696f9d9e8",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -14,27 +14,28 @@
|
|
|
14
14
|
"Adrian Smijulj <adrian@webiny.com>"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@babel/runtime": "7.
|
|
17
|
+
"@babel/runtime": "7.22.6",
|
|
18
18
|
"@graphql-tools/schema": "7.1.5",
|
|
19
|
-
"@webiny/api": "0.0.0-unstable.
|
|
20
|
-
"@webiny/error": "0.0.0-unstable.
|
|
21
|
-
"@webiny/handler": "0.0.0-unstable.
|
|
22
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
19
|
+
"@webiny/api": "0.0.0-unstable.2696f9d9e8",
|
|
20
|
+
"@webiny/error": "0.0.0-unstable.2696f9d9e8",
|
|
21
|
+
"@webiny/handler": "0.0.0-unstable.2696f9d9e8",
|
|
22
|
+
"@webiny/plugins": "0.0.0-unstable.2696f9d9e8",
|
|
23
23
|
"boolean": "3.2.0",
|
|
24
24
|
"graphql": "15.8.0",
|
|
25
25
|
"graphql-scalars": "1.12.0",
|
|
26
26
|
"graphql-tag": "2.12.6"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@babel/cli": "
|
|
30
|
-
"@babel/core": "
|
|
31
|
-
"@babel/preset-env": "
|
|
32
|
-
"@webiny/cli": "
|
|
33
|
-
"@webiny/handler-aws": "
|
|
34
|
-
"@webiny/project-utils": "
|
|
35
|
-
"jest": "
|
|
36
|
-
"jest-mock-console": "
|
|
37
|
-
"rimraf": "
|
|
29
|
+
"@babel/cli": "7.22.6",
|
|
30
|
+
"@babel/core": "7.22.8",
|
|
31
|
+
"@babel/preset-env": "7.22.7",
|
|
32
|
+
"@webiny/cli": "0.0.0-unstable.2696f9d9e8",
|
|
33
|
+
"@webiny/handler-aws": "0.0.0-unstable.2696f9d9e8",
|
|
34
|
+
"@webiny/project-utils": "0.0.0-unstable.2696f9d9e8",
|
|
35
|
+
"jest": "29.5.0",
|
|
36
|
+
"jest-mock-console": "1.3.0",
|
|
37
|
+
"rimraf": "3.0.2",
|
|
38
|
+
"ttypescript": "1.5.15",
|
|
38
39
|
"typescript": "4.7.4"
|
|
39
40
|
},
|
|
40
41
|
"publishConfig": {
|
|
@@ -45,5 +46,5 @@
|
|
|
45
46
|
"build": "yarn webiny run build",
|
|
46
47
|
"watch": "yarn webiny run watch"
|
|
47
48
|
},
|
|
48
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "2696f9d9e84ad621e1412a05e1252b5ca9c245fb"
|
|
49
50
|
}
|
|
@@ -1,31 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.GraphQLSchemaPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
7
|
var _plugins = require("@webiny/plugins");
|
|
13
|
-
|
|
14
8
|
class GraphQLSchemaPlugin extends _plugins.Plugin {
|
|
9
|
+
static type = "graphql-schema";
|
|
15
10
|
constructor(config) {
|
|
16
11
|
super();
|
|
17
|
-
(0, _defineProperty2.default)(this, "config", void 0);
|
|
18
12
|
this.config = config;
|
|
19
13
|
}
|
|
20
|
-
|
|
21
14
|
get schema() {
|
|
22
15
|
return {
|
|
23
16
|
typeDefs: this.config.typeDefs || "",
|
|
24
17
|
resolvers: this.config.resolvers
|
|
25
18
|
};
|
|
26
19
|
}
|
|
27
|
-
|
|
28
20
|
}
|
|
29
|
-
|
|
30
21
|
exports.GraphQLSchemaPlugin = GraphQLSchemaPlugin;
|
|
31
|
-
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=GraphQLSchemaPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GraphQLSchemaPlugin","Plugin","constructor","config","schema","typeDefs","resolvers"],"sources":["GraphQLSchemaPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { GraphQLSchemaDefinition, Resolvers, Types } from \"~/types\";\nimport { Context } from \"@webiny/api/types\";\n\nexport interface GraphQLSchemaPluginConfig<TContext> {\n typeDefs?: Types;\n resolvers?: Resolvers<TContext>;\n}\n\nexport class GraphQLSchemaPlugin<TContext = Context> extends Plugin {\n public static override readonly type: string = \"graphql-schema\";\n private config: GraphQLSchemaPluginConfig<TContext>;\n\n constructor(config: GraphQLSchemaPluginConfig<TContext>) {\n super();\n this.config = config;\n }\n\n get schema(): GraphQLSchemaDefinition<TContext> {\n return {\n typeDefs: this.config.typeDefs || \"\",\n resolvers: this.config.resolvers\n };\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_plugins","require","GraphQLSchemaPlugin","Plugin","type","constructor","config","schema","typeDefs","resolvers","exports"],"sources":["GraphQLSchemaPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { GraphQLSchemaDefinition, Resolvers, Types } from \"~/types\";\nimport { Context } from \"@webiny/api/types\";\n\nexport interface GraphQLSchemaPluginConfig<TContext> {\n typeDefs?: Types;\n resolvers?: Resolvers<TContext>;\n}\n\nexport class GraphQLSchemaPlugin<TContext = Context> extends Plugin {\n public static override readonly type: string = \"graphql-schema\";\n private config: GraphQLSchemaPluginConfig<TContext>;\n\n constructor(config: GraphQLSchemaPluginConfig<TContext>) {\n super();\n this.config = config;\n }\n\n get schema(): GraphQLSchemaDefinition<TContext> {\n return {\n typeDefs: this.config.typeDefs || \"\",\n resolvers: this.config.resolvers\n };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,mBAAmB,SAA6BC,eAAM,CAAC;EAChE,OAAgCC,IAAI,GAAW,gBAAgB;EAG/DC,WAAWA,CAACC,MAA2C,EAAE;IACrD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,IAAIC,MAAMA,CAAA,EAAsC;IAC5C,OAAO;MACHC,QAAQ,EAAE,IAAI,CAACF,MAAM,CAACE,QAAQ,IAAI,EAAE;MACpCC,SAAS,EAAE,IAAI,CAACH,MAAM,CAACG;IAC3B,CAAC;EACL;AACJ;AAACC,OAAA,CAAAR,mBAAA,GAAAA,mBAAA"}
|
package/plugins/index.js
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _GraphQLSchemaPlugin = require("./GraphQLSchemaPlugin");
|
|
8
|
-
|
|
9
7
|
Object.keys(_GraphQLSchemaPlugin).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _GraphQLSchemaPlugin[key]) return;
|
|
@@ -15,4 +13,6 @@ Object.keys(_GraphQLSchemaPlugin).forEach(function (key) {
|
|
|
15
13
|
return _GraphQLSchemaPlugin[key];
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
|
-
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/plugins/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./GraphQLSchemaPlugin\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_GraphQLSchemaPlugin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./GraphQLSchemaPlugin\";\n"],"mappings":";;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,oBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,oBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,oBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
|
package/processRequestBody.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _graphql = require("graphql");
|
|
9
|
-
|
|
10
8
|
const processRequestBody = async (body, schema, context) => {
|
|
11
9
|
const {
|
|
12
10
|
query,
|
|
@@ -29,19 +27,17 @@ const processRequestBody = async (body, schema, context) => {
|
|
|
29
27
|
});
|
|
30
28
|
return result;
|
|
31
29
|
};
|
|
32
|
-
|
|
33
30
|
var _default = async (requestBody, schema, context) => {
|
|
34
|
-
if (Array.isArray(requestBody)
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
if (Array.isArray(requestBody)) {
|
|
32
|
+
const results = [];
|
|
33
|
+
for (const body of requestBody) {
|
|
34
|
+
const result = await processRequestBody(body, schema, context);
|
|
35
|
+
results.push(result);
|
|
39
36
|
}
|
|
40
|
-
|
|
41
|
-
return result;
|
|
37
|
+
return results;
|
|
42
38
|
}
|
|
43
|
-
|
|
44
39
|
return await processRequestBody(requestBody, schema, context);
|
|
45
40
|
};
|
|
41
|
+
exports.default = _default;
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
//# sourceMappingURL=processRequestBody.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["processRequestBody","body","schema","context","query","variables","operationName","plugins","byType","forEach","pl","apply","result","graphql","requestBody","Array","isArray","
|
|
1
|
+
{"version":3,"names":["_graphql","require","processRequestBody","body","schema","context","query","variables","operationName","plugins","byType","forEach","pl","apply","result","graphql","_default","requestBody","Array","isArray","results","push","exports","default"],"sources":["processRequestBody.ts"],"sourcesContent":["import { ExecutionResult, graphql, GraphQLSchema } from \"graphql\";\nimport { GraphQLAfterQueryPlugin, GraphQLBeforeQueryPlugin, GraphQLRequestBody } from \"~/types\";\nimport { Context } from \"@webiny/api/types\";\n\nconst processRequestBody = async (\n body: GraphQLRequestBody,\n schema: GraphQLSchema,\n context: Context\n) => {\n const { query, variables, operationName } = body;\n\n context.plugins\n .byType<GraphQLBeforeQueryPlugin>(\"graphql-before-query\")\n .forEach(pl => pl.apply({ body, schema, context }));\n\n const result = await graphql(schema, query, {}, context, variables, operationName);\n\n context.plugins.byType<GraphQLAfterQueryPlugin>(\"graphql-after-query\").forEach(pl => {\n pl.apply({ result, body, schema, context });\n });\n\n return result;\n};\n\nexport default async (\n requestBody: GraphQLRequestBody | GraphQLRequestBody[],\n schema: GraphQLSchema,\n context: Context\n): Promise<ExecutionResult[] | ExecutionResult> => {\n if (Array.isArray(requestBody)) {\n const results: ExecutionResult[] = [];\n for (const body of requestBody) {\n const result = await processRequestBody(body, schema, context);\n results.push(result);\n }\n return results;\n }\n return await processRequestBody(requestBody, schema, context);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAIA,MAAMC,kBAAkB,GAAG,MAAAA,CACvBC,IAAwB,EACxBC,MAAqB,EACrBC,OAAgB,KACf;EACD,MAAM;IAAEC,KAAK;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGL,IAAI;EAEhDE,OAAO,CAACI,OAAO,CACVC,MAAM,CAA2B,sBAAsB,CAAC,CACxDC,OAAO,CAACC,EAAE,IAAIA,EAAE,CAACC,KAAK,CAAC;IAAEV,IAAI;IAAEC,MAAM;IAAEC;EAAQ,CAAC,CAAC,CAAC;EAEvD,MAAMS,MAAM,GAAG,MAAM,IAAAC,gBAAO,EAACX,MAAM,EAAEE,KAAK,EAAE,CAAC,CAAC,EAAED,OAAO,EAAEE,SAAS,EAAEC,aAAa,CAAC;EAElFH,OAAO,CAACI,OAAO,CAACC,MAAM,CAA0B,qBAAqB,CAAC,CAACC,OAAO,CAACC,EAAE,IAAI;IACjFA,EAAE,CAACC,KAAK,CAAC;MAAEC,MAAM;MAAEX,IAAI;MAAEC,MAAM;MAAEC;IAAQ,CAAC,CAAC;EAC/C,CAAC,CAAC;EAEF,OAAOS,MAAM;AACjB,CAAC;AAAC,IAAAE,QAAA,GAEa,MAAAA,CACXC,WAAsD,EACtDb,MAAqB,EACrBC,OAAgB,KAC+B;EAC/C,IAAIa,KAAK,CAACC,OAAO,CAACF,WAAW,CAAC,EAAE;IAC5B,MAAMG,OAA0B,GAAG,EAAE;IACrC,KAAK,MAAMjB,IAAI,IAAIc,WAAW,EAAE;MAC5B,MAAMH,MAAM,GAAG,MAAMZ,kBAAkB,CAACC,IAAI,EAAEC,MAAM,EAAEC,OAAO,CAAC;MAC9De,OAAO,CAACC,IAAI,CAACP,MAAM,CAAC;IACxB;IACA,OAAOM,OAAO;EAClB;EACA,OAAO,MAAMlB,kBAAkB,CAACe,WAAW,EAAEb,MAAM,EAAEC,OAAO,CAAC;AACjE,CAAC;AAAAiB,OAAA,CAAAC,OAAA,GAAAP,QAAA"}
|
package/responses.js
CHANGED
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.Response = exports.NotFoundResponse = exports.ListResponse = exports.ListErrorResponse = exports.ErrorResponse = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
7
|
const defaultParams = {
|
|
13
8
|
code: "",
|
|
14
9
|
message: "",
|
|
15
10
|
data: null,
|
|
16
11
|
stack: null
|
|
17
12
|
};
|
|
18
|
-
|
|
19
13
|
class ErrorResponse {
|
|
20
14
|
constructor(params) {
|
|
21
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
22
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
23
15
|
this.data = null;
|
|
24
|
-
const debug = process.env.DEBUG === "true";
|
|
16
|
+
const debug = process.env.DEBUG === "true";
|
|
25
17
|
|
|
18
|
+
// Ensure `stack` is either `string` or `null`.
|
|
26
19
|
let stack = defaultParams.stack;
|
|
27
|
-
|
|
28
20
|
if (debug && params.stack) {
|
|
29
21
|
stack = params.stack;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
this.error = {
|
|
33
24
|
code: params.code || defaultParams.code,
|
|
34
25
|
message: params.message || defaultParams.message,
|
|
@@ -36,11 +27,8 @@ class ErrorResponse {
|
|
|
36
27
|
stack: stack
|
|
37
28
|
};
|
|
38
29
|
}
|
|
39
|
-
|
|
40
30
|
}
|
|
41
|
-
|
|
42
31
|
exports.ErrorResponse = ErrorResponse;
|
|
43
|
-
|
|
44
32
|
class NotFoundResponse extends ErrorResponse {
|
|
45
33
|
constructor(message) {
|
|
46
34
|
super({
|
|
@@ -48,26 +36,19 @@ class NotFoundResponse extends ErrorResponse {
|
|
|
48
36
|
message
|
|
49
37
|
});
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
}
|
|
53
|
-
|
|
54
40
|
exports.NotFoundResponse = NotFoundResponse;
|
|
55
|
-
|
|
56
41
|
class ListErrorResponse {
|
|
57
42
|
constructor(params) {
|
|
58
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
59
|
-
(0, _defineProperty2.default)(this, "meta", void 0);
|
|
60
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
61
43
|
this.meta = null;
|
|
62
44
|
this.data = null;
|
|
63
|
-
const debug = process.env.DEBUG === "true";
|
|
45
|
+
const debug = process.env.DEBUG === "true";
|
|
64
46
|
|
|
47
|
+
// Ensure `stack` is either `string` or `null`.
|
|
65
48
|
let stack = defaultParams.stack;
|
|
66
|
-
|
|
67
49
|
if (debug && params.stack) {
|
|
68
50
|
stack = params.stack;
|
|
69
51
|
}
|
|
70
|
-
|
|
71
52
|
this.error = {
|
|
72
53
|
code: params.code || defaultParams.code,
|
|
73
54
|
message: params.message || defaultParams.message,
|
|
@@ -75,33 +56,22 @@ class ListErrorResponse {
|
|
|
75
56
|
stack: stack
|
|
76
57
|
};
|
|
77
58
|
}
|
|
78
|
-
|
|
79
59
|
}
|
|
80
|
-
|
|
81
60
|
exports.ListErrorResponse = ListErrorResponse;
|
|
82
|
-
|
|
83
61
|
class Response {
|
|
84
62
|
constructor(data) {
|
|
85
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
86
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
87
63
|
this.data = data;
|
|
88
64
|
this.error = null;
|
|
89
65
|
}
|
|
90
|
-
|
|
91
66
|
}
|
|
92
|
-
|
|
93
67
|
exports.Response = Response;
|
|
94
|
-
|
|
95
68
|
class ListResponse {
|
|
96
69
|
constructor(data, meta) {
|
|
97
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
98
|
-
(0, _defineProperty2.default)(this, "meta", void 0);
|
|
99
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
100
70
|
this.data = Array.isArray(data) ? data : [];
|
|
101
71
|
this.meta = meta || {};
|
|
102
72
|
this.error = null;
|
|
103
73
|
}
|
|
104
|
-
|
|
105
74
|
}
|
|
75
|
+
exports.ListResponse = ListResponse;
|
|
106
76
|
|
|
107
|
-
|
|
77
|
+
//# sourceMappingURL=responses.js.map
|
package/responses.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defaultParams","code","message","data","stack","ErrorResponse","constructor","params","debug","process","env","DEBUG","error","NotFoundResponse","ListErrorResponse","meta","Response","ListResponse","Array","isArray"],"sources":["responses.ts"],"sourcesContent":["export interface ErrorResponseParams {\n message: string;\n code?: string;\n data?: any;\n stack?: string | null;\n}\n\nconst defaultParams: Required<ErrorResponseParams> = {\n code: \"\",\n message: \"\",\n data: null,\n stack: null\n};\n\nexport class ErrorResponse {\n public readonly data: null;\n public readonly error: {\n code: string;\n message: string;\n data: any;\n stack: string | null;\n };\n\n constructor(params: ErrorResponseParams) {\n this.data = null;\n\n const debug = process.env.DEBUG === \"true\";\n\n // Ensure `stack` is either `string` or `null`.\n let stack = defaultParams.stack;\n if (debug && params.stack) {\n stack = params.stack;\n }\n\n this.error = {\n code: params.code || defaultParams.code,\n message: params.message || defaultParams.message,\n data: params.data || defaultParams.data,\n stack: stack\n };\n }\n}\n\nexport class NotFoundResponse extends ErrorResponse {\n constructor(message: string) {\n super({\n code: \"NOT_FOUND\",\n message\n });\n }\n}\n\nexport class ListErrorResponse {\n public readonly data: null;\n public readonly meta: null;\n public readonly error: {\n code: string;\n message: string;\n data: any;\n stack: string | null;\n };\n\n constructor(params: ErrorResponseParams) {\n this.meta = null;\n this.data = null;\n\n const debug = process.env.DEBUG === \"true\";\n\n // Ensure `stack` is either `string` or `null`.\n let stack = defaultParams.stack;\n if (debug && params.stack) {\n stack = params.stack;\n }\n\n this.error = {\n code: params.code || defaultParams.code,\n message: params.message || defaultParams.message,\n data: params.data || defaultParams.data,\n stack: stack\n };\n }\n}\n\nexport class Response<T = any> {\n public readonly data: T;\n public readonly error: null;\n\n constructor(data: T) {\n this.data = data;\n this.error = null;\n }\n}\n\nexport class ListResponse<T, M> {\n public readonly data: Array<T>;\n public readonly meta: M;\n public readonly error: null;\n\n constructor(data: Array<T>, meta?: M) {\n this.data = Array.isArray(data) ? data : [];\n this.meta = meta || ({} as M);\n this.error = null;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["defaultParams","code","message","data","stack","ErrorResponse","constructor","params","debug","process","env","DEBUG","error","exports","NotFoundResponse","ListErrorResponse","meta","Response","ListResponse","Array","isArray"],"sources":["responses.ts"],"sourcesContent":["export interface ErrorResponseParams {\n message: string;\n code?: string;\n data?: any;\n stack?: string | null;\n}\n\nconst defaultParams: Required<ErrorResponseParams> = {\n code: \"\",\n message: \"\",\n data: null,\n stack: null\n};\n\nexport class ErrorResponse {\n public readonly data: null;\n public readonly error: {\n code: string;\n message: string;\n data: any;\n stack: string | null;\n };\n\n constructor(params: ErrorResponseParams) {\n this.data = null;\n\n const debug = process.env.DEBUG === \"true\";\n\n // Ensure `stack` is either `string` or `null`.\n let stack = defaultParams.stack;\n if (debug && params.stack) {\n stack = params.stack;\n }\n\n this.error = {\n code: params.code || defaultParams.code,\n message: params.message || defaultParams.message,\n data: params.data || defaultParams.data,\n stack: stack\n };\n }\n}\n\nexport class NotFoundResponse extends ErrorResponse {\n constructor(message: string) {\n super({\n code: \"NOT_FOUND\",\n message\n });\n }\n}\n\nexport class ListErrorResponse {\n public readonly data: null;\n public readonly meta: null;\n public readonly error: {\n code: string;\n message: string;\n data: any;\n stack: string | null;\n };\n\n constructor(params: ErrorResponseParams) {\n this.meta = null;\n this.data = null;\n\n const debug = process.env.DEBUG === \"true\";\n\n // Ensure `stack` is either `string` or `null`.\n let stack = defaultParams.stack;\n if (debug && params.stack) {\n stack = params.stack;\n }\n\n this.error = {\n code: params.code || defaultParams.code,\n message: params.message || defaultParams.message,\n data: params.data || defaultParams.data,\n stack: stack\n };\n }\n}\n\nexport class Response<T = any> {\n public readonly data: T;\n public readonly error: null;\n\n constructor(data: T) {\n this.data = data;\n this.error = null;\n }\n}\n\nexport class ListResponse<T, M> {\n public readonly data: Array<T>;\n public readonly meta: M;\n public readonly error: null;\n\n constructor(data: Array<T>, meta?: M) {\n this.data = Array.isArray(data) ? data : [];\n this.meta = meta || ({} as M);\n this.error = null;\n }\n}\n"],"mappings":";;;;;;AAOA,MAAMA,aAA4C,GAAG;EACjDC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,EAAE;EACXC,IAAI,EAAE,IAAI;EACVC,KAAK,EAAE;AACX,CAAC;AAEM,MAAMC,aAAa,CAAC;EASvBC,WAAWA,CAACC,MAA2B,EAAE;IACrC,IAAI,CAACJ,IAAI,GAAG,IAAI;IAEhB,MAAMK,KAAK,GAAGC,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK,MAAM;;IAE1C;IACA,IAAIP,KAAK,GAAGJ,aAAa,CAACI,KAAK;IAC/B,IAAII,KAAK,IAAID,MAAM,CAACH,KAAK,EAAE;MACvBA,KAAK,GAAGG,MAAM,CAACH,KAAK;IACxB;IAEA,IAAI,CAACQ,KAAK,GAAG;MACTX,IAAI,EAAEM,MAAM,CAACN,IAAI,IAAID,aAAa,CAACC,IAAI;MACvCC,OAAO,EAAEK,MAAM,CAACL,OAAO,IAAIF,aAAa,CAACE,OAAO;MAChDC,IAAI,EAAEI,MAAM,CAACJ,IAAI,IAAIH,aAAa,CAACG,IAAI;MACvCC,KAAK,EAAEA;IACX,CAAC;EACL;AACJ;AAACS,OAAA,CAAAR,aAAA,GAAAA,aAAA;AAEM,MAAMS,gBAAgB,SAAST,aAAa,CAAC;EAChDC,WAAWA,CAACJ,OAAe,EAAE;IACzB,KAAK,CAAC;MACFD,IAAI,EAAE,WAAW;MACjBC;IACJ,CAAC,CAAC;EACN;AACJ;AAACW,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAEM,MAAMC,iBAAiB,CAAC;EAU3BT,WAAWA,CAACC,MAA2B,EAAE;IACrC,IAAI,CAACS,IAAI,GAAG,IAAI;IAChB,IAAI,CAACb,IAAI,GAAG,IAAI;IAEhB,MAAMK,KAAK,GAAGC,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK,MAAM;;IAE1C;IACA,IAAIP,KAAK,GAAGJ,aAAa,CAACI,KAAK;IAC/B,IAAII,KAAK,IAAID,MAAM,CAACH,KAAK,EAAE;MACvBA,KAAK,GAAGG,MAAM,CAACH,KAAK;IACxB;IAEA,IAAI,CAACQ,KAAK,GAAG;MACTX,IAAI,EAAEM,MAAM,CAACN,IAAI,IAAID,aAAa,CAACC,IAAI;MACvCC,OAAO,EAAEK,MAAM,CAACL,OAAO,IAAIF,aAAa,CAACE,OAAO;MAChDC,IAAI,EAAEI,MAAM,CAACJ,IAAI,IAAIH,aAAa,CAACG,IAAI;MACvCC,KAAK,EAAEA;IACX,CAAC;EACL;AACJ;AAACS,OAAA,CAAAE,iBAAA,GAAAA,iBAAA;AAEM,MAAME,QAAQ,CAAU;EAI3BX,WAAWA,CAACH,IAAO,EAAE;IACjB,IAAI,CAACA,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACS,KAAK,GAAG,IAAI;EACrB;AACJ;AAACC,OAAA,CAAAI,QAAA,GAAAA,QAAA;AAEM,MAAMC,YAAY,CAAO;EAK5BZ,WAAWA,CAACH,IAAc,EAAEa,IAAQ,EAAE;IAClC,IAAI,CAACb,IAAI,GAAGgB,KAAK,CAACC,OAAO,CAACjB,IAAI,CAAC,GAAGA,IAAI,GAAG,EAAE;IAC3C,IAAI,CAACa,IAAI,GAAGA,IAAI,IAAK,CAAC,CAAO;IAC7B,IAAI,CAACJ,KAAK,GAAG,IAAI;EACrB;AACJ;AAACC,OAAA,CAAAK,YAAA,GAAAA,YAAA"}
|
package/types.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface HandlerGraphQLOptions {
|
|
|
11
11
|
debug?: boolean | string;
|
|
12
12
|
}
|
|
13
13
|
export declare type GraphQLFieldResolver<TSource = any, TArgs = any, TContext = Context> = BaseGraphQLFieldResolver<TSource, TContext, TArgs>;
|
|
14
|
-
export declare type Types = string | (() => string | Promise<string>);
|
|
14
|
+
export declare type Types = string | string[] | (() => string | string[] | Promise<string | string[]>);
|
|
15
15
|
export interface GraphQLSchemaPluginTypeArgs {
|
|
16
16
|
context?: any;
|
|
17
17
|
args?: any;
|
package/types.js
CHANGED
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import {\n GraphQLScalarType,\n GraphQLFieldResolver as BaseGraphQLFieldResolver,\n GraphQLSchema\n} from \"graphql\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { Context } from \"@webiny/api/types\";\nimport { RouteMethodPath } from \"@webiny/handler/types\";\n\nexport interface GraphQLScalarPlugin extends Plugin {\n type: \"graphql-scalar\";\n scalar: GraphQLScalarType;\n}\n\nexport interface HandlerGraphQLOptions {\n path?: RouteMethodPath;\n debug?: boolean | string;\n}\n\nexport type GraphQLFieldResolver<\n TSource = any,\n TArgs = any,\n TContext = Context\n> = BaseGraphQLFieldResolver<TSource, TContext, TArgs>;\n\n// `GraphQLSchemaPlugin` types.\nexport type Types = string | (() => string | Promise<string>);\n\nexport interface GraphQLSchemaPluginTypeArgs {\n context?: any;\n args?: any;\n source?: any;\n}\n\nexport type Resolvers<TContext> =\n | GraphQLScalarType\n | GraphQLFieldResolver<any, Record<string, any>, TContext>\n | { [property: string]: Resolvers<TContext> };\n\nexport interface GraphQLSchemaDefinition<TContext> {\n typeDefs: Types;\n resolvers?: Resolvers<TContext>;\n}\n\nexport interface GraphQLSchemaPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-schema\";\n schema: GraphQLSchemaDefinition<TContext>;\n}\n\nexport interface GraphQLRequestBody {\n query: string;\n variables: Record<string, any>;\n operationName: string;\n}\n\nexport interface GraphQLBeforeQueryPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-before-query\";\n apply(params: { body: GraphQLRequestBody; schema: GraphQLSchema; context: TContext }): void;\n}\n\nexport interface GraphQLAfterQueryPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-after-query\";\n apply(params: {\n result: any;\n body: GraphQLRequestBody;\n schema: GraphQLSchema;\n context: TContext;\n }): void;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import {\n GraphQLScalarType,\n GraphQLFieldResolver as BaseGraphQLFieldResolver,\n GraphQLSchema\n} from \"graphql\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { Context } from \"@webiny/api/types\";\nimport { RouteMethodPath } from \"@webiny/handler/types\";\n\nexport interface GraphQLScalarPlugin extends Plugin {\n type: \"graphql-scalar\";\n scalar: GraphQLScalarType;\n}\n\nexport interface HandlerGraphQLOptions {\n path?: RouteMethodPath;\n debug?: boolean | string;\n}\n\nexport type GraphQLFieldResolver<\n TSource = any,\n TArgs = any,\n TContext = Context\n> = BaseGraphQLFieldResolver<TSource, TContext, TArgs>;\n\n// `GraphQLSchemaPlugin` types.\nexport type Types = string | string[] | (() => string | string[] | Promise<string | string[]>);\n\nexport interface GraphQLSchemaPluginTypeArgs {\n context?: any;\n args?: any;\n source?: any;\n}\n\nexport type Resolvers<TContext> =\n | GraphQLScalarType\n | GraphQLFieldResolver<any, Record<string, any>, TContext>\n | { [property: string]: Resolvers<TContext> };\n\nexport interface GraphQLSchemaDefinition<TContext> {\n typeDefs: Types;\n resolvers?: Resolvers<TContext>;\n}\n\nexport interface GraphQLSchemaPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-schema\";\n schema: GraphQLSchemaDefinition<TContext>;\n}\n\nexport interface GraphQLRequestBody {\n query: string;\n variables: Record<string, any>;\n operationName: string;\n}\n\nexport interface GraphQLBeforeQueryPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-before-query\";\n apply(params: { body: GraphQLRequestBody; schema: GraphQLSchema; context: TContext }): void;\n}\n\nexport interface GraphQLAfterQueryPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-after-query\";\n apply(params: {\n result: any;\n body: GraphQLRequestBody;\n schema: GraphQLSchema;\n context: TContext;\n }): void;\n}\n"],"mappings":""}
|