@webiny/handler-graphql 5.34.6 → 5.34.7-beta.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/createGraphQLHandler.js
CHANGED
|
@@ -75,8 +75,8 @@ var _default = (options = {}) => {
|
|
|
75
75
|
try {
|
|
76
76
|
body = createRequestBody(request.body);
|
|
77
77
|
} catch (ex) {
|
|
78
|
-
console.
|
|
79
|
-
console.
|
|
78
|
+
console.error(`Error while creating the body request.`);
|
|
79
|
+
console.error(formatErrorPayload(ex));
|
|
80
80
|
throw ex;
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -84,8 +84,8 @@ var _default = (options = {}) => {
|
|
|
84
84
|
const result = await (0, _processRequestBody.default)(body, schema, context);
|
|
85
85
|
return reply.status(200).send(result);
|
|
86
86
|
} catch (ex) {
|
|
87
|
-
console.
|
|
88
|
-
console.
|
|
87
|
+
console.error(`Error while processing the body request.`);
|
|
88
|
+
console.error(formatErrorPayload(ex));
|
|
89
89
|
throw ex;
|
|
90
90
|
}
|
|
91
91
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_CACHE_MAX_AGE","createRequestBody","body","JSON","parse","formatErrorPayload","error","WebinyError","stringify","type","message","code","data","name","stack","options","schema","undefined","debug","boolean","path","route","RoutePlugin","onPost","onOptions","context","_","reply","status","headers","send","hijack","request","createGraphQLSchema","ex","console","
|
|
1
|
+
{"version":3,"names":["DEFAULT_CACHE_MAX_AGE","createRequestBody","body","JSON","parse","formatErrorPayload","error","WebinyError","stringify","type","message","code","data","name","stack","options","schema","undefined","debug","boolean","path","route","RoutePlugin","onPost","onOptions","context","_","reply","status","headers","send","hijack","request","createGraphQLSchema","ex","console","result","processRequestBody","debugPlugins"],"sources":["createGraphQLHandler.ts"],"sourcesContent":["import { boolean } from \"boolean\";\nimport { GraphQLSchema } from \"graphql\";\nimport { RoutePlugin } from \"@webiny/handler\";\nimport WebinyError from \"@webiny/error\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\nimport { GraphQLRequestBody, HandlerGraphQLOptions } from \"./types\";\nimport { createGraphQLSchema } from \"./createGraphQLSchema\";\nimport debugPlugins from \"./debugPlugins\";\nimport processRequestBody from \"./processRequestBody\";\n\nconst DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year\n\nconst createRequestBody = (body: unknown): GraphQLRequestBody | GraphQLRequestBody[] => {\n /**\n * We are trusting that the body payload is correct.\n * The `processRequestBody` will fail if it is not.\n */\n return typeof body === \"string\" ? JSON.parse(body) : body;\n};\n\nconst formatErrorPayload = (error: Error): string => {\n if (error instanceof WebinyError) {\n return JSON.stringify({\n type: \"CoreGraphQLWebinyError\",\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return JSON.stringify({\n type: \"Error\",\n name: error.name,\n message: error.message,\n stack: error.stack\n });\n};\n\nexport default (options: HandlerGraphQLOptions = {}): PluginCollection => {\n let schema: GraphQLSchema | undefined = undefined;\n\n const debug = boolean(options.debug);\n\n const path = options?.path || \"/graphql\";\n\n const route = new RoutePlugin(async ({ onPost, onOptions, context }) => {\n onOptions(path, async (_, reply) => {\n return reply\n .status(204)\n .headers({\n \"Cache-Control\": `public, max-age=${DEFAULT_CACHE_MAX_AGE}`\n })\n .send({})\n .hijack();\n });\n onPost(path, async (request, reply) => {\n if (!schema) {\n try {\n schema = createGraphQLSchema(context);\n } catch (ex) {\n return reply.code(500).send(formatErrorPayload(ex));\n }\n }\n let body: GraphQLRequestBody | GraphQLRequestBody[];\n try {\n body = createRequestBody(request.body);\n } catch (ex) {\n console.error(`Error while creating the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n try {\n const result = await processRequestBody(body, schema, context);\n return reply.status(200).send(result);\n } catch (ex) {\n console.error(`Error while processing the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n });\n });\n\n route.name = \"handler.graphql.route.default\";\n\n return [\n ...(debug ? debugPlugins() : []),\n {\n type: \"wc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,EAA7B,CADG,EAEH;IACI7B,IAAI,EAAE;EADV,CAFG,EAKHY,KALG,CAAP;AAOH,C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/handler-graphql",
|
|
3
|
-
"version": "5.34.
|
|
3
|
+
"version": "5.34.7-beta.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "7.19.0",
|
|
18
18
|
"@graphql-tools/schema": "7.1.5",
|
|
19
|
-
"@webiny/api": "5.34.
|
|
20
|
-
"@webiny/error": "5.34.
|
|
21
|
-
"@webiny/handler": "5.34.
|
|
22
|
-
"@webiny/plugins": "5.34.
|
|
19
|
+
"@webiny/api": "5.34.7-beta.1",
|
|
20
|
+
"@webiny/error": "5.34.7-beta.1",
|
|
21
|
+
"@webiny/handler": "5.34.7-beta.1",
|
|
22
|
+
"@webiny/plugins": "5.34.7-beta.1",
|
|
23
23
|
"boolean": "3.2.0",
|
|
24
24
|
"graphql": "15.8.0",
|
|
25
25
|
"graphql-scalars": "1.12.0",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"@babel/cli": "^7.19.3",
|
|
30
30
|
"@babel/core": "^7.19.3",
|
|
31
31
|
"@babel/preset-env": "^7.19.4",
|
|
32
|
-
"@webiny/cli": "^5.34.
|
|
33
|
-
"@webiny/handler-aws": "^5.34.
|
|
34
|
-
"@webiny/project-utils": "^5.34.
|
|
32
|
+
"@webiny/cli": "^5.34.7-beta.1",
|
|
33
|
+
"@webiny/handler-aws": "^5.34.7-beta.1",
|
|
34
|
+
"@webiny/project-utils": "^5.34.7-beta.1",
|
|
35
35
|
"jest": "^28.1.0",
|
|
36
36
|
"jest-mock-console": "^1.0.0",
|
|
37
37
|
"rimraf": "^3.0.2",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"build": "yarn webiny run build",
|
|
47
47
|
"watch": "yarn webiny run watch"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "fd29a7876dcb76b7ac4fbc9fb2dd6cf00a011ad4"
|
|
50
50
|
}
|