@webiny/handler-graphql 0.0.0-unstable.1e66d121db → 0.0.0-unstable.611c5af35e
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 +3 -6
- 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.js +0 -2
- package/builtInTypes/LongScalar.js.map +1 -1
- package/builtInTypes/NumberScalar.d.ts +1 -1
- package/builtInTypes/NumberScalar.js +9 -14
- package/builtInTypes/NumberScalar.js.map +1 -1
- package/builtInTypes/RefInputScalar.js +0 -11
- 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 +0 -11
- package/createGraphQLHandler.js.map +1 -1
- package/createGraphQLSchema.js +4 -14
- 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.js +0 -10
- package/index.js.map +1 -1
- package/interceptConsole.js +4 -10
- package/interceptConsole.js.map +1 -1
- package/package.json +10 -10
- 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 +0 -7
- package/processRequestBody.js.map +1 -1
- package/responses.js +4 -24
- package/responses.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_CACHE_MAX_AGE","createRequestBody","body","JSON","parse","options","schema","undefined","debug","boolean","path","route","RoutePlugin","onPost","onOptions","context","_","reply","status","headers","send","request","createGraphQLSchema","result","processRequestBody","name","debugPlugins","type"],"sources":["createGraphQLHandler.ts"],"sourcesContent":["import { boolean } from \"boolean\";\nimport { HandlerGraphQLOptions } from \"./types\";\nimport { createGraphQLSchema } from \"./createGraphQLSchema\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\nimport debugPlugins from \"./debugPlugins\";\nimport processRequestBody from \"./processRequestBody\";\nimport { GraphQLSchema } from \"graphql\";\nimport { RoutePlugin } from \"@webiny/handler\";\n\nconst DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year\n\n/**\n * TODO Until we figure out how to better convert incoming body, we will leave it as any.\n */\nconst createRequestBody = (body: any): any => {\n return typeof body === \"string\" ? JSON.parse(body) : body;\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 });\n onPost(path, async (request, reply) => {\n if (!schema) {\n schema = createGraphQLSchema(context);\n }\n const body = createRequestBody(request.body);\n const result = await processRequestBody(body, schema, context);\n return reply.status(200).send(result);\n });\n });\n\n route.name = \"handler.graphql.route.default\";\n\n return [\n ...(debug ? debugPlugins() : []),\n {\n type: \"wcp-telemetry-tracker\"\n },\n route\n ];\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["DEFAULT_CACHE_MAX_AGE","createRequestBody","body","JSON","parse","options","schema","undefined","debug","boolean","path","route","RoutePlugin","onPost","onOptions","context","_","reply","status","headers","send","request","createGraphQLSchema","result","processRequestBody","name","debugPlugins","type"],"sources":["createGraphQLHandler.ts"],"sourcesContent":["import { boolean } from \"boolean\";\nimport { HandlerGraphQLOptions } from \"./types\";\nimport { createGraphQLSchema } from \"./createGraphQLSchema\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\nimport debugPlugins from \"./debugPlugins\";\nimport processRequestBody from \"./processRequestBody\";\nimport { GraphQLSchema } from \"graphql\";\nimport { RoutePlugin } from \"@webiny/handler\";\n\nconst DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year\n\n/**\n * TODO Until we figure out how to better convert incoming body, we will leave it as any.\n */\nconst createRequestBody = (body: any): any => {\n return typeof body === \"string\" ? JSON.parse(body) : body;\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 });\n onPost(path, async (request, reply) => {\n if (!schema) {\n schema = createGraphQLSchema(context);\n }\n const body = createRequestBody(request.body);\n const result = await processRequestBody(body, schema, context);\n return reply.status(200).send(result);\n });\n });\n\n route.name = \"handler.graphql.route.default\";\n\n return [\n ...(debug ? debugPlugins() : []),\n {\n type: \"wcp-telemetry-tracker\"\n },\n route\n ];\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AAEA;AACA;AAEA;AAEA,MAAMA,qBAAqB,GAAG,QAAQ,CAAC,CAAC;;AAExC;AACA;AACA;AACA,MAAMC,iBAAiB,GAAIC,IAAS,IAAU;EAC1C,OAAO,OAAOA,IAAI,KAAK,QAAQ,GAAGC,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC,GAAGA,IAAI;AAC7D,CAAC;AAAC,eAEa,CAACG,OAA8B,GAAG,CAAC,CAAC,KAAuB;EACtE,IAAIC,MAAiC,GAAGC,SAAS;EAEjD,MAAMC,KAAK,GAAG,IAAAC,gBAAO,EAACJ,OAAO,CAACG,KAAK,CAAC;EAEpC,MAAME,IAAI,GAAG,CAAAL,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEK,IAAI,KAAI,UAAU;EAExC,MAAMC,KAAK,GAAG,IAAIC,oBAAW,CAAC,OAAO;IAAEC,MAAM;IAAEC,SAAS;IAAEC;EAAQ,CAAC,KAAK;IACpED,SAAS,CAACJ,IAAI,EAAE,OAAOM,CAAC,EAAEC,KAAK,KAAK;MAChC,OAAOA,KAAK,CACPC,MAAM,CAAC,GAAG,CAAC,CACXC,OAAO,CAAC;QACL,eAAe,EAAG,mBAAkBnB,qBAAsB;MAC9D,CAAC,CAAC,CACDoB,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC,CAAC;IACFP,MAAM,CAACH,IAAI,EAAE,OAAOW,OAAO,EAAEJ,KAAK,KAAK;MACnC,IAAI,CAACX,MAAM,EAAE;QACTA,MAAM,GAAG,IAAAgB,wCAAmB,EAACP,OAAO,CAAC;MACzC;MACA,MAAMb,IAAI,GAAGD,iBAAiB,CAACoB,OAAO,CAACnB,IAAI,CAAC;MAC5C,MAAMqB,MAAM,GAAG,MAAM,IAAAC,2BAAkB,EAACtB,IAAI,EAAEI,MAAM,EAAES,OAAO,CAAC;MAC9D,OAAOE,KAAK,CAACC,MAAM,CAAC,GAAG,CAAC,CAACE,IAAI,CAACG,MAAM,CAAC;IACzC,CAAC,CAAC;EACN,CAAC,CAAC;EAEFZ,KAAK,CAACc,IAAI,GAAG,+BAA+B;EAE5C,OAAO,CACH,IAAIjB,KAAK,GAAG,IAAAkB,qBAAY,GAAE,GAAG,EAAE,CAAC,EAChC;IACIC,IAAI,EAAE;EACV,CAAC,EACDhB,KAAK,CACR;AACL,CAAC;AAAA"}
|
package/createGraphQLSchema.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
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.createGraphQLSchema = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
13
|
-
|
|
14
10
|
var _schema = require("@graphql-tools/schema");
|
|
15
|
-
|
|
16
11
|
var _builtInTypes = require("./builtInTypes");
|
|
17
|
-
|
|
18
12
|
const createGraphQLSchema = context => {
|
|
19
13
|
const scalars = context.plugins.byType("graphql-scalar").map(item => item.scalar);
|
|
20
14
|
const typeDefs = [(0, _graphqlTag.default)`
|
|
@@ -37,14 +31,13 @@ const createGraphQLSchema = context => {
|
|
|
37
31
|
JSON: _builtInTypes.JsonScalar,
|
|
38
32
|
Long: _builtInTypes.LongScalar,
|
|
39
33
|
RefInput: _builtInTypes.RefInput,
|
|
40
|
-
Number: _builtInTypes.
|
|
41
|
-
Any: _builtInTypes.
|
|
34
|
+
Number: _builtInTypes.NumberScalar,
|
|
35
|
+
Any: _builtInTypes.AnyScalar,
|
|
42
36
|
DateTime: _builtInTypes.DateTimeScalar,
|
|
43
37
|
Date: _builtInTypes.DateScalar,
|
|
44
38
|
Time: _builtInTypes.TimeScalar
|
|
45
39
|
})];
|
|
46
40
|
const gqlPlugins = context.plugins.byType("graphql-schema");
|
|
47
|
-
|
|
48
41
|
for (let i = 0; i < gqlPlugins.length; i++) {
|
|
49
42
|
const plugin = gqlPlugins[i];
|
|
50
43
|
/**
|
|
@@ -52,17 +45,14 @@ const createGraphQLSchema = context => {
|
|
|
52
45
|
* Figure out correct types on typeDefs and resolvers
|
|
53
46
|
*/
|
|
54
47
|
// @ts-ignore
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
typeDefs.push(plugin.schema.typeDefs);
|
|
49
|
+
// @ts-ignore
|
|
58
50
|
resolvers.push(plugin.schema.resolvers);
|
|
59
51
|
}
|
|
60
|
-
|
|
61
52
|
return (0, _schema.makeExecutableSchema)({
|
|
62
53
|
typeDefs,
|
|
63
54
|
resolvers,
|
|
64
55
|
inheritResolversFromInterfaces: true
|
|
65
56
|
});
|
|
66
57
|
};
|
|
67
|
-
|
|
68
58
|
exports.createGraphQLSchema = createGraphQLSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createGraphQLSchema","context","scalars","plugins","byType","map","item","scalar","typeDefs","gql","name","join","resolvers","reduce","acc","s","JSON","JsonScalar","Long","LongScalar","RefInput","Number","NumberScalar","Any","AnyScalar","DateTime","DateTimeScalar","Date","DateScalar","Time","TimeScalar","gqlPlugins","i","length","plugin","push","schema","makeExecutableSchema","inheritResolversFromInterfaces"],"sources":["createGraphQLSchema.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport { makeExecutableSchema } from \"@graphql-tools/schema\";\nimport { GraphQLScalarPlugin, GraphQLSchemaPlugin } from \"./types\";\nimport { Context } from \"@webiny/api/types\";\nimport {\n RefInput,\n
|
|
1
|
+
{"version":3,"names":["createGraphQLSchema","context","scalars","plugins","byType","map","item","scalar","typeDefs","gql","name","join","resolvers","reduce","acc","s","JSON","JsonScalar","Long","LongScalar","RefInput","Number","NumberScalar","Any","AnyScalar","DateTime","DateTimeScalar","Date","DateScalar","Time","TimeScalar","gqlPlugins","i","length","plugin","push","schema","makeExecutableSchema","inheritResolversFromInterfaces"],"sources":["createGraphQLSchema.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport { makeExecutableSchema } from \"@graphql-tools/schema\";\nimport { GraphQLScalarPlugin, GraphQLSchemaPlugin } from \"./types\";\nimport { Context } from \"@webiny/api/types\";\nimport {\n RefInput,\n NumberScalar,\n AnyScalar,\n DateScalar,\n DateTimeScalar,\n JsonScalar,\n TimeScalar,\n LongScalar\n} from \"./builtInTypes\";\nimport { GraphQLScalarType } from \"graphql/type/definition\";\n\nexport const createGraphQLSchema = (context: Context) => {\n const scalars = context.plugins\n .byType<GraphQLScalarPlugin>(\"graphql-scalar\")\n .map(item => item.scalar);\n\n const typeDefs = [\n gql`\n type Query\n type Mutation\n ${scalars.map(scalar => `scalar ${scalar.name}`).join(\" \")}\n scalar JSON\n scalar Long\n scalar RefInput\n scalar Number\n scalar Any\n scalar Date\n scalar DateTime\n scalar Time\n `\n ];\n\n const resolvers = [\n {\n ...scalars.reduce((acc, s) => {\n acc[s.name] = s;\n return acc;\n }, {} as Record<string, GraphQLScalarType>),\n JSON: JsonScalar,\n Long: LongScalar,\n RefInput,\n Number: NumberScalar,\n Any: AnyScalar,\n DateTime: DateTimeScalar,\n Date: DateScalar,\n Time: TimeScalar\n }\n ];\n\n const gqlPlugins = context.plugins.byType<GraphQLSchemaPlugin>(\"graphql-schema\");\n for (let i = 0; i < gqlPlugins.length; i++) {\n const plugin = gqlPlugins[i];\n /**\n * TODO @ts-refactor\n * Figure out correct types on typeDefs and resolvers\n */\n // @ts-ignore\n typeDefs.push(plugin.schema.typeDefs);\n // @ts-ignore\n resolvers.push(plugin.schema.resolvers);\n }\n\n return makeExecutableSchema({\n typeDefs,\n resolvers,\n inheritResolversFromInterfaces: true\n });\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AAGA;AAYO,MAAMA,mBAAmB,GAAIC,OAAgB,IAAK;EACrD,MAAMC,OAAO,GAAGD,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAAsB,gBAAgB,CAAC,CAC7CC,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,MAAM,CAAC;EAE7B,MAAMC,QAAQ,GAAG,CACb,IAAAC,mBAAG,CAAC;AACZ;AACA;AACA,cAAcP,OAAO,CAACG,GAAG,CAACE,MAAM,IAAK,UAASA,MAAM,CAACG,IAAK,EAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CACJ;EAED,MAAMC,SAAS,GAAG,6DAEPV,OAAO,CAACW,MAAM,CAAC,CAACC,GAAG,EAAEC,CAAC,KAAK;IAC1BD,GAAG,CAACC,CAAC,CAACL,IAAI,CAAC,GAAGK,CAAC;IACf,OAAOD,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAAsC;IAC3CE,IAAI,EAAEC,wBAAU;IAChBC,IAAI,EAAEC,wBAAU;IAChBC,QAAQ,EAARA,sBAAQ;IACRC,MAAM,EAAEC,0BAAY;IACpBC,GAAG,EAAEC,uBAAS;IACdC,QAAQ,EAAEC,4BAAc;IACxBC,IAAI,EAAEC,wBAAU;IAChBC,IAAI,EAAEC;EAAU,GAEvB;EAED,MAAMC,UAAU,GAAG9B,OAAO,CAACE,OAAO,CAACC,MAAM,CAAsB,gBAAgB,CAAC;EAChF,KAAK,IAAI4B,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,UAAU,CAACE,MAAM,EAAED,CAAC,EAAE,EAAE;IACxC,MAAME,MAAM,GAAGH,UAAU,CAACC,CAAC,CAAC;IAC5B;AACR;AACA;AACA;IACQ;IACAxB,QAAQ,CAAC2B,IAAI,CAACD,MAAM,CAACE,MAAM,CAAC5B,QAAQ,CAAC;IACrC;IACAI,SAAS,CAACuB,IAAI,CAACD,MAAM,CAACE,MAAM,CAACxB,SAAS,CAAC;EAC3C;EAEA,OAAO,IAAAyB,4BAAoB,EAAC;IACxB7B,QAAQ;IACRI,SAAS;IACT0B,8BAA8B,EAAE;EACpC,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/debugPlugins.js
CHANGED
|
@@ -4,20 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _interceptConsole = require("./interceptConsole");
|
|
9
|
-
|
|
10
8
|
var _api = require("@webiny/api");
|
|
11
|
-
|
|
12
9
|
var _default = () => [new _api.ContextPlugin(async context => {
|
|
13
10
|
if (!context.debug) {
|
|
14
11
|
context.debug = {};
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
if (!context.debug.logs) {
|
|
18
14
|
context.debug.logs = [];
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
(0, _interceptConsole.interceptConsole)((method, args) => {
|
|
22
17
|
context.debug.logs.push({
|
|
23
18
|
method,
|
|
@@ -26,7 +21,6 @@ var _default = () => [new _api.ContextPlugin(async context => {
|
|
|
26
21
|
});
|
|
27
22
|
}), {
|
|
28
23
|
type: "graphql-after-query",
|
|
29
|
-
|
|
30
24
|
apply({
|
|
31
25
|
result,
|
|
32
26
|
context
|
|
@@ -34,12 +28,9 @@ var _default = () => [new _api.ContextPlugin(async context => {
|
|
|
34
28
|
result["extensions"] = {
|
|
35
29
|
console: [...(context.debug.logs || [])]
|
|
36
30
|
};
|
|
37
|
-
|
|
38
31
|
if (context.debug.logs) {
|
|
39
32
|
context.debug.logs.length = 0;
|
|
40
33
|
}
|
|
41
34
|
}
|
|
42
|
-
|
|
43
35
|
}];
|
|
44
|
-
|
|
45
36
|
exports.default = _default;
|
package/debugPlugins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ContextPlugin","context","debug","logs","interceptConsole","method","args","push","type","apply","result","console","length"],"sources":["debugPlugins.ts"],"sourcesContent":["import { interceptConsole } from \"./interceptConsole\";\nimport { GraphQLAfterQueryPlugin } from \"./types\";\nimport { Context } from \"@webiny/api/types\";\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":"
|
|
1
|
+
{"version":3,"names":["ContextPlugin","context","debug","logs","interceptConsole","method","args","push","type","apply","result","console","length"],"sources":["debugPlugins.ts"],"sourcesContent":["import { interceptConsole } from \"./interceptConsole\";\nimport { GraphQLAfterQueryPlugin } from \"./types\";\nimport { Context } from \"@webiny/api/types\";\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;AAGA;AAA4C,eAY7B,MAAM,CACjB,IAAIA,kBAAa,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;EAEA,IAAAC,kCAAgB,EAAC,CAACC,MAAM,EAAEC,IAAI,KAAK;IAC9BL,OAAO,CAACC,KAAK,CAACC,IAAI,CAAWI,IAAI,CAAC;MAAEF,MAAM;MAAEC;IAAK,CAAC,CAAC;EACxD,CAAC,CAAC;AACN,CAAC,CAAC,EACF;EACIE,IAAI,EAAE,qBAAqB;EAC3BC,KAAK,CAAC;IAAEC,MAAM;IAAET;EAAQ,CAAC,EAAE;IACvBS,MAAM,CAAC,YAAY,CAAC,GAAG;MAAEC,OAAO,EAAE,CAAC,IAAIV,OAAO,CAACC,KAAK,CAACC,IAAI,IAAI,EAAE,CAAC;IAAE,CAAC;IACnE,IAAIF,OAAO,CAACC,KAAK,CAACC,IAAI,EAAE;MACpBF,OAAO,CAACC,KAAK,CAACC,IAAI,CAACS,MAAM,GAAG,CAAC;IACjC;EACJ;AACJ,CAAC,CACJ;AAAA"}
|
package/errors.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
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.NotFoundError = void 0;
|
|
9
|
-
|
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
9
|
class NotFoundError extends _error.default {
|
|
13
10
|
constructor(message = "Not found.") {
|
|
14
11
|
super(message, "NOT_FOUND");
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
exports.NotFoundError = NotFoundError;
|
package/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NotFoundError","WebinyError","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":"
|
|
1
|
+
{"version":3,"names":["NotFoundError","WebinyError","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;AAEO,MAAMA,aAAa,SAASC,cAAW,CAAC;EAC3CC,WAAW,CAACC,OAAO,GAAG,YAAY,EAAE;IAChC,KAAK,CAACA,OAAO,EAAE,WAAW,CAAC;EAC/B;AACJ;AAAC"}
|
package/index.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
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
|
var _exportNames = {};
|
|
9
8
|
exports.default = void 0;
|
|
10
|
-
|
|
11
9
|
var _createGraphQLHandler = _interopRequireDefault(require("./createGraphQLHandler"));
|
|
12
|
-
|
|
13
10
|
var _errors = require("./errors");
|
|
14
|
-
|
|
15
11
|
Object.keys(_errors).forEach(function (key) {
|
|
16
12
|
if (key === "default" || key === "__esModule") return;
|
|
17
13
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -23,9 +19,7 @@ Object.keys(_errors).forEach(function (key) {
|
|
|
23
19
|
}
|
|
24
20
|
});
|
|
25
21
|
});
|
|
26
|
-
|
|
27
22
|
var _responses = require("./responses");
|
|
28
|
-
|
|
29
23
|
Object.keys(_responses).forEach(function (key) {
|
|
30
24
|
if (key === "default" || key === "__esModule") return;
|
|
31
25
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -37,9 +31,7 @@ Object.keys(_responses).forEach(function (key) {
|
|
|
37
31
|
}
|
|
38
32
|
});
|
|
39
33
|
});
|
|
40
|
-
|
|
41
34
|
var _plugins = require("./plugins");
|
|
42
|
-
|
|
43
35
|
Object.keys(_plugins).forEach(function (key) {
|
|
44
36
|
if (key === "default" || key === "__esModule") return;
|
|
45
37
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -51,7 +43,5 @@ Object.keys(_plugins).forEach(function (key) {
|
|
|
51
43
|
}
|
|
52
44
|
});
|
|
53
45
|
});
|
|
54
|
-
|
|
55
46
|
var _default = (options = {}) => [(0, _createGraphQLHandler.default)(options)];
|
|
56
|
-
|
|
57
47
|
exports.default = _default;
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["options","createGraphQLHandler"],"sources":["index.ts"],"sourcesContent":["import { HandlerGraphQLOptions } from \"./types\";\nimport createGraphQLHandler from \"./createGraphQLHandler\";\n\nexport * from \"./errors\";\nexport * from \"./responses\";\nexport * from \"./plugins\";\n\nexport default (options: HandlerGraphQLOptions = {}) => [createGraphQLHandler(options)];\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["options","createGraphQLHandler"],"sources":["index.ts"],"sourcesContent":["import { HandlerGraphQLOptions } from \"./types\";\nimport createGraphQLHandler from \"./createGraphQLHandler\";\n\nexport * from \"./errors\";\nexport * from \"./responses\";\nexport * from \"./plugins\";\n\nexport default (options: HandlerGraphQLOptions = {}) => [createGraphQLHandler(options)];\n"],"mappings":";;;;;;;;AACA;AAEA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAA0B,eAEX,CAACA,OAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,IAAAC,6BAAoB,EAACD,OAAO,CAAC,CAAC;AAAA"}
|
package/interceptConsole.js
CHANGED
|
@@ -7,37 +7,31 @@ exports.interceptConsole = void 0;
|
|
|
7
7
|
const consoleMethods = ["assert", "debug", "dir", "error", "group", "groupCollapsed", "groupEnd", "info", "log", "table", "warn"];
|
|
8
8
|
const originalMethods = {};
|
|
9
9
|
const skipOriginal = ["table"];
|
|
10
|
-
|
|
11
10
|
const restoreOriginalMethods = () => {
|
|
12
11
|
for (const method of consoleMethods) {
|
|
13
12
|
// @ts-ignore
|
|
14
13
|
console[method] = originalMethods[method];
|
|
15
14
|
}
|
|
16
15
|
};
|
|
17
|
-
|
|
18
16
|
const interceptConsole = callback => {
|
|
19
17
|
// @ts-ignore
|
|
20
18
|
if (console["__WEBINY__"] === true) {
|
|
21
19
|
restoreOriginalMethods();
|
|
22
|
-
}
|
|
23
|
-
|
|
20
|
+
}
|
|
24
21
|
|
|
22
|
+
// @ts-ignore
|
|
25
23
|
console["__WEBINY__"] = true;
|
|
26
|
-
|
|
27
24
|
for (const method of consoleMethods) {
|
|
28
25
|
// @ts-ignore
|
|
29
|
-
originalMethods[method] = console[method];
|
|
30
|
-
|
|
26
|
+
originalMethods[method] = console[method];
|
|
27
|
+
// @ts-ignore
|
|
31
28
|
console[method] = (...args) => {
|
|
32
29
|
callback(method, args);
|
|
33
|
-
|
|
34
30
|
if (skipOriginal.includes(method)) {
|
|
35
31
|
return;
|
|
36
32
|
}
|
|
37
|
-
|
|
38
33
|
originalMethods[method](...args);
|
|
39
34
|
};
|
|
40
35
|
}
|
|
41
36
|
};
|
|
42
|
-
|
|
43
37
|
exports.interceptConsole = interceptConsole;
|
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-ignore\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-ignore\n if (console[\"__WEBINY__\"] === true) {\n restoreOriginalMethods();\n }\n\n // @ts-ignore\n console[\"__WEBINY__\"] = true;\n\n for (const method of consoleMethods) {\n // @ts-ignore\n originalMethods[method] = console[method];\n // @ts-ignore\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,
|
|
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-ignore\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-ignore\n if (console[\"__WEBINY__\"] === true) {\n restoreOriginalMethods();\n }\n\n // @ts-ignore\n console[\"__WEBINY__\"] = true;\n\n for (const method of consoleMethods) {\n // @ts-ignore\n originalMethods[method] = console[method];\n // @ts-ignore\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,GAAG,MAAM;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,EAAE;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;AAAC"}
|
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.611c5af35e",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"Adrian Smijulj <adrian@webiny.com>"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@babel/runtime": "7.
|
|
17
|
+
"@babel/runtime": "7.20.1",
|
|
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.611c5af35e",
|
|
20
|
+
"@webiny/error": "0.0.0-unstable.611c5af35e",
|
|
21
|
+
"@webiny/handler": "0.0.0-unstable.611c5af35e",
|
|
22
|
+
"@webiny/plugins": "0.0.0-unstable.611c5af35e",
|
|
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": "^0.0.0-unstable.
|
|
33
|
-
"@webiny/handler-aws": "^0.0.0-unstable.
|
|
34
|
-
"@webiny/project-utils": "^0.0.0-unstable.
|
|
32
|
+
"@webiny/cli": "^0.0.0-unstable.611c5af35e",
|
|
33
|
+
"@webiny/handler-aws": "^0.0.0-unstable.611c5af35e",
|
|
34
|
+
"@webiny/project-utils": "^0.0.0-unstable.611c5af35e",
|
|
35
35
|
"jest": "^28.1.0",
|
|
36
36
|
"jest-mock-console": "^1.0.0",
|
|
37
37
|
"rimraf": "^3.0.2",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"build": "yarn webiny run build",
|
|
46
46
|
"watch": "yarn webiny run watch"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "cdeed09317c2c0e07cb0d4d88f9ac38a214ddc22"
|
|
49
49
|
}
|
|
@@ -1,31 +1,24 @@
|
|
|
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.GraphQLSchemaPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _plugins = require("@webiny/plugins");
|
|
13
|
-
|
|
14
10
|
class GraphQLSchemaPlugin extends _plugins.Plugin {
|
|
15
11
|
constructor(config) {
|
|
16
12
|
super();
|
|
17
13
|
(0, _defineProperty2.default)(this, "config", void 0);
|
|
18
14
|
this.config = config;
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
get schema() {
|
|
22
17
|
return {
|
|
23
18
|
typeDefs: this.config.typeDefs || "",
|
|
24
19
|
resolvers: this.config.resolvers
|
|
25
20
|
};
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
}
|
|
29
|
-
|
|
30
23
|
exports.GraphQLSchemaPlugin = GraphQLSchemaPlugin;
|
|
31
24
|
(0, _defineProperty2.default)(GraphQLSchemaPlugin, "type", "graphql-schema");
|
|
@@ -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":["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":";;;;;;;;AAAA;AASO,MAAMA,mBAAmB,SAA6BC,eAAM,CAAC;EAIhEC,WAAW,CAACC,MAA2C,EAAE;IACrD,KAAK,EAAE;IAAC;IACR,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,IAAIC,MAAM,GAAsC;IAC5C,OAAO;MACHC,QAAQ,EAAE,IAAI,CAACF,MAAM,CAACE,QAAQ,IAAI,EAAE;MACpCC,SAAS,EAAE,IAAI,CAACH,MAAM,CAACG;IAC3B,CAAC;EACL;AACJ;AAAC;AAAA,8BAfYN,mBAAmB,UACmB,gBAAgB"}
|
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;
|
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":[],"sources":["index.ts"],"sourcesContent":["export * from \"./GraphQLSchemaPlugin\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;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,14 @@ const processRequestBody = async (body, schema, context) => {
|
|
|
29
27
|
});
|
|
30
28
|
return result;
|
|
31
29
|
};
|
|
32
|
-
|
|
33
30
|
var _default = async (requestBody, schema, context) => {
|
|
34
31
|
if (Array.isArray(requestBody) === true) {
|
|
35
32
|
const result = [];
|
|
36
|
-
|
|
37
33
|
for (let i = 0; i < requestBody.length; i++) {
|
|
38
34
|
result.push(await processRequestBody(requestBody[i], schema, context));
|
|
39
35
|
}
|
|
40
|
-
|
|
41
36
|
return result;
|
|
42
37
|
}
|
|
43
|
-
|
|
44
38
|
return await processRequestBody(requestBody, schema, context);
|
|
45
39
|
};
|
|
46
|
-
|
|
47
40
|
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","i","length","push"],"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) === true) {\n const result: ExecutionResult[] = [];\n for (let i = 0; i < (requestBody as GraphQLRequestBody[]).length; i++) {\n result.push(\n await processRequestBody((requestBody as GraphQLRequestBody[])[i], schema, context)\n );\n }\n return result;\n }\n return await processRequestBody(requestBody as GraphQLRequestBody, schema, context);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["processRequestBody","body","schema","context","query","variables","operationName","plugins","byType","forEach","pl","apply","result","graphql","requestBody","Array","isArray","i","length","push"],"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) === true) {\n const result: ExecutionResult[] = [];\n for (let i = 0; i < (requestBody as GraphQLRequestBody[]).length; i++) {\n result.push(\n await processRequestBody((requestBody as GraphQLRequestBody[])[i], schema, context)\n );\n }\n return result;\n }\n return await processRequestBody(requestBody as GraphQLRequestBody, schema, context);\n};\n"],"mappings":";;;;;;AAAA;AAIA,MAAMA,kBAAkB,GAAG,OACvBC,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,eAEa,OACXE,WAAsD,EACtDZ,MAAqB,EACrBC,OAAgB,KAC+B;EAC/C,IAAIY,KAAK,CAACC,OAAO,CAACF,WAAW,CAAC,KAAK,IAAI,EAAE;IACrC,MAAMF,MAAyB,GAAG,EAAE;IACpC,KAAK,IAAIK,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAIH,WAAW,CAA0BI,MAAM,EAAED,CAAC,EAAE,EAAE;MACnEL,MAAM,CAACO,IAAI,CACP,MAAMnB,kBAAkB,CAAEc,WAAW,CAA0BG,CAAC,CAAC,EAAEf,MAAM,EAAEC,OAAO,CAAC,CACtF;IACL;IACA,OAAOS,MAAM;EACjB;EACA,OAAO,MAAMZ,kBAAkB,CAACc,WAAW,EAAwBZ,MAAM,EAAEC,OAAO,CAAC;AACvF,CAAC;AAAA"}
|
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","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":";;;;;;;;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,WAAW,CAACC,MAA2B,EAAE;IAAA;IAAA;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;AAAC;AAEM,MAAMS,gBAAgB,SAASR,aAAa,CAAC;EAChDC,WAAW,CAACJ,OAAe,EAAE;IACzB,KAAK,CAAC;MACFD,IAAI,EAAE,WAAW;MACjBC;IACJ,CAAC,CAAC;EACN;AACJ;AAAC;AAEM,MAAMY,iBAAiB,CAAC;EAU3BR,WAAW,CAACC,MAA2B,EAAE;IAAA;IAAA;IAAA;IACrC,IAAI,CAACQ,IAAI,GAAG,IAAI;IAChB,IAAI,CAACZ,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;AAAC;AAEM,MAAMY,QAAQ,CAAU;EAI3BV,WAAW,CAACH,IAAO,EAAE;IAAA;IAAA;IACjB,IAAI,CAACA,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACS,KAAK,GAAG,IAAI;EACrB;AACJ;AAAC;AAEM,MAAMK,YAAY,CAAO;EAK5BX,WAAW,CAACH,IAAc,EAAEY,IAAQ,EAAE;IAAA;IAAA;IAAA;IAClC,IAAI,CAACZ,IAAI,GAAGe,KAAK,CAACC,OAAO,CAAChB,IAAI,CAAC,GAAGA,IAAI,GAAG,EAAE;IAC3C,IAAI,CAACY,IAAI,GAAGA,IAAI,IAAK,CAAC,CAAO;IAC7B,IAAI,CAACH,KAAK,GAAG,IAAI;EACrB;AACJ;AAAC"}
|