@webiny/handler-graphql 5.40.0-beta.1 → 5.40.0-beta.3
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 +1 -2
- package/builtInTypes/AnyScalar.js.map +1 -1
- package/builtInTypes/DateScalar.js +1 -2
- package/builtInTypes/DateScalar.js.map +1 -1
- package/builtInTypes/DateTimeScalar.js +1 -2
- package/builtInTypes/DateTimeScalar.js.map +1 -1
- package/builtInTypes/DateTimeZScalar.js +1 -2
- package/builtInTypes/DateTimeZScalar.js.map +1 -1
- package/builtInTypes/JsonScalar.js +1 -2
- package/builtInTypes/JsonScalar.js.map +1 -1
- package/builtInTypes/LongScalar.js +1 -2
- package/builtInTypes/LongScalar.js.map +1 -1
- package/builtInTypes/NumberScalar.js +1 -2
- package/builtInTypes/NumberScalar.js.map +1 -1
- package/builtInTypes/RefInputScalar.js +1 -2
- package/builtInTypes/RefInputScalar.js.map +1 -1
- package/builtInTypes/TimeScalar.js +1 -2
- package/builtInTypes/TimeScalar.js.map +1 -1
- package/builtInTypes/index.js.map +1 -1
- package/createGraphQLHandler.js +2 -2
- package/createGraphQLHandler.js.map +1 -1
- package/createGraphQLSchema.js.map +1 -1
- package/debugPlugins.js.map +1 -1
- package/errors.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +13 -10
- package/index.js.map +1 -1
- package/interceptConsole.js.map +1 -1
- package/package.json +15 -15
- package/plugins/GraphQLSchemaPlugin.d.ts +6 -2
- package/plugins/GraphQLSchemaPlugin.js +5 -1
- package/plugins/GraphQLSchemaPlugin.js.map +1 -1
- package/plugins/index.js.map +1 -1
- package/processRequestBody.d.ts +1 -2
- package/processRequestBody.js +6 -6
- package/processRequestBody.js.map +1 -1
- package/responses.js.map +1 -1
- package/types.js.map +1 -1
|
@@ -8,12 +8,11 @@ var _graphql = require("graphql");
|
|
|
8
8
|
const returnValue = value => {
|
|
9
9
|
return value;
|
|
10
10
|
};
|
|
11
|
-
const AnyScalar = new _graphql.GraphQLScalarType({
|
|
11
|
+
const AnyScalar = exports.AnyScalar = new _graphql.GraphQLScalarType({
|
|
12
12
|
name: "Any",
|
|
13
13
|
description: `A scalar type that represents an ambiguous value.`,
|
|
14
14
|
serialize: returnValue,
|
|
15
15
|
parseValue: returnValue
|
|
16
16
|
});
|
|
17
|
-
exports.AnyScalar = AnyScalar;
|
|
18
17
|
|
|
19
18
|
//# sourceMappingURL=AnyScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","returnValue","value","AnyScalar","GraphQLScalarType","name","description","serialize","parseValue"
|
|
1
|
+
{"version":3,"names":["_graphql","require","returnValue","value","AnyScalar","exports","GraphQLScalarType","name","description","serialize","parseValue"],"sources":["AnyScalar.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\n\nconst returnValue = (value: any): any => {\n return value;\n};\n\nexport const AnyScalar = new GraphQLScalarType({\n name: \"Any\",\n description: `A scalar type that represents an ambiguous value.`,\n serialize: returnValue,\n parseValue: returnValue\n});\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,MAAMC,WAAW,GAAIC,KAAU,IAAU;EACrC,OAAOA,KAAK;AAChB,CAAC;AAEM,MAAMC,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,IAAIE,0BAAiB,CAAC;EAC3CC,IAAI,EAAE,KAAK;EACXC,WAAW,EAAG,mDAAkD;EAChEC,SAAS,EAAEP,WAAW;EACtBQ,UAAU,EAAER;AAChB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.DateScalar = void 0;
|
|
7
7
|
var _graphqlScalars = require("graphql-scalars");
|
|
8
8
|
var _graphql = require("graphql");
|
|
9
|
-
const DateScalar = new _graphql.GraphQLScalarType({
|
|
9
|
+
const DateScalar = exports.DateScalar = new _graphql.GraphQLScalarType({
|
|
10
10
|
..._graphqlScalars.DateResolver,
|
|
11
11
|
serialize: value => {
|
|
12
12
|
if (!value) {
|
|
@@ -23,6 +23,5 @@ const DateScalar = new _graphql.GraphQLScalarType({
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
exports.DateScalar = DateScalar;
|
|
27
26
|
|
|
28
27
|
//# sourceMappingURL=DateScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphqlScalars","require","_graphql","DateScalar","GraphQLScalarType","DateResolver","serialize","value","date","Date","toISOString","slice","ex"
|
|
1
|
+
{"version":3,"names":["_graphqlScalars","require","_graphql","DateScalar","exports","GraphQLScalarType","DateResolver","serialize","value","date","Date","toISOString","slice","ex"],"sources":["DateScalar.ts"],"sourcesContent":["import { DateResolver } from \"graphql-scalars\";\nimport { GraphQLScalarType } from \"graphql\";\nexport const DateScalar = new GraphQLScalarType({\n ...DateResolver,\n serialize: value => {\n if (!value) {\n return null;\n }\n try {\n const date = new Date(value);\n return date.toISOString().slice(0, 10);\n } catch (ex) {\n if (value.toISOString) {\n return value.toISOString().slice(0, 10);\n }\n throw ex;\n }\n }\n});\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACO,MAAME,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,IAAIE,0BAAiB,CAAC;EAC5C,GAAGC,4BAAY;EACfC,SAAS,EAAEC,KAAK,IAAI;IAChB,IAAI,CAACA,KAAK,EAAE;MACR,OAAO,IAAI;IACf;IACA,IAAI;MACA,MAAMC,IAAI,GAAG,IAAIC,IAAI,CAACF,KAAK,CAAC;MAC5B,OAAOC,IAAI,CAACE,WAAW,CAAC,CAAC,CAACC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;IAC1C,CAAC,CAAC,OAAOC,EAAE,EAAE;MACT,IAAIL,KAAK,CAACG,WAAW,EAAE;QACnB,OAAOH,KAAK,CAACG,WAAW,CAAC,CAAC,CAACC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;MAC3C;MACA,MAAMC,EAAE;IACZ;EACJ;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.DateTimeScalar = void 0;
|
|
7
7
|
var _graphqlScalars = require("graphql-scalars");
|
|
8
8
|
var _graphql = require("graphql");
|
|
9
|
-
const DateTimeScalar = new _graphql.GraphQLScalarType({
|
|
9
|
+
const DateTimeScalar = exports.DateTimeScalar = new _graphql.GraphQLScalarType({
|
|
10
10
|
..._graphqlScalars.DateTimeResolver,
|
|
11
11
|
serialize: value => {
|
|
12
12
|
if (!value) {
|
|
@@ -23,6 +23,5 @@ const DateTimeScalar = new _graphql.GraphQLScalarType({
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
exports.DateTimeScalar = DateTimeScalar;
|
|
27
26
|
|
|
28
27
|
//# sourceMappingURL=DateTimeScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphqlScalars","require","_graphql","DateTimeScalar","GraphQLScalarType","DateTimeResolver","serialize","value","date","Date","toISOString","ex"
|
|
1
|
+
{"version":3,"names":["_graphqlScalars","require","_graphql","DateTimeScalar","exports","GraphQLScalarType","DateTimeResolver","serialize","value","date","Date","toISOString","ex"],"sources":["DateTimeScalar.ts"],"sourcesContent":["import { DateTimeResolver } from \"graphql-scalars\";\nimport { GraphQLScalarType } from \"graphql\";\nexport const DateTimeScalar = new GraphQLScalarType({\n ...DateTimeResolver,\n serialize: value => {\n if (!value) {\n return null;\n }\n try {\n const date = new Date(value);\n return date.toISOString();\n } catch (ex) {\n if (value.toISOString) {\n return value.toISOString();\n }\n throw ex;\n }\n }\n});\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACO,MAAME,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,IAAIE,0BAAiB,CAAC;EAChD,GAAGC,gCAAgB;EACnBC,SAAS,EAAEC,KAAK,IAAI;IAChB,IAAI,CAACA,KAAK,EAAE;MACR,OAAO,IAAI;IACf;IACA,IAAI;MACA,MAAMC,IAAI,GAAG,IAAIC,IAAI,CAACF,KAAK,CAAC;MAC5B,OAAOC,IAAI,CAACE,WAAW,CAAC,CAAC;IAC7B,CAAC,CAAC,OAAOC,EAAE,EAAE;MACT,IAAIJ,KAAK,CAACG,WAAW,EAAE;QACnB,OAAOH,KAAK,CAACG,WAAW,CAAC,CAAC;MAC9B;MACA,MAAMC,EAAE;IACZ;EACJ;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -34,7 +34,7 @@ const validateTimeZone = value => {
|
|
|
34
34
|
* A custom type for dateTime with the timezone.
|
|
35
35
|
* Must be in format "YYYY-MM-ddTHH:mm:ss+HH:mm".
|
|
36
36
|
*/
|
|
37
|
-
const DateTimeZScalar = new _graphql.GraphQLScalarType({
|
|
37
|
+
const DateTimeZScalar = exports.DateTimeZScalar = new _graphql.GraphQLScalarType({
|
|
38
38
|
name: "DateTimeZ",
|
|
39
39
|
description: "A custom type for dateTime with the timezone.",
|
|
40
40
|
parseValue: value => {
|
|
@@ -47,6 +47,5 @@ const DateTimeZScalar = new _graphql.GraphQLScalarType({
|
|
|
47
47
|
return value;
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
|
-
exports.DateTimeZScalar = DateTimeZScalar;
|
|
51
50
|
|
|
52
51
|
//# sourceMappingURL=DateTimeZScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphqlScalars","require","_graphql","_error","_interopRequireDefault","validateTimeZone","value","timeWithTimezone","split","WebinyError","separator","includes","zone","hoursMinutes","hours","minutes","undefined","length","DateTimeZScalar","GraphQLScalarType","name","description","parseValue","DateTimeResolver","serialize"
|
|
1
|
+
{"version":3,"names":["_graphqlScalars","require","_graphql","_error","_interopRequireDefault","validateTimeZone","value","timeWithTimezone","split","WebinyError","separator","includes","zone","hoursMinutes","hours","minutes","undefined","length","DateTimeZScalar","exports","GraphQLScalarType","name","description","parseValue","DateTimeResolver","serialize"],"sources":["DateTimeZScalar.ts"],"sourcesContent":["import { DateTimeResolver } from \"graphql-scalars\";\nimport { GraphQLScalarType } from \"graphql\";\nimport WebinyError from \"@webiny/error\";\n\nconst validateTimeZone = (value: string): void => {\n const timeWithTimezone = value.split(\"T\")[1];\n if (!timeWithTimezone) {\n throw new WebinyError(\n \"Could not extract time with timezone from value.\",\n \"DATE_TIME_TIMEZONE_ERROR\",\n {\n value\n }\n );\n }\n const separator = timeWithTimezone.includes(\"-\") ? \"-\" : \"+\";\n const zone = timeWithTimezone.split(separator)[1];\n if (!zone) {\n throw new WebinyError(\n \"Could not extract timezone from value.\",\n \"DATE_TIME_TIMEZONE_ERROR\",\n {\n value: timeWithTimezone\n }\n );\n }\n const hoursMinutes = zone.split(\":\");\n const [hours, minutes] = hoursMinutes;\n if (hours === undefined || minutes === undefined || hoursMinutes.length !== 2) {\n throw new WebinyError(\n \"Could not extract hours or minutes from value.\",\n \"DATE_TIME_TIMEZONE_ERROR\",\n {\n value: zone\n }\n );\n }\n};\n/**\n * A custom type for dateTime with the timezone.\n * Must be in format \"YYYY-MM-ddTHH:mm:ss+HH:mm\".\n */\nexport const DateTimeZScalar = new GraphQLScalarType({\n name: \"DateTimeZ\",\n description: \"A custom type for dateTime with the timezone.\",\n parseValue: value => {\n // this serves as validator\n DateTimeResolver.parseValue(value);\n validateTimeZone(value);\n return value;\n },\n serialize: value => {\n return value;\n }\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,MAAMI,gBAAgB,GAAIC,KAAa,IAAW;EAC9C,MAAMC,gBAAgB,GAAGD,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defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.JsonScalar = void 0;
|
|
7
7
|
var _graphqlScalars = require("graphql-scalars");
|
|
8
|
-
const JsonScalar = _graphqlScalars.JSONResolver;
|
|
9
|
-
exports.JsonScalar = JsonScalar;
|
|
8
|
+
const JsonScalar = exports.JsonScalar = _graphqlScalars.JSONResolver;
|
|
10
9
|
|
|
11
10
|
//# sourceMappingURL=JsonScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphqlScalars","require","JsonScalar","
|
|
1
|
+
{"version":3,"names":["_graphqlScalars","require","JsonScalar","exports","JSONResolver"],"sources":["JsonScalar.ts"],"sourcesContent":["import { JSONResolver } from \"graphql-scalars\";\nexport const JsonScalar = JSONResolver;\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACO,MAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAGE,4BAAY","ignoreList":[]}
|
|
@@ -27,7 +27,7 @@ const parseValue = value => {
|
|
|
27
27
|
}
|
|
28
28
|
return parseInt(value);
|
|
29
29
|
};
|
|
30
|
-
const LongScalar = new _graphql.GraphQLScalarType({
|
|
30
|
+
const LongScalar = exports.LongScalar = new _graphql.GraphQLScalarType({
|
|
31
31
|
name: "Long",
|
|
32
32
|
description: "A custom input type to be used for large integers (Long).",
|
|
33
33
|
serialize: value => {
|
|
@@ -52,6 +52,5 @@ const LongScalar = new _graphql.GraphQLScalarType({
|
|
|
52
52
|
throw new Error(`Expected type Long, found {${ast.kind}}`);
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
|
-
exports.LongScalar = LongScalar;
|
|
56
55
|
|
|
57
56
|
//# sourceMappingURL=LongScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","_language","_error","_interopRequireDefault","parseValue","value","String","includes","WebinyError","undefined","isNaN","parseInt","LongScalar","GraphQLScalarType","name","description","serialize","ex","console","log","message","code","data","parseLiteral","ast","kind","Kind","INT","Error"
|
|
1
|
+
{"version":3,"names":["_graphql","require","_language","_error","_interopRequireDefault","parseValue","value","String","includes","WebinyError","undefined","isNaN","parseInt","LongScalar","exports","GraphQLScalarType","name","description","serialize","ex","console","log","message","code","data","parseLiteral","ast","kind","Kind","INT","Error"],"sources":["LongScalar.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\nimport { Kind } from \"graphql/language\";\nimport WebinyError from \"@webiny/error\";\n\nconst parseValue = (value: any) => {\n if (String(value).includes(\".\")) {\n throw new WebinyError(\"Value sent must be an integer.\", \"INVALID_VALUE\", {\n value\n });\n }\n if (typeof value === \"number\") {\n return value;\n }\n\n if (value === null || value === undefined) {\n return null;\n }\n\n if (isNaN(value) === true) {\n throw new WebinyError(\"Value sent must be an integer.\", \"INVALID_VALUE\", {\n value\n });\n }\n\n return parseInt(value);\n};\n\nexport const LongScalar = new GraphQLScalarType({\n name: \"Long\",\n description: \"A custom input type to be used for large integers (Long).\",\n serialize: (value: any) => {\n try {\n return parseValue(value);\n } catch (ex) {\n console.log({\n message: \"Value sent must be an integer.\",\n code: \"INVALID_VALUE\",\n data: {\n value\n }\n });\n return null;\n }\n },\n parseValue,\n parseLiteral: ast => {\n if (ast.kind === Kind.INT) {\n return parseInt(ast.value);\n }\n\n throw new Error(`Expected type Long, found {${ast.kind}}`);\n }\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,MAAMI,UAAU,GAAIC,KAAU,IAAK;EAC/B,IAAIC,MAAM,CAACD,KAAK,CAAC,CAACE,QAAQ,CAAC,GAAG,CAAC,EAAE;IAC7B,MAAM,IAAIC,cAAW,CAAC,gCAAgC,EAAE,eAAe,EAAE;MACrEH;IACJ,CAAC,CAAC;EACN;EACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKI,SAAS,EAAE;IACvC,OAAO,IAAI;EACf;EAEA,IAAIC,KAAK,CAACL,KAAK,CAAC,KAAK,IAAI,EAAE;IACvB,MAAM,IAAIG,cAAW,CAAC,gCAAgC,EAAE,eAAe,EAAE;MACrEH;IACJ,CAAC,CAAC;EACN;EAEA,OAAOM,QAAQ,CAACN,KAAK,CAAC;AAC1B,CAAC;AAEM,MAAMO,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,IAAIE,0BAAiB,CAAC;EAC5CC,IAAI,EAAE,MAAM;EACZC,WAAW,EAAE,2DAA2D;EACxEC,SAAS,EAAGZ,KAAU,IAAK;IACvB,IAAI;MACA,OAAOD,UAAU,CAACC,KAAK,CAAC;IAC5B,CAAC,CAAC,OAAOa,EAAE,EAAE;MACTC,OAAO,CAACC,GAAG,CAAC;QACRC,OAAO,EAAE,gCAAgC;QACzCC,IAAI,EAAE,eAAe;QACrBC,IAAI,EAAE;UACFlB;QACJ;MACJ,CAAC,CAAC;MACF,OAAO,IAAI;IACf;EACJ,CAAC;EACDD,UAAU;EACVoB,YAAY,EAAEC,GAAG,IAAI;IACjB,IAAIA,GAAG,CAACC,IAAI,KAAKC,cAAI,CAACC,GAAG,EAAE;MACvB,OAAOjB,QAAQ,CAACc,GAAG,CAACpB,KAAK,CAAC;IAC9B;IAEA,MAAM,IAAIwB,KAAK,CAAE,8BAA6BJ,GAAG,CAACC,IAAK,GAAE,CAAC;EAC9D;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -24,7 +24,7 @@ const parseValue = value => {
|
|
|
24
24
|
}
|
|
25
25
|
return parseFloat(value);
|
|
26
26
|
};
|
|
27
|
-
const NumberScalar = new _graphql.GraphQLScalarType({
|
|
27
|
+
const NumberScalar = exports.NumberScalar = new _graphql.GraphQLScalarType({
|
|
28
28
|
name: "Number",
|
|
29
29
|
description: "A custom input type to be used with numbers. Supports Int and Float.",
|
|
30
30
|
serialize: value => {
|
|
@@ -51,6 +51,5 @@ const NumberScalar = new _graphql.GraphQLScalarType({
|
|
|
51
51
|
throw new Error(`Expected type Number, found {${ast.kind}}`);
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
-
exports.NumberScalar = NumberScalar;
|
|
55
54
|
|
|
56
55
|
//# sourceMappingURL=NumberScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","_language","_error","_interopRequireDefault","parseValue","value","String","match","WebinyError","undefined","isNaN","parseFloat","NumberScalar","GraphQLScalarType","name","description","serialize","ex","console","log","message","code","data","parseLiteral","ast","kind","Kind","INT","Number","FLOAT","Error"
|
|
1
|
+
{"version":3,"names":["_graphql","require","_language","_error","_interopRequireDefault","parseValue","value","String","match","WebinyError","undefined","isNaN","parseFloat","NumberScalar","exports","GraphQLScalarType","name","description","serialize","ex","console","log","message","code","data","parseLiteral","ast","kind","Kind","INT","Number","FLOAT","Error"],"sources":["NumberScalar.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\nimport { Kind } from \"graphql/language\";\nimport WebinyError from \"@webiny/error\";\n\nconst parseValue = (value: any) => {\n if (String(value).match(/^0x/) !== null) {\n throw new WebinyError(\"Value sent must be a non-hex number.\", \"INVALID_VALUE\", {\n value\n });\n } else if (typeof value === \"number\") {\n return value;\n } else if (value === null || value === undefined) {\n return null;\n } else if (isNaN(value) === true) {\n throw new WebinyError(\"Value sent must be a number.\", \"INVALID_VALUE\", {\n value\n });\n }\n return parseFloat(value);\n};\n\nexport const NumberScalar = new GraphQLScalarType({\n name: \"Number\",\n description: \"A custom input type to be used with numbers. Supports Int and Float.\",\n serialize: (value: any) => {\n try {\n return parseValue(value);\n } catch (ex) {\n console.log({\n message: \"Value sent must be a number.\",\n code: \"INVALID_VALUE\",\n data: {\n value\n }\n });\n return null;\n }\n },\n parseValue,\n parseLiteral: ast => {\n if (ast.kind === Kind.INT) {\n return Number(ast.value);\n } else if (ast.kind === Kind.FLOAT) {\n return parseFloat(ast.value);\n }\n throw new Error(`Expected type Number, found {${ast.kind}}`);\n }\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,MAAMI,UAAU,GAAIC,KAAU,IAAK;EAC/B,IAAIC,MAAM,CAACD,KAAK,CAAC,CAACE,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;IACrC,MAAM,IAAIC,cAAW,CAAC,sCAAsC,EAAE,eAAe,EAAE;MAC3EH;IACJ,CAAC,CAAC;EACN,CAAC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAClC,OAAOA,KAAK;EAChB,CAAC,MAAM,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKI,SAAS,EAAE;IAC9C,OAAO,IAAI;EACf,CAAC,MAAM,IAAIC,KAAK,CAACL,KAAK,CAAC,KAAK,IAAI,EAAE;IAC9B,MAAM,IAAIG,cAAW,CAAC,8BAA8B,EAAE,eAAe,EAAE;MACnEH;IACJ,CAAC,CAAC;EACN;EACA,OAAOM,UAAU,CAACN,KAAK,CAAC;AAC5B,CAAC;AAEM,MAAMO,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,IAAIE,0BAAiB,CAAC;EAC9CC,IAAI,EAAE,QAAQ;EACdC,WAAW,EAAE,sEAAsE;EACnFC,SAAS,EAAGZ,KAAU,IAAK;IACvB,IAAI;MACA,OAAOD,UAAU,CAACC,KAAK,CAAC;IAC5B,CAAC,CAAC,OAAOa,EAAE,EAAE;MACTC,OAAO,CAACC,GAAG,CAAC;QACRC,OAAO,EAAE,8BAA8B;QACvCC,IAAI,EAAE,eAAe;QACrBC,IAAI,EAAE;UACFlB;QACJ;MACJ,CAAC,CAAC;MACF,OAAO,IAAI;IACf;EACJ,CAAC;EACDD,UAAU;EACVoB,YAAY,EAAEC,GAAG,IAAI;IACjB,IAAIA,GAAG,CAACC,IAAI,KAAKC,cAAI,CAACC,GAAG,EAAE;MACvB,OAAOC,MAAM,CAACJ,GAAG,CAACpB,KAAK,CAAC;IAC5B,CAAC,MAAM,IAAIoB,GAAG,CAACC,IAAI,KAAKC,cAAI,CAACG,KAAK,EAAE;MAChC,OAAOnB,UAAU,CAACc,GAAG,CAACpB,KAAK,CAAC;IAChC;IACA,MAAM,IAAI0B,KAAK,CAAE,gCAA+BN,GAAG,CAACC,IAAK,GAAE,CAAC;EAChE;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -32,7 +32,7 @@ const isValidId = value => {
|
|
|
32
32
|
}
|
|
33
33
|
return value;
|
|
34
34
|
};
|
|
35
|
-
const RefInputScalar = new _graphql.GraphQLScalarType({
|
|
35
|
+
const RefInputScalar = exports.RefInputScalar = new _graphql.GraphQLScalarType({
|
|
36
36
|
name: "RefInput",
|
|
37
37
|
description: "A custom input type to be used with references. Supports plain ID and `{ id: ID }` Object literal.",
|
|
38
38
|
serialize: value => {
|
|
@@ -72,6 +72,5 @@ const RefInputScalar = new _graphql.GraphQLScalarType({
|
|
|
72
72
|
throw new Error("Invalid RefInput value!");
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
|
-
exports.RefInputScalar = RefInputScalar;
|
|
76
75
|
|
|
77
76
|
//# sourceMappingURL=RefInputScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","tests","re","message","isValidId","value","length","Error","test","RefInputScalar","GraphQLScalarType","name","description","serialize","id","parseValue","parseLiteral","ast","kind","i","fields"
|
|
1
|
+
{"version":3,"names":["_graphql","require","tests","re","message","isValidId","value","length","Error","test","RefInputScalar","exports","GraphQLScalarType","name","description","serialize","id","parseValue","parseLiteral","ast","kind","i","fields"],"sources":["RefInputScalar.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\n\nconst tests = [\n {\n re: /^([0-9a-zA-Z_-]+)$/,\n message: \"Must be a string matching a-z, A-Z, 0-9, underscore (_) or dash(-)!\"\n },\n {\n re: /^-/,\n message: \"Must not start with a dash (-)!\"\n },\n {\n re: /-$/,\n message: \"Must not end with a dash (-)!\"\n },\n {\n re: /^_/,\n message: \"Must not start with an underscore (_)!\"\n },\n {\n re: /_$/,\n message: \"Must not end with an underscore (_)!\"\n }\n];\n\nconst isValidId = (value: any): string => {\n if (typeof value !== \"string\" || value.length < 1) {\n throw new Error(\"Must be a string with at least 1 character!\");\n }\n for (const test of tests) {\n if (test.re.test(value) === null) {\n throw new Error(test.message);\n }\n }\n return value;\n};\n\nexport const RefInputScalar = new GraphQLScalarType({\n name: \"RefInput\",\n description:\n \"A custom input type to be used with references. Supports plain ID and `{ id: ID }` Object literal.\",\n serialize: value => {\n if (!value || value.id === null) {\n return null;\n }\n\n return typeof value === \"string\" ? value : value.id;\n },\n parseValue: value => {\n if (!value || value.id === null) {\n return null;\n }\n\n if (typeof value === \"string\") {\n return isValidId(value);\n }\n\n if (\"id\" in value) {\n return isValidId(value.id);\n }\n\n throw new Error(\"Invalid RefInput value!\");\n },\n parseLiteral: ast => {\n if (ast.kind === \"StringValue\") {\n return isValidId(ast.value);\n }\n\n if (ast.kind === \"ObjectValue\") {\n for (let i = 0; i < ast.fields.length; i++) {\n const { name, value } = ast.fields[i];\n if (name.value === \"id\") {\n // @ts-expect-error\n return isValidId(value.value);\n }\n }\n }\n\n throw new Error(\"Invalid RefInput value!\");\n }\n});\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,MAAMC,KAAK,GAAG,CACV;EACIC,EAAE,EAAE,oBAAoB;EACxBC,OAAO,EAAE;AACb,CAAC,EACD;EACID,EAAE,EAAE,IAAI;EACRC,OAAO,EAAE;AACb,CAAC,EACD;EACID,EAAE,EAAE,IAAI;EACRC,OAAO,EAAE;AACb,CAAC,EACD;EACID,EAAE,EAAE,IAAI;EACRC,OAAO,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AAI,KAAK,aAAa,EAAE;MAC5B,OAAOf,SAAS,CAACc,GAAG,CAACb,KAAK,CAAC;IAC/B;IAEA,IAAIa,GAAG,CAACC,IAAI,KAAK,aAAa,EAAE;MAC5B,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,GAAG,CAACG,MAAM,CAACf,MAAM,EAAEc,CAAC,EAAE,EAAE;QACxC,MAAM;UAAER,IAAI;UAAEP;QAAM,CAAC,GAAGa,GAAG,CAACG,MAAM,CAACD,CAAC,CAAC;QACrC,IAAIR,IAAI,CAACP,KAAK,KAAK,IAAI,EAAE;UACrB;UACA,OAAOD,SAAS,CAACC,KAAK,CAACA,KAAK,CAAC;QACjC;MACJ;IACJ;IAEA,MAAM,IAAIE,KAAK,CAAC,yBAAyB,CAAC;EAC9C;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -48,7 +48,7 @@ const convertToTime = value => {
|
|
|
48
48
|
} = parseTime(value);
|
|
49
49
|
return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
|
|
50
50
|
};
|
|
51
|
-
const TimeScalar = new _graphql.GraphQLScalarType({
|
|
51
|
+
const TimeScalar = exports.TimeScalar = new _graphql.GraphQLScalarType({
|
|
52
52
|
name: "Time",
|
|
53
53
|
description: "A custom type to support time-only input.",
|
|
54
54
|
// sending to client
|
|
@@ -56,6 +56,5 @@ const TimeScalar = new _graphql.GraphQLScalarType({
|
|
|
56
56
|
// received from client
|
|
57
57
|
parseValue: convertToTime
|
|
58
58
|
});
|
|
59
|
-
exports.TimeScalar = TimeScalar;
|
|
60
59
|
|
|
61
60
|
//# sourceMappingURL=TimeScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","_error","_interopRequireDefault","re","parseTime","value","match","WebinyError","parsed","split","map","Number","length","hours","minutes","seconds","convertToTime","String","padStart","TimeScalar","GraphQLScalarType","name","description","serialize","parseValue"
|
|
1
|
+
{"version":3,"names":["_graphql","require","_error","_interopRequireDefault","re","parseTime","value","match","WebinyError","parsed","split","map","Number","length","hours","minutes","seconds","convertToTime","String","padStart","TimeScalar","exports","GraphQLScalarType","name","description","serialize","parseValue"],"sources":["TimeScalar.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\nimport WebinyError from \"@webiny/error\";\n\nconst re = /^([0-9]{2}):([0-9]{2})(:([0-9]{2}))?$/;\n\nconst parseTime = (value?: string) => {\n if (!value || value.match(re) === null) {\n throw new WebinyError(\"Value does not look like time.\", \"TIME_VALIDATION_ERROR\", { value });\n }\n const parsed = value.split(\":\").map(Number);\n if (parsed.length < 2) {\n throw new WebinyError(`Could not parse the value.`, \"TIME_VALIDATION_ERROR\", { value });\n }\n const [hours, minutes, seconds = 0] = parsed;\n if (hours >= 24) {\n throw new WebinyError(`There cannot be more than 24 hours.`, \"TIME_VALIDATION_ERROR\", {\n value\n });\n } else if (minutes >= 60) {\n throw new WebinyError(`There cannot be more than 59 minutes.`, \"TIME_VALIDATION_ERROR\", {\n value\n });\n } else if (seconds >= 60) {\n throw new WebinyError(`There cannot be more than 59 seconds.`, \"TIME_VALIDATION_ERROR\", {\n value\n });\n }\n return {\n hours,\n minutes,\n seconds\n };\n};\n\nconst convertToTime = (value: string): string => {\n const { hours, minutes, seconds } = parseTime(value);\n return `${String(hours).padStart(2, \"0\")}:${String(minutes).padStart(2, \"0\")}:${String(\n seconds\n ).padStart(2, \"0\")}`;\n};\n\nexport const TimeScalar = new GraphQLScalarType({\n name: \"Time\",\n description: \"A custom type to support time-only input.\",\n // sending to client\n serialize: convertToTime,\n // received from client\n parseValue: convertToTime\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,MAAMG,EAAE,GAAG,uCAAuC;AAElD,MAAMC,SAAS,GAAIC,KAAc,IAAK;EAClC,IAAI,CAACA,KAAK,I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M,CAClFF,OACJ,CAAC,CAACG,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAE,EAAC;AACxB,CAAC;AAEM,MAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,IAAIE,0BAAiB,CAAC;EAC5CC,IAAI,EAAE,MAAM;EACZC,WAAW,EAAE,2CAA2C;EACxD;EACAC,SAAS,EAAER,aAAa;EACxB;EACAS,UAAU,EAAET;AAChB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_AnyScalar","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_DateScalar","_DateTimeScalar","_DateTimeZScalar","_JsonScalar","_LongScalar","_NumberScalar","_RefInputScalar","_TimeScalar"],"sources":["index.ts"],"sourcesContent":["export * from \"./AnyScalar\";\nexport * from \"./DateScalar\";\nexport * from \"./DateTimeScalar\";\nexport * from \"./DateTimeZScalar\";\nexport * from \"./JsonScalar\";\nexport * from \"./LongScalar\";\nexport * from \"./NumberScalar\";\nexport * from \"./RefInputScalar\";\nexport * from \"./TimeScalar\";\n"],"mappings":";;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,UAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,UAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,UAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,WAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,WAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,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GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAY,WAAA,CAAAZ,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAQ,WAAA,CAAAZ,GAAA;IAAA;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"names":["_AnyScalar","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_DateScalar","_DateTimeScalar","_DateTimeZScalar","_JsonScalar","_LongScalar","_NumberScalar","_RefInputScalar","_TimeScalar"],"sources":["index.ts"],"sourcesContent":["export * from \"./AnyScalar\";\nexport * from \"./DateScalar\";\nexport * from \"./DateTimeScalar\";\nexport * from \"./DateTimeZScalar\";\nexport * from \"./JsonScalar\";\nexport * from \"./LongScalar\";\nexport * from \"./NumberScalar\";\nexport * from \"./RefInputScalar\";\nexport * from \"./TimeScalar\";\n"],"mappings":";;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,UAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,UAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,UAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,WAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,WAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,WAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,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OAAA,CAAAD,GAAA,MAAAY,WAAA,CAAAZ,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAQ,WAAA,CAAAZ,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/createGraphQLHandler.js
CHANGED
|
@@ -10,7 +10,7 @@ var _handler = require("@webiny/handler");
|
|
|
10
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
11
|
var _createGraphQLSchema = require("./createGraphQLSchema");
|
|
12
12
|
var _debugPlugins = _interopRequireDefault(require("./debugPlugins"));
|
|
13
|
-
var _processRequestBody =
|
|
13
|
+
var _processRequestBody = require("./processRequestBody");
|
|
14
14
|
const DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year
|
|
15
15
|
|
|
16
16
|
const createCacheKey = context => {
|
|
@@ -84,7 +84,7 @@ var _default = (options = {}) => {
|
|
|
84
84
|
throw ex;
|
|
85
85
|
}
|
|
86
86
|
try {
|
|
87
|
-
const result = await (0, _processRequestBody.
|
|
87
|
+
const result = await (0, _processRequestBody.processRequestBody)(body, schema, context);
|
|
88
88
|
return reply.status(200).send(result);
|
|
89
89
|
} catch (ex) {
|
|
90
90
|
console.error(`Error while processing the body request.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_boolean","require","_handler","_error","_interopRequireDefault","_createGraphQLSchema","_debugPlugins","_processRequestBody","DEFAULT_CACHE_MAX_AGE","createCacheKey","context","plugins","getSchemaPlugins","tenant","tenancy","getCurrentTenant","contentLocale","i18n","getContentLocale","id","code","length","toString","filter","Boolean","join","createRequestBody","body","JSON","parse","formatErrorPayload","error","WebinyError","stringify","type","message","data","name","stack","_default","options","schema","undefined","cacheKey","debug","boolean","path","route","RoutePlugin","onPost","onOptions","_","reply","status","headers","send","hijack","request","contextCacheKey","createGraphQLSchema","ex","console","result","processRequestBody","debugPlugins","exports","default"],"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, getSchemaPlugins } from \"./createGraphQLSchema\";\nimport debugPlugins from \"./debugPlugins\";\nimport
|
|
1
|
+
{"version":3,"names":["_boolean","require","_handler","_error","_interopRequireDefault","_createGraphQLSchema","_debugPlugins","_processRequestBody","DEFAULT_CACHE_MAX_AGE","createCacheKey","context","plugins","getSchemaPlugins","tenant","tenancy","getCurrentTenant","contentLocale","i18n","getContentLocale","id","code","length","toString","filter","Boolean","join","createRequestBody","body","JSON","parse","formatErrorPayload","error","WebinyError","stringify","type","message","data","name","stack","_default","options","schema","undefined","cacheKey","debug","boolean","path","route","RoutePlugin","onPost","onOptions","_","reply","status","headers","send","hijack","request","contextCacheKey","createGraphQLSchema","ex","console","result","processRequestBody","debugPlugins","exports","default"],"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 { Context } from \"@webiny/handler\";\nimport { GraphQLRequestBody, HandlerGraphQLOptions } from \"./types\";\nimport { createGraphQLSchema, getSchemaPlugins } from \"./createGraphQLSchema\";\nimport debugPlugins from \"./debugPlugins\";\nimport { processRequestBody } from \"./processRequestBody\";\n\nconst DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year\n\nconst createCacheKey = (context: Context) => {\n const plugins = getSchemaPlugins(context);\n // TODO: in the near future, we have to assign a fixed name to every\n // TODO: GraphQLSchema plugin, to be able to create a reliable cache key.\n\n // TODO: `getCurrentTenant` should be injected as a parameter.\n // @ts-expect-error TODO: We should not be accessing `context` like this here.\n const tenant = context.tenancy?.getCurrentTenant();\n\n // TODO: `getContentLocale` should be injected as a parameter.\n // @ts-expect-error TODO: We should not be accessing `context` like this here.\n const contentLocale = context.i18n?.getContentLocale();\n\n return [\n tenant ? `tenant:${tenant.id}` : null,\n contentLocale ? `locale:${contentLocale.code}` : null,\n plugins.length.toString()\n ]\n .filter(Boolean)\n .join(\"#\");\n};\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 let cacheKey: string | 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 const contextCacheKey = createCacheKey(context as Context);\n if (!schema || cacheKey !== contextCacheKey) {\n try {\n schema = createGraphQLSchema(context);\n cacheKey = contextCacheKey;\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: \"wcp-telemetry-tracker\"\n },\n route\n ];\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAIA,IAAAI,oBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AAEA,MAAMO,qBAAqB,GAAG,QAAQ,CAAC,CAAC;;AAExC,MAAMC,cAAc,GAAIC,OAAgB,IAAK;EACzC,MAAMC,OAAO,GAAG,IAAAC,qCAAgB,EAACF,OAAO,CAAC;EACzC;EACA;;EAEA;EACA;EACA,MAAMG,MAAM,GAAGH,OAAO,CAACI,OAAO,EAAEC,gBAAgB,CAAC,CAAC;;EAElD;EACA;EACA,MAAMC,aAAa,GAAGN,OAAO,CAACO,IAAI,EAAEC,gBAAgB,CAAC,CAAC;EAEtD,OAAO,CACHL,MAAM,GAAI,UAASA,MAAM,CAACM,EAAG,EAAC,GAAG,IAAI,EACrCH,aAAa,GAAI,UAASA,aAAa,CAACI,IAAK,EAAC,GAAG,IAAI,EACrDT,OAAO,CAACU,MAAM,CAACC,QAAQ,CAAC,CAAC,CAC5B,CACIC,MAAM,CAACC,OAAO,CAAC,CACfC,IAAI,CAAC,GAAG,CAAC;AAClB,CAAC;AAED,MAAMC,iBAAiB,GAAIC,IAAa,IAAgD;EACpF;AACJ;AACA;AACA;EACI,OAAO,OAAOA,IAAI,KAAK,QAAQ,GAAGC,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC,GAAGA,IAAI;AAC7D,CAAC;AAED,MAAMG,kBAAkB,GAAIC,KAAY,IAAa;EACjD,IAAIA,KAAK,YAAYC,cAAW,EAAE;IAC9B,O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lugins","context","plugins","byType","exports","createGraphQLSchema","scalars","map","item","scalar","typeDefs","gql","name","join","resolvers","reduce","acc","s","JSON","JsonScalar","Long","LongScalar","RefInput","RefInputScalar","Number","NumberScalar","Any","AnyScalar","DateTime","DateTimeScalar","Date","DateScalar","Time","TimeScalar","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 RefInputScalar,\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 getSchemaPlugins = (context: Context) => {\n return context.plugins.byType<GraphQLSchemaPlugin>(\"graphql-schema\");\n};\n\nexport const createGraphQLSchema = (context: Context) => {\n const scalars = context.plugins\n .byType<GraphQLScalarPlugin>(\"graphql-scalar\")\n .map(item => item.scalar);\n\n // TODO: once the API packages more closed, we'll have the opportunity\n // TODO: to maybe import the @ps directive from `api-prerendering-service` package.\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 # This directive doesn't do anything on the GraphQL resolution level. It just serves\n # as a way to tell the Prerendering Service whether the GraphQL query needs to be\n # cached or not.\n directive @ps(cache: Boolean) on QUERY\n `\n ];\n\n const resolvers = [\n {\n ...scalars.reduce<Record<string, GraphQLScalarType>>((acc, s) => {\n acc[s.name] = s;\n return acc;\n }, {}),\n JSON: JsonScalar,\n Long: LongScalar,\n RefInput: RefInputScalar,\n Number: NumberScalar,\n Any: AnyScalar,\n DateTime: DateTimeScalar,\n Date: DateScalar,\n Time: TimeScalar\n }\n ];\n\n const plugins = getSchemaPlugins(context);\n for (const plugin of plugins) {\n /**\n * TODO @ts-refactor\n * Figure out correct types on typeDefs and resolvers\n */\n // @ts-expect-error\n typeDefs.push(plugin.schema.typeDefs);\n // @ts-expect-error\n resolvers.push(plugin.schema.resolvers);\n }\n\n return makeExecutableSchema({\n typeDefs,\n resolvers,\n inheritResolversFromInterfaces: true\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAGA,IAAAE,aAAA,GAAAF,OAAA;AAYO,MAAMG,gBAAgB,GAAIC,OAAgB,IAAK;EAClD,OAAOA,OAAO,CAACC,OAAO,CAACC,MAAM,CAAsB,gBAAgB,CAAC;AACxE,CAAC;AAACC,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA;AAEK,MAAMK,mBAAmB,GAAIJ,OAAgB,IAAK;EACrD,MAAMK,OAAO,GAAGL,OAAO,CAACC,OAAO,CAC1BC,MAAM,CAAsB,gBAAgB,CAAC,CAC7CI,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,MAAM,CAAC;;EAE7B;EACA;EACA,MAAMC,QAAQ,GAAG,CACb,IAAAC,mBAAG,CAAC;AACZ;AACA;AACA,cAAcL,OAAO,CAACC,GAAG,CAACE,MAAM,IAAK,UAASA,MAAM,CAACG,IAAK,EAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CACJ;EAED,MAAMC,SAAS,GAAG,CACd;IACI,GAAGR,OAAO,CAACS,MAAM,CAAoC,CAACC,GAAG,EAAEC,CAAC,KAAK;MAC7DD,GAAG,CAACC,CAAC,CAACL,IAAI,CAAC,GAAGK,CAAC;MACf,OAAOD,GAAG;IACd,CAAC,EAAE,CAAC,CAAC,CAAC;IACNE,IAAI,EAAEC,wBAAU;IAChBC,IAAI,EAAEC,wBAAU;IAChBC,QAAQ,EAAEC,4BAAc;IACxBC,MAAM,EAAEC,0BAAY;IACpBC,GAAG,EAAEC,uBAAS;IACdC,QAAQ,EAAEC,4BAAc;IACxBC,IAAI,EAAEC,wBAAU;IAChBC,IAAI,EAAEC;EACV,CAAC,CACJ;EAED,MAAM/B,OAAO,GAAGF,gBAAgB,CAACC,OAAO,CAAC;EACzC,KAAK,MAAMiC,MAAM,IAAIhC,OAAO,EAAE;IAC1B;AACR;AACA;AACA;IACQ;IACAQ,QAAQ,CAACyB,IAAI,CAACD,MAAM,CAACE,MAAM,CAAC1B,QAAQ,CAAC;IACrC;IACAI,SAAS,CAACqB,IAAI,CAACD,MAAM,CAACE,MAAM,CAACtB,SAAS,CAAC;EAC3C;EAEA,OAAO,IAAAuB,4BAAoB,EAAC;IACxB3B,QAAQ;IACRI,SAAS;IACTwB,8BAA8B,EAAE;EACpC,CAAC,CAAC;AACN,CAAC;AAAClC,OAAA,CAAAC,mBAAA,GAAAA,mBAAA"}
|
|
1
|
+
{"version":3,"names":["_graphqlTag","_interopRequireDefault","require","_schema","_builtInTypes","getSchemaPlugins","context","plugins","byType","exports","createGraphQLSchema","scalars","map","item","scalar","typeDefs","gql","name","join","resolvers","reduce","acc","s","JSON","JsonScalar","Long","LongScalar","RefInput","RefInputScalar","Number","NumberScalar","Any","AnyScalar","DateTime","DateTimeScalar","Date","DateScalar","Time","TimeScalar","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 RefInputScalar,\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 getSchemaPlugins = (context: Context) => {\n return context.plugins.byType<GraphQLSchemaPlugin>(\"graphql-schema\");\n};\n\nexport const createGraphQLSchema = (context: Context) => {\n const scalars = context.plugins\n .byType<GraphQLScalarPlugin>(\"graphql-scalar\")\n .map(item => item.scalar);\n\n // TODO: once the API packages more closed, we'll have the opportunity\n // TODO: to maybe import the @ps directive from `api-prerendering-service` package.\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 # This directive doesn't do anything on the GraphQL resolution level. It just serves\n # as a way to tell the Prerendering Service whether the GraphQL query needs to be\n # cached or not.\n directive @ps(cache: Boolean) on QUERY\n `\n ];\n\n const resolvers = [\n {\n ...scalars.reduce<Record<string, GraphQLScalarType>>((acc, s) => {\n acc[s.name] = s;\n return acc;\n }, {}),\n JSON: JsonScalar,\n Long: LongScalar,\n RefInput: RefInputScalar,\n Number: NumberScalar,\n Any: AnyScalar,\n DateTime: DateTimeScalar,\n Date: DateScalar,\n Time: TimeScalar\n }\n ];\n\n const plugins = getSchemaPlugins(context);\n for (const plugin of plugins) {\n /**\n * TODO @ts-refactor\n * Figure out correct types on typeDefs and resolvers\n */\n // @ts-expect-error\n typeDefs.push(plugin.schema.typeDefs);\n // @ts-expect-error\n resolvers.push(plugin.schema.resolvers);\n }\n\n return makeExecutableSchema({\n typeDefs,\n resolvers,\n inheritResolversFromInterfaces: true\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAGA,IAAAE,aAAA,GAAAF,OAAA;AAYO,MAAMG,gBAAgB,GAAIC,OAAgB,IAAK;EAClD,OAAOA,OAAO,CAACC,OAAO,CAACC,MAAM,CAAsB,gBAAgB,CAAC;AACxE,CAAC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AuB,4BAAoB,EAAC;IACxB3B,QAAQ;IACRI,SAAS;IACTwB,8BAA8B,EAAE;EACpC,CAAC,CAAC;AACN,CAAC;AAAClC,OAAA,CAAAC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
package/debugPlugins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_interceptConsole","require","_api","_default","ContextPlugin","context","debug","logs","interceptConsole","method","args","push","type","apply","result","console","length","exports","default"],"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,IAAAA,iBAAA,GAAAC,OAAA;AAGA,IAAAC,IAAA,GAAAD,OAAA;AAA4C,IAAAE,QAAA,GAY7BA,CAAA,KAAM,CACjB,IAAIC,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,KAAKA,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;AAAAC,OAAA,CAAAC,OAAA,GAAAf,QAAA"}
|
|
1
|
+
{"version":3,"names":["_interceptConsole","require","_api","_default","ContextPlugin","context","debug","logs","interceptConsole","method","args","push","type","apply","result","console","length","exports","default"],"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,IAAAA,iBAAA,GAAAC,OAAA;AAGA,IAAAC,IAAA,GAAAD,OAAA;AAA4C,IAAAE,QAAA,GAY7BA,CAAA,KAAM,CACjB,IAAIC,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,KAAKA,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;AAAAC,OAAA,CAAAC,OAAA,GAAAf,QAAA","ignoreList":[]}
|
package/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","NotFoundError","WebinyError","constructor","message","exports"],"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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,aAAa,SAASC,cAAW,CAAC;EAC3CC,WAAWA,CAACC,OAAO,GAAG,YAAY,EAAE;IAChC,KAAK,CAACA,OAAO,EAAE,WAAW,CAAC;EAC/B;AACJ;AAACC,OAAA,CAAAJ,aAAA,GAAAA,aAAA"}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","NotFoundError","WebinyError","constructor","message","exports"],"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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,aAAa,SAASC,cAAW,CAAC;EAC3CC,WAAWA,CAACC,OAAO,GAAG,YAAY,EAAE;IAChC,KAAK,CAACA,OAAO,EAAE,WAAW,CAAC;EAC/B;AACJ;AAACC,OAAA,CAAAJ,aAAA,GAAAA,aAAA","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import { HandlerGraphQLOptions } from "./types";
|
|
|
2
2
|
export * from "./errors";
|
|
3
3
|
export * from "./responses";
|
|
4
4
|
export * from "./plugins";
|
|
5
|
-
export
|
|
5
|
+
export * from "./processRequestBody";
|
|
6
6
|
declare const _default: (options?: HandlerGraphQLOptions) => import("@webiny/plugins/types").PluginCollection[];
|
|
7
7
|
export default _default;
|
package/index.js
CHANGED
|
@@ -4,16 +4,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
var _exportNames = {
|
|
8
|
-
processRequestBody: true
|
|
9
|
-
};
|
|
7
|
+
var _exportNames = {};
|
|
10
8
|
exports.default = void 0;
|
|
11
|
-
Object.defineProperty(exports, "processRequestBody", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () {
|
|
14
|
-
return _processRequestBody.default;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
9
|
var _createGraphQLHandler = _interopRequireDefault(require("./createGraphQLHandler"));
|
|
18
10
|
var _errors = require("./errors");
|
|
19
11
|
Object.keys(_errors).forEach(function (key) {
|
|
@@ -51,7 +43,18 @@ Object.keys(_plugins).forEach(function (key) {
|
|
|
51
43
|
}
|
|
52
44
|
});
|
|
53
45
|
});
|
|
54
|
-
var _processRequestBody =
|
|
46
|
+
var _processRequestBody = require("./processRequestBody");
|
|
47
|
+
Object.keys(_processRequestBody).forEach(function (key) {
|
|
48
|
+
if (key === "default" || key === "__esModule") return;
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
50
|
+
if (key in exports && exports[key] === _processRequestBody[key]) return;
|
|
51
|
+
Object.defineProperty(exports, key, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return _processRequestBody[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
55
58
|
var _default = (options = {}) => [(0, _createGraphQLHandler.default)(options)];
|
|
56
59
|
exports.default = _default;
|
|
57
60
|
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_createGraphQLHandler","_interopRequireDefault","require","_errors","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_responses","_plugins","_processRequestBody","_default","options","createGraphQLHandler","default"],"sources":["index.ts"],"sourcesContent":["import { HandlerGraphQLOptions } from \"./types\";\nimport createGraphQLHandler from \"./createGraphQLHandler\";\n\nexport * from \"./errors\";\nexport * from \"./responses\";\nexport * from \"./plugins\";\nexport
|
|
1
|
+
{"version":3,"names":["_createGraphQLHandler","_interopRequireDefault","require","_errors","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_responses","_plugins","_processRequestBody","_default","options","createGraphQLHandler","default"],"sources":["index.ts"],"sourcesContent":["import { HandlerGraphQLOptions } from \"./types\";\nimport createGraphQLHandler from \"./createGraphQLHandler\";\n\nexport * from \"./errors\";\nexport * from \"./responses\";\nexport * from \"./plugins\";\nexport * from \"./processRequestBody\";\n\nexport default (options: HandlerGraphQLOptions = {}) => [createGraphQLHandler(options)];\n"],"mappings":";;;;;;;;AACA,IAAAA,qBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,UAAA,GAAAd,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAW,UAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,UAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,UAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AACA,IAAAU,QAAA,GAAAf,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAY,QAAA,EAAAX,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAU,QAAA,CAAAV,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,QAAA,CAAAV,GAAA;IAAA;EAAA;AAAA;AACA,IAAAW,mBAAA,GAAAhB,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAa,mBAAA,EAAAZ,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAW,mBAAA,CAAAX,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,mBAAA,CAAAX,GAAA;IAAA;EAAA;AAAA;AAAqC,IAAAY,QAAA,GAEtBA,CAACC,OAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,IAAAC,6BAAoB,EAACD,OAAO,CAAC,CAAC;AAAAR,OAAA,CAAAU,OAAA,GAAAH,QAAA","ignoreList":[]}
|
package/interceptConsole.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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"}
|
|
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","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/handler-graphql",
|
|
3
|
-
"version": "5.40.0-beta.
|
|
3
|
+
"version": "5.40.0-beta.3",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -14,27 +14,27 @@
|
|
|
14
14
|
"Adrian Smijulj <adrian@webiny.com>"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@babel/runtime": "7.
|
|
17
|
+
"@babel/runtime": "7.24.1",
|
|
18
18
|
"@graphql-tools/schema": "7.1.5",
|
|
19
|
-
"@webiny/api": "5.40.0-beta.
|
|
20
|
-
"@webiny/error": "5.40.0-beta.
|
|
21
|
-
"@webiny/handler": "5.40.0-beta.
|
|
22
|
-
"@webiny/plugins": "5.40.0-beta.
|
|
19
|
+
"@webiny/api": "5.40.0-beta.3",
|
|
20
|
+
"@webiny/error": "5.40.0-beta.3",
|
|
21
|
+
"@webiny/handler": "5.40.0-beta.3",
|
|
22
|
+
"@webiny/plugins": "5.40.0-beta.3",
|
|
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": "7.
|
|
30
|
-
"@babel/core": "7.
|
|
31
|
-
"@babel/preset-env": "7.
|
|
32
|
-
"@webiny/cli": "5.40.0-beta.
|
|
33
|
-
"@webiny/handler-aws": "5.40.0-beta.
|
|
34
|
-
"@webiny/project-utils": "5.40.0-beta.
|
|
35
|
-
"jest": "29.
|
|
29
|
+
"@babel/cli": "7.24.1",
|
|
30
|
+
"@babel/core": "7.24.3",
|
|
31
|
+
"@babel/preset-env": "7.24.3",
|
|
32
|
+
"@webiny/cli": "5.40.0-beta.3",
|
|
33
|
+
"@webiny/handler-aws": "5.40.0-beta.3",
|
|
34
|
+
"@webiny/project-utils": "5.40.0-beta.3",
|
|
35
|
+
"jest": "29.7.0",
|
|
36
36
|
"jest-mock-console": "1.3.0",
|
|
37
|
-
"rimraf": "
|
|
37
|
+
"rimraf": "5.0.5",
|
|
38
38
|
"ttypescript": "1.5.15",
|
|
39
39
|
"typescript": "4.7.4"
|
|
40
40
|
},
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"build": "yarn webiny run build",
|
|
47
47
|
"watch": "yarn webiny run watch"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "638d8b84063906cd1aa979ed6e0487ad26fbcf2f"
|
|
50
50
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
2
|
import { GraphQLSchemaDefinition, Resolvers, Types } from "../types";
|
|
3
3
|
import { Context } from "@webiny/api/types";
|
|
4
|
+
export interface IGraphQLSchemaPlugin<TContext = Context> extends Plugin {
|
|
5
|
+
schema: GraphQLSchemaDefinition<TContext>;
|
|
6
|
+
}
|
|
4
7
|
export interface GraphQLSchemaPluginConfig<TContext> {
|
|
5
8
|
typeDefs?: Types;
|
|
6
9
|
resolvers?: Resolvers<TContext>;
|
|
7
10
|
}
|
|
8
|
-
export declare class GraphQLSchemaPlugin<TContext = Context> extends Plugin {
|
|
11
|
+
export declare class GraphQLSchemaPlugin<TContext = Context> extends Plugin implements IGraphQLSchemaPlugin<TContext> {
|
|
9
12
|
static readonly type: string;
|
|
10
|
-
|
|
13
|
+
protected config: GraphQLSchemaPluginConfig<TContext>;
|
|
11
14
|
constructor(config: GraphQLSchemaPluginConfig<TContext>);
|
|
12
15
|
get schema(): GraphQLSchemaDefinition<TContext>;
|
|
13
16
|
}
|
|
17
|
+
export declare const createGraphQLSchemaPlugin: <T = Context>(config: GraphQLSchemaPluginConfig<T>) => GraphQLSchemaPlugin<T>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.GraphQLSchemaPlugin = void 0;
|
|
6
|
+
exports.createGraphQLSchemaPlugin = exports.GraphQLSchemaPlugin = void 0;
|
|
7
7
|
var _plugins = require("@webiny/plugins");
|
|
8
8
|
class GraphQLSchemaPlugin extends _plugins.Plugin {
|
|
9
9
|
static type = "graphql-schema";
|
|
@@ -19,5 +19,9 @@ class GraphQLSchemaPlugin extends _plugins.Plugin {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
exports.GraphQLSchemaPlugin = GraphQLSchemaPlugin;
|
|
22
|
+
const createGraphQLSchemaPlugin = config => {
|
|
23
|
+
return new GraphQLSchemaPlugin(config);
|
|
24
|
+
};
|
|
25
|
+
exports.createGraphQLSchemaPlugin = createGraphQLSchemaPlugin;
|
|
22
26
|
|
|
23
27
|
//# sourceMappingURL=GraphQLSchemaPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
1
|
+
{"version":3,"names":["_plugins","require","GraphQLSchemaPlugin","Plugin","type","constructor","config","schema","typeDefs","resolvers","exports","createGraphQLSchemaPlugin"],"sources":["GraphQLSchemaPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { GraphQLSchemaDefinition, Resolvers, Types } from \"~/types\";\nimport { Context } from \"@webiny/api/types\";\n\nexport interface IGraphQLSchemaPlugin<TContext = Context> extends Plugin {\n schema: GraphQLSchemaDefinition<TContext>;\n}\n\nexport interface GraphQLSchemaPluginConfig<TContext> {\n typeDefs?: Types;\n resolvers?: Resolvers<TContext>;\n}\n\nexport class GraphQLSchemaPlugin<TContext = Context>\n extends Plugin\n implements IGraphQLSchemaPlugin<TContext>\n{\n public static override readonly type: string = \"graphql-schema\";\n protected 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\nexport const createGraphQLSchemaPlugin = <T = Context>(config: GraphQLSchemaPluginConfig<T>) => {\n return new GraphQLSchemaPlugin<T>(config);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAaO,MAAMC,mBAAmB,SACpBC,eAAM,CAElB;EACI,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;AAEM,MAAMS,yBAAyB,GAAiBL,MAAoC,IAAK;EAC5F,OAAO,IAAIJ,mBAAmB,CAAII,MAAM,CAAC;AAC7C,CAAC;AAACI,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
package/plugins/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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"}
|
|
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","ignoreList":[]}
|
package/processRequestBody.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ExecutionResult, GraphQLSchema } from "graphql";
|
|
2
2
|
import { GraphQLRequestBody } from "./types";
|
|
3
3
|
import { Context } from "@webiny/api/types";
|
|
4
|
-
declare const
|
|
5
|
-
export default _default;
|
|
4
|
+
export declare const processRequestBody: <TData = Record<string, any>, TExtensions = Record<string, any>>(requestBody: GraphQLRequestBody | GraphQLRequestBody[], schema: GraphQLSchema, context: Context) => Promise<ExecutionResult<TData, TExtensions> | ExecutionResult<TData, TExtensions>[]>;
|
package/processRequestBody.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.processRequestBody = void 0;
|
|
7
7
|
var _graphql = require("graphql");
|
|
8
|
-
const
|
|
8
|
+
const executeGraphQl = async (body, schema, context) => {
|
|
9
9
|
const {
|
|
10
10
|
query,
|
|
11
11
|
variables,
|
|
@@ -27,17 +27,17 @@ const processRequestBody = async (body, schema, context) => {
|
|
|
27
27
|
});
|
|
28
28
|
return result;
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
const processRequestBody = async (requestBody, schema, context) => {
|
|
31
31
|
if (Array.isArray(requestBody)) {
|
|
32
32
|
const results = [];
|
|
33
33
|
for (const body of requestBody) {
|
|
34
|
-
const result = await
|
|
34
|
+
const result = await executeGraphQl(body, schema, context);
|
|
35
35
|
results.push(result);
|
|
36
36
|
}
|
|
37
37
|
return results;
|
|
38
38
|
}
|
|
39
|
-
return await
|
|
39
|
+
return await executeGraphQl(requestBody, schema, context);
|
|
40
40
|
};
|
|
41
|
-
exports.
|
|
41
|
+
exports.processRequestBody = processRequestBody;
|
|
42
42
|
|
|
43
43
|
//# sourceMappingURL=processRequestBody.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","
|
|
1
|
+
{"version":3,"names":["_graphql","require","executeGraphQl","body","schema","context","query","variables","operationName","plugins","byType","forEach","pl","apply","result","graphql","processRequestBody","requestBody","Array","isArray","results","push","exports"],"sources":["processRequestBody.ts"],"sourcesContent":["import { ExecutionResult, graphql, GraphQLSchema } from \"graphql\";\nimport { GraphQLAfterQueryPlugin, GraphQLBeforeQueryPlugin, GraphQLRequestBody } from \"~/types\";\nimport { Context } from \"@webiny/api/types\";\n\nconst executeGraphQl = 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 const processRequestBody = async <\n TData = Record<string, any>,\n TExtensions = Record<string, any>\n>(\n requestBody: GraphQLRequestBody | GraphQLRequestBody[],\n schema: GraphQLSchema,\n context: Context\n): Promise<ExecutionResult<TData, TExtensions>[] | ExecutionResult<TData, TExtensions>> => {\n if (Array.isArray(requestBody)) {\n const results: ExecutionResult<TData, TExtensions>[] = [];\n for (const body of requestBody) {\n const result = await executeGraphQl(body, schema, context);\n results.push(result as ExecutionResult<TData, TExtensions>);\n }\n return results;\n }\n return (await executeGraphQl(requestBody, schema, context)) as ExecutionResult<\n TData,\n TExtensions\n >;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAIA,MAAMC,cAAc,GAAG,MAAAA,CACnBC,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;AAEM,MAAME,kBAAkB,GAAG,MAAAA,CAI9BC,WAAsD,EACtDb,MAAqB,EACrBC,OAAgB,KACuE;EACvF,IAAIa,KAAK,CAACC,OAAO,CAACF,WAAW,CAAC,EAAE;IAC5B,MAAMG,OAA8C,GAAG,EAAE;IACzD,KAAK,MAAMjB,IAAI,IAAIc,WAAW,EAAE;MAC5B,MAAMH,MAAM,GAAG,MAAMZ,cAAc,CAACC,IAAI,EAAEC,MAAM,EAAEC,OAAO,CAAC;MAC1De,OAAO,CAACC,IAAI,CAACP,MAA6C,CAAC;IAC/D;IACA,OAAOM,OAAO;EAClB;EACA,OAAQ,MAAMlB,cAAc,CAACe,WAAW,EAAEb,MAAM,EAAEC,OAAO,CAAC;AAI9D,CAAC;AAACiB,OAAA,CAAAN,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
package/responses.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,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,"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":";;;;;;AA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K,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","ignoreList":[]}
|
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[] | (() => 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":""}
|
|
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":"","ignoreList":[]}
|