@webiny/handler-graphql 0.0.0-unstable.aad28a72ae → 0.0.0-unstable.acacc54f0e
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.js +0 -3
- package/builtInTypes/AnyScalar.js.map +1 -1
- package/builtInTypes/DateScalar.js +0 -7
- package/builtInTypes/DateScalar.js.map +1 -1
- package/builtInTypes/DateTimeScalar.js +0 -7
- package/builtInTypes/DateTimeScalar.js.map +1 -1
- package/builtInTypes/DateTimeZScalar.js +0 -13
- package/builtInTypes/DateTimeZScalar.js.map +1 -1
- package/builtInTypes/JsonScalar.js +0 -2
- package/builtInTypes/JsonScalar.js.map +1 -1
- package/builtInTypes/LongScalar.d.ts +2 -1
- package/builtInTypes/LongScalar.js +49 -4
- package/builtInTypes/LongScalar.js.map +1 -1
- package/builtInTypes/NumberScalar.js +0 -9
- package/builtInTypes/NumberScalar.js.map +1 -1
- package/builtInTypes/RefInputScalar.d.ts +1 -1
- package/builtInTypes/RefInputScalar.js +3 -14
- package/builtInTypes/RefInputScalar.js.map +1 -1
- package/builtInTypes/TimeScalar.js +0 -12
- package/builtInTypes/TimeScalar.js.map +1 -1
- package/builtInTypes/index.js +0 -18
- package/builtInTypes/index.js.map +1 -1
- package/createGraphQLHandler.js +37 -26
- package/createGraphQLHandler.js.map +1 -1
- package/createGraphQLSchema.d.ts +2 -0
- package/createGraphQLSchema.js +18 -17
- package/createGraphQLSchema.js.map +1 -1
- package/debugPlugins.js +0 -9
- package/debugPlugins.js.map +1 -1
- package/errors.js +0 -5
- package/errors.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +10 -11
- package/index.js.map +1 -1
- package/interceptConsole.js +4 -10
- package/interceptConsole.js.map +1 -1
- package/package.json +17 -16
- package/plugins/GraphQLSchemaPlugin.js +0 -7
- package/plugins/GraphQLSchemaPlugin.js.map +1 -1
- package/plugins/index.js +0 -2
- package/plugins/index.js.map +1 -1
- package/processRequestBody.js +6 -12
- package/processRequestBody.js.map +1 -1
- package/responses.js +4 -24
- package/responses.js.map +1 -1
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,15 @@ 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
|
};
|
|
46
|
-
|
|
47
41
|
exports.default = _default;
|
|
@@ -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,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.Response = exports.NotFoundResponse = exports.ListResponse = exports.ListErrorResponse = exports.ErrorResponse = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
const defaultParams = {
|
|
13
10
|
code: "",
|
|
14
11
|
message: "",
|
|
15
12
|
data: null,
|
|
16
13
|
stack: null
|
|
17
14
|
};
|
|
18
|
-
|
|
19
15
|
class ErrorResponse {
|
|
20
16
|
constructor(params) {
|
|
21
17
|
(0, _defineProperty2.default)(this, "data", void 0);
|
|
22
18
|
(0, _defineProperty2.default)(this, "error", void 0);
|
|
23
19
|
this.data = null;
|
|
24
|
-
const debug = process.env.DEBUG === "true";
|
|
20
|
+
const debug = process.env.DEBUG === "true";
|
|
25
21
|
|
|
22
|
+
// Ensure `stack` is either `string` or `null`.
|
|
26
23
|
let stack = defaultParams.stack;
|
|
27
|
-
|
|
28
24
|
if (debug && params.stack) {
|
|
29
25
|
stack = params.stack;
|
|
30
26
|
}
|
|
31
|
-
|
|
32
27
|
this.error = {
|
|
33
28
|
code: params.code || defaultParams.code,
|
|
34
29
|
message: params.message || defaultParams.message,
|
|
@@ -36,11 +31,8 @@ class ErrorResponse {
|
|
|
36
31
|
stack: stack
|
|
37
32
|
};
|
|
38
33
|
}
|
|
39
|
-
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
exports.ErrorResponse = ErrorResponse;
|
|
43
|
-
|
|
44
36
|
class NotFoundResponse extends ErrorResponse {
|
|
45
37
|
constructor(message) {
|
|
46
38
|
super({
|
|
@@ -48,11 +40,8 @@ class NotFoundResponse extends ErrorResponse {
|
|
|
48
40
|
message
|
|
49
41
|
});
|
|
50
42
|
}
|
|
51
|
-
|
|
52
43
|
}
|
|
53
|
-
|
|
54
44
|
exports.NotFoundResponse = NotFoundResponse;
|
|
55
|
-
|
|
56
45
|
class ListErrorResponse {
|
|
57
46
|
constructor(params) {
|
|
58
47
|
(0, _defineProperty2.default)(this, "data", void 0);
|
|
@@ -60,14 +49,13 @@ class ListErrorResponse {
|
|
|
60
49
|
(0, _defineProperty2.default)(this, "error", void 0);
|
|
61
50
|
this.meta = null;
|
|
62
51
|
this.data = null;
|
|
63
|
-
const debug = process.env.DEBUG === "true";
|
|
52
|
+
const debug = process.env.DEBUG === "true";
|
|
64
53
|
|
|
54
|
+
// Ensure `stack` is either `string` or `null`.
|
|
65
55
|
let stack = defaultParams.stack;
|
|
66
|
-
|
|
67
56
|
if (debug && params.stack) {
|
|
68
57
|
stack = params.stack;
|
|
69
58
|
}
|
|
70
|
-
|
|
71
59
|
this.error = {
|
|
72
60
|
code: params.code || defaultParams.code,
|
|
73
61
|
message: params.message || defaultParams.message,
|
|
@@ -75,11 +63,8 @@ class ListErrorResponse {
|
|
|
75
63
|
stack: stack
|
|
76
64
|
};
|
|
77
65
|
}
|
|
78
|
-
|
|
79
66
|
}
|
|
80
|
-
|
|
81
67
|
exports.ListErrorResponse = ListErrorResponse;
|
|
82
|
-
|
|
83
68
|
class Response {
|
|
84
69
|
constructor(data) {
|
|
85
70
|
(0, _defineProperty2.default)(this, "data", void 0);
|
|
@@ -87,11 +72,8 @@ class Response {
|
|
|
87
72
|
this.data = data;
|
|
88
73
|
this.error = null;
|
|
89
74
|
}
|
|
90
|
-
|
|
91
75
|
}
|
|
92
|
-
|
|
93
76
|
exports.Response = Response;
|
|
94
|
-
|
|
95
77
|
class ListResponse {
|
|
96
78
|
constructor(data, meta) {
|
|
97
79
|
(0, _defineProperty2.default)(this, "data", void 0);
|
|
@@ -101,7 +83,5 @@ class ListResponse {
|
|
|
101
83
|
this.meta = meta || {};
|
|
102
84
|
this.error = null;
|
|
103
85
|
}
|
|
104
|
-
|
|
105
86
|
}
|
|
106
|
-
|
|
107
87
|
exports.ListResponse = ListResponse;
|
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","_defineProperty2","default","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;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IACrC,IAAI,CAACN,IAAI,GAAG,IAAI;IAEhB,MAAMO,KAAK,GAAGC,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK,MAAM;;IAE1C;IACA,IAAIT,KAAK,GAAGJ,aAAa,CAACI,KAAK;IAC/B,IAAIM,KAAK,IAAIH,MAAM,CAACH,KAAK,EAAE;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