@webiny/handler-graphql 5.39.0-beta.1 → 5.39.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/DateScalar.js +3 -4
- package/builtInTypes/DateScalar.js.map +1 -1
- package/builtInTypes/DateTimeScalar.js +3 -4
- package/builtInTypes/DateTimeScalar.js.map +1 -1
- package/builtInTypes/LongScalar.js +2 -3
- package/builtInTypes/LongScalar.js.map +1 -1
- package/builtInTypes/NumberScalar.js +3 -4
- package/builtInTypes/NumberScalar.js.map +1 -1
- package/builtInTypes/RefInputScalar.js +1 -1
- package/builtInTypes/RefInputScalar.js.map +1 -1
- package/createGraphQLHandler.js +7 -8
- package/createGraphQLHandler.js.map +1 -1
- package/createGraphQLSchema.js +8 -8
- package/createGraphQLSchema.js.map +1 -1
- package/interceptConsole.js +5 -5
- package/interceptConsole.js.map +1 -1
- package/package.json +9 -9
- package/plugins/GraphQLSchemaPlugin.js +1 -4
- package/plugins/GraphQLSchemaPlugin.js.map +1 -1
- package/responses.js +0 -12
- package/responses.js.map +1 -1
- package/types.d.ts +1 -1
- package/types.js.map +1 -1
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.DateScalar = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
7
|
var _graphqlScalars = require("graphql-scalars");
|
|
10
8
|
var _graphql = require("graphql");
|
|
11
|
-
const DateScalar = new _graphql.GraphQLScalarType(
|
|
9
|
+
const DateScalar = new _graphql.GraphQLScalarType({
|
|
10
|
+
..._graphqlScalars.DateResolver,
|
|
12
11
|
serialize: value => {
|
|
13
12
|
if (!value) {
|
|
14
13
|
return null;
|
|
@@ -23,7 +22,7 @@ const DateScalar = new _graphql.GraphQLScalarType((0, _objectSpread2.default)((0
|
|
|
23
22
|
throw ex;
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
})
|
|
25
|
+
});
|
|
27
26
|
exports.DateScalar = DateScalar;
|
|
28
27
|
|
|
29
28
|
//# sourceMappingURL=DateScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphqlScalars","require","_graphql","DateScalar","GraphQLScalarType","
|
|
1
|
+
{"version":3,"names":["_graphqlScalars","require","_graphql","DateScalar","GraphQLScalarType","DateResolver","serialize","value","date","Date","toISOString","slice","ex","exports"],"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,GAAG,IAAIC,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;AAACC,OAAA,CAAAV,UAAA,GAAAA,UAAA"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.DateTimeScalar = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
7
|
var _graphqlScalars = require("graphql-scalars");
|
|
10
8
|
var _graphql = require("graphql");
|
|
11
|
-
const DateTimeScalar = new _graphql.GraphQLScalarType(
|
|
9
|
+
const DateTimeScalar = new _graphql.GraphQLScalarType({
|
|
10
|
+
..._graphqlScalars.DateTimeResolver,
|
|
12
11
|
serialize: value => {
|
|
13
12
|
if (!value) {
|
|
14
13
|
return null;
|
|
@@ -23,7 +22,7 @@ const DateTimeScalar = new _graphql.GraphQLScalarType((0, _objectSpread2.default
|
|
|
23
22
|
throw ex;
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
})
|
|
25
|
+
});
|
|
27
26
|
exports.DateTimeScalar = DateTimeScalar;
|
|
28
27
|
|
|
29
28
|
//# sourceMappingURL=DateTimeScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphqlScalars","require","_graphql","DateTimeScalar","GraphQLScalarType","
|
|
1
|
+
{"version":3,"names":["_graphqlScalars","require","_graphql","DateTimeScalar","GraphQLScalarType","DateTimeResolver","serialize","value","date","Date","toISOString","ex","exports"],"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,GAAG,IAAIC,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;AAACC,OAAA,CAAAT,cAAA,GAAAA,cAAA"}
|
|
@@ -46,11 +46,10 @@ const LongScalar = new _graphql.GraphQLScalarType({
|
|
|
46
46
|
},
|
|
47
47
|
parseValue,
|
|
48
48
|
parseLiteral: ast => {
|
|
49
|
-
const value = ast.value;
|
|
50
49
|
if (ast.kind === _language.Kind.INT) {
|
|
51
|
-
return parseInt(value);
|
|
50
|
+
return parseInt(ast.value);
|
|
52
51
|
}
|
|
53
|
-
throw new Error(`Expected type Long, found {${
|
|
52
|
+
throw new Error(`Expected type Long, found {${ast.kind}}`);
|
|
54
53
|
}
|
|
55
54
|
});
|
|
56
55
|
exports.LongScalar = LongScalar;
|
|
@@ -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","exports"],"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
|
|
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","exports"],"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,GAAG,IAAIC,0BAAiB,CAAC;EAC5CC,IAAI,EAAE,MAAM;EACZC,WAAW,EAAE,2DAA2D;EACxEC,SAAS,EAAGX,KAAU,IAAK;IACvB,IAAI;MACA,OAAOD,UAAU,CAACC,KAAK,CAAC;IAC5B,CAAC,CAAC,OAAOY,EAAE,EAAE;MACTC,OAAO,CAACC,GAAG,CAAC;QACRC,OAAO,EAAE,gCAAgC;QACzCC,IAAI,EAAE,eAAe;QACrBC,IAAI,EAAE;UACFjB;QACJ;MACJ,CAAC,CAAC;MACF,OAAO,IAAI;IACf;EACJ,CAAC;EACDD,UAAU;EACVmB,YAAY,EAAEC,GAAG,IAAI;IACjB,IAAIA,GAAG,CAACC,IAAI,KAAKC,cAAI,CAACC,GAAG,EAAE;MACvB,OAAOhB,QAAQ,CAACa,GAAG,CAACnB,KAAK,CAAC;IAC9B;IAEA,MAAM,IAAIuB,KAAK,CAAE,8BAA6BJ,GAAG,CAACC,IAAK,GAAE,CAAC;EAC9D;AACJ,CAAC,CAAC;AAACI,OAAA,CAAAjB,UAAA,GAAAA,UAAA"}
|
|
@@ -43,13 +43,12 @@ const NumberScalar = new _graphql.GraphQLScalarType({
|
|
|
43
43
|
},
|
|
44
44
|
parseValue,
|
|
45
45
|
parseLiteral: ast => {
|
|
46
|
-
const value = ast.value;
|
|
47
46
|
if (ast.kind === _language.Kind.INT) {
|
|
48
|
-
return Number(value);
|
|
47
|
+
return Number(ast.value);
|
|
49
48
|
} else if (ast.kind === _language.Kind.FLOAT) {
|
|
50
|
-
return parseFloat(value);
|
|
49
|
+
return parseFloat(ast.value);
|
|
51
50
|
}
|
|
52
|
-
throw new Error(`Expected type Number, found {${
|
|
51
|
+
throw new Error(`Expected type Number, found {${ast.kind}}`);
|
|
53
52
|
}
|
|
54
53
|
});
|
|
55
54
|
exports.NumberScalar = NumberScalar;
|
|
@@ -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","exports"],"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
|
|
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","exports"],"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,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,CAACC,IAAI,KAAKC,cAAI,CAACG,KAAK,EAAE;MAChC,OAAOlB,UAAU,CAACa,GAAG,CAACnB,KAAK,CAAC;IAChC;IACA,MAAM,IAAIyB,KAAK,CAAE,gCAA+BN,GAAG,CAACC,IAAK,GAAE,CAAC;EAChE;AACJ,CAAC,CAAC;AAACM,OAAA,CAAAnB,YAAA,GAAAA,YAAA"}
|
|
@@ -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","exports"],"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-
|
|
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","exports"],"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!\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AK,QAAQ,EAAE;MAC3B,OAAOD,SAAS,CAACC,KAAK,CAAC;IAC3B;IAEA,IAAI,IAAI,IAAIA,KAAK,EAAE;MACf,OAAOD,SAAS,CAACC,KAAK,CAACS,EAAE,CAAC;IAC9B;IAEA,MAAM,IAAIP,KAAK,CAAC,yBAAyB,CAAC;EAC9C,CAAC;EACDS,YAAY,EAAEC,GAAG,IAAI;IACjB,IAAIA,GAAG,CAACC,IAAI,KAAK,aAAa,EAAE;MAC5B,OAAOd,SAAS,CAACa,GAAG,CAACZ,KAAK,CAAC;IAC/B;IAEA,IAAIY,GAAG,CAACC,IAAI,KAAK,aAAa,EAAE;MAC5B,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,GAAG,CAACG,MAAM,CAACd,MAAM,EAAEa,CAAC,EAAE,EAAE;QACxC,MAAM;UAAER,IAAI;UAAEN;QAAM,CAAC,GAAGY,GAAG,CAACG,MAAM,CAACD,CAAC,CAAC;QACrC,IAAIR,IAAI,CAACN,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;AAACc,OAAA,CAAAZ,cAAA,GAAAA,cAAA"}
|
package/createGraphQLHandler.js
CHANGED
|
@@ -14,18 +14,17 @@ var _processRequestBody = _interopRequireDefault(require("./processRequestBody")
|
|
|
14
14
|
const DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year
|
|
15
15
|
|
|
16
16
|
const createCacheKey = context => {
|
|
17
|
-
var _context$tenancy, _context$i18n;
|
|
18
17
|
const plugins = (0, _createGraphQLSchema.getSchemaPlugins)(context);
|
|
19
18
|
// TODO: in the near future, we have to assign a fixed name to every
|
|
20
19
|
// TODO: GraphQLSchema plugin, to be able to create a reliable cache key.
|
|
21
20
|
|
|
22
|
-
//
|
|
23
|
-
// @ts-
|
|
24
|
-
const tenant =
|
|
21
|
+
// TODO: `getCurrentTenant` should be injected as a parameter.
|
|
22
|
+
// @ts-expect-error TODO: We should not be accessing `context` like this here.
|
|
23
|
+
const tenant = context.tenancy?.getCurrentTenant();
|
|
25
24
|
|
|
26
|
-
//
|
|
27
|
-
// @ts-
|
|
28
|
-
const contentLocale =
|
|
25
|
+
// TODO: `getContentLocale` should be injected as a parameter.
|
|
26
|
+
// @ts-expect-error TODO: We should not be accessing `context` like this here.
|
|
27
|
+
const contentLocale = context.i18n?.getContentLocale();
|
|
29
28
|
return [tenant ? `tenant:${tenant.id}` : null, contentLocale ? `locale:${contentLocale.code}` : null, plugins.length.toString()].filter(Boolean).join("#");
|
|
30
29
|
};
|
|
31
30
|
const createRequestBody = body => {
|
|
@@ -55,7 +54,7 @@ var _default = (options = {}) => {
|
|
|
55
54
|
let schema = undefined;
|
|
56
55
|
let cacheKey = undefined;
|
|
57
56
|
const debug = (0, _boolean.boolean)(options.debug);
|
|
58
|
-
const path =
|
|
57
|
+
const path = options?.path || "/graphql";
|
|
59
58
|
const route = new _handler.RoutePlugin(async ({
|
|
60
59
|
onPost,
|
|
61
60
|
onOptions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_boolean","require","_handler","_error","_interopRequireDefault","_createGraphQLSchema","_debugPlugins","_processRequestBody","DEFAULT_CACHE_MAX_AGE","createCacheKey","context","
|
|
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 processRequestBody from \"./processRequestBody\";\nimport { Context } from \"@webiny/handler\";\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;AAGA,IAAAI,oBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,mBAAA,GAAAH,sBAAA,CAAAH,OAAA;AAGA,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;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ACC,MAAM,CAAC,GAAG,CAAC,CAACE,IAAI,CAACO,MAAM,CAAC;MACzC,CAAC,CAAC,OAAOF,EAAE,EAAE;QACTC,OAAO,CAAC9B,KAAK,CAAE,0CAAyC,CAAC;QACzD8B,OAAO,CAAC9B,KAAK,CAACD,kBAAkB,CAAC8B,EAAE,CAAC,CAAC;QACrC,MAAMA,EAAE;MACZ;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;EAEFb,KAAK,CAACV,IAAI,GAAG,+BAA+B;EAE5C,OAAO,CACH,IAAIO,KAAK,GAAG,IAAAoB,qBAAY,EAAC,CAAC,GAAG,EAAE,CAAC,EAChC;IACI9B,IAAI,EAAE;EACV,CAAC,EACDa,KAAK,CACR;AACL,CAAC;AAAAkB,OAAA,CAAAC,OAAA,GAAA3B,QAAA"}
|
package/createGraphQLSchema.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.getSchemaPlugins = exports.createGraphQLSchema = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
8
|
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
10
9
|
var _schema = require("@graphql-tools/schema");
|
|
11
10
|
var _builtInTypes = require("./builtInTypes");
|
|
@@ -36,10 +35,11 @@ const createGraphQLSchema = context => {
|
|
|
36
35
|
# cached or not.
|
|
37
36
|
directive @ps(cache: Boolean) on QUERY
|
|
38
37
|
`];
|
|
39
|
-
const resolvers = [
|
|
40
|
-
acc
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
const resolvers = [{
|
|
39
|
+
...scalars.reduce((acc, s) => {
|
|
40
|
+
acc[s.name] = s;
|
|
41
|
+
return acc;
|
|
42
|
+
}, {}),
|
|
43
43
|
JSON: _builtInTypes.JsonScalar,
|
|
44
44
|
Long: _builtInTypes.LongScalar,
|
|
45
45
|
RefInput: _builtInTypes.RefInputScalar,
|
|
@@ -48,16 +48,16 @@ const createGraphQLSchema = context => {
|
|
|
48
48
|
DateTime: _builtInTypes.DateTimeScalar,
|
|
49
49
|
Date: _builtInTypes.DateScalar,
|
|
50
50
|
Time: _builtInTypes.TimeScalar
|
|
51
|
-
}
|
|
51
|
+
}];
|
|
52
52
|
const plugins = getSchemaPlugins(context);
|
|
53
53
|
for (const plugin of plugins) {
|
|
54
54
|
/**
|
|
55
55
|
* TODO @ts-refactor
|
|
56
56
|
* Figure out correct types on typeDefs and resolvers
|
|
57
57
|
*/
|
|
58
|
-
// @ts-
|
|
58
|
+
// @ts-expect-error
|
|
59
59
|
typeDefs.push(plugin.schema.typeDefs);
|
|
60
|
-
// @ts-
|
|
60
|
+
// @ts-expect-error
|
|
61
61
|
resolvers.push(plugin.schema.resolvers);
|
|
62
62
|
}
|
|
63
63
|
return (0, _schema.makeExecutableSchema)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphqlTag","_interopRequireDefault","require","_schema","_builtInTypes","getSchemaPlugins","context","plugins","byType","exports","createGraphQLSchema","scalars","map","item","scalar","typeDefs","gql","name","join","resolvers","
|
|
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,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AI,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"}
|
package/interceptConsole.js
CHANGED
|
@@ -9,22 +9,22 @@ const originalMethods = {};
|
|
|
9
9
|
const skipOriginal = ["table"];
|
|
10
10
|
const restoreOriginalMethods = () => {
|
|
11
11
|
for (const method of consoleMethods) {
|
|
12
|
-
// @ts-
|
|
12
|
+
// @ts-expect-error
|
|
13
13
|
console[method] = originalMethods[method];
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
const interceptConsole = callback => {
|
|
17
|
-
// @ts-
|
|
17
|
+
// @ts-expect-error
|
|
18
18
|
if (console["__WEBINY__"] === true) {
|
|
19
19
|
restoreOriginalMethods();
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
// @ts-
|
|
22
|
+
// @ts-expect-error
|
|
23
23
|
console["__WEBINY__"] = true;
|
|
24
24
|
for (const method of consoleMethods) {
|
|
25
|
-
// @ts-
|
|
25
|
+
// @ts-expect-error
|
|
26
26
|
originalMethods[method] = console[method];
|
|
27
|
-
// @ts-
|
|
27
|
+
// @ts-expect-error
|
|
28
28
|
console[method] = (...args) => {
|
|
29
29
|
callback(method, args);
|
|
30
30
|
if (skipOriginal.includes(method)) {
|
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-
|
|
1
|
+
{"version":3,"names":["consoleMethods","originalMethods","skipOriginal","restoreOriginalMethods","method","console","interceptConsole","callback","args","includes","exports"],"sources":["interceptConsole.ts"],"sourcesContent":["const consoleMethods = [\n \"assert\",\n \"debug\",\n \"dir\",\n \"error\",\n \"group\",\n \"groupCollapsed\",\n \"groupEnd\",\n \"info\",\n \"log\",\n \"table\",\n \"warn\"\n];\n\nconst originalMethods: Record<string, any> = {};\nconst skipOriginal: string[] = [\"table\"];\n\nconst restoreOriginalMethods = () => {\n for (const method of consoleMethods) {\n // @ts-expect-error\n console[method] = originalMethods[method];\n }\n};\n\ninterface InterceptConsoleCallable {\n (method: string, args: any[]): void;\n}\n\nexport const interceptConsole = (callback: InterceptConsoleCallable) => {\n // @ts-expect-error\n if (console[\"__WEBINY__\"] === true) {\n restoreOriginalMethods();\n }\n\n // @ts-expect-error\n console[\"__WEBINY__\"] = true;\n\n for (const method of consoleMethods) {\n // @ts-expect-error\n originalMethods[method] = console[method];\n // @ts-expect-error\n console[method] = (...args) => {\n callback(method, args);\n if (skipOriginal.includes(method)) {\n return;\n }\n originalMethods[method](...args);\n };\n }\n};\n"],"mappings":";;;;;;AAAA,MAAMA,cAAc,GAAG,CACnB,QAAQ,EACR,OAAO,EACP,KAAK,EACL,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,KAAK,EACL,OAAO,EACP,MAAM,CACT;AAED,MAAMC,eAAoC,GAAG,CAAC,CAAC;AAC/C,MAAMC,YAAsB,GAAG,CAAC,OAAO,CAAC;AAExC,MAAMC,sBAAsB,GAAGA,CAAA,KAAM;EACjC,KAAK,MAAMC,MAAM,IAAIJ,cAAc,EAAE;IACjC;IACAK,OAAO,CAACD,MAAM,CAAC,GAAGH,eAAe,CAACG,MAAM,CAAC;EAC7C;AACJ,CAAC;AAMM,MAAME,gBAAgB,GAAIC,QAAkC,IAAK;EACpE;EACA,IAAIF,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,EAAE;IAChCF,sBAAsB,CAAC,CAAC;EAC5B;;EAEA;EACAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;EAE5B,KAAK,MAAMD,MAAM,IAAIJ,cAAc,EAAE;IACjC;IACAC,eAAe,CAACG,MAAM,CAAC,GAAGC,OAAO,CAACD,MAAM,CAAC;IACzC;IACAC,OAAO,CAACD,MAAM,CAAC,GAAG,CAAC,GAAGI,IAAI,KAAK;MAC3BD,QAAQ,CAACH,MAAM,EAAEI,IAAI,CAAC;MACtB,IAAIN,YAAY,CAACO,QAAQ,CAACL,MAAM,CAAC,EAAE;QAC/B;MACJ;MACAH,eAAe,CAACG,MAAM,CAAC,CAAC,GAAGI,IAAI,CAAC;IACpC,CAAC;EACL;AACJ,CAAC;AAACE,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/handler-graphql",
|
|
3
|
-
"version": "5.39.0-beta.
|
|
3
|
+
"version": "5.39.0-beta.3",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "7.22.6",
|
|
18
18
|
"@graphql-tools/schema": "7.1.5",
|
|
19
|
-
"@webiny/api": "5.39.0-beta.
|
|
20
|
-
"@webiny/error": "5.39.0-beta.
|
|
21
|
-
"@webiny/handler": "5.39.0-beta.
|
|
22
|
-
"@webiny/plugins": "5.39.0-beta.
|
|
19
|
+
"@webiny/api": "5.39.0-beta.3",
|
|
20
|
+
"@webiny/error": "5.39.0-beta.3",
|
|
21
|
+
"@webiny/handler": "5.39.0-beta.3",
|
|
22
|
+
"@webiny/plugins": "5.39.0-beta.3",
|
|
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.22.6",
|
|
30
30
|
"@babel/core": "7.22.8",
|
|
31
31
|
"@babel/preset-env": "7.22.7",
|
|
32
|
-
"@webiny/cli": "5.39.0-beta.
|
|
33
|
-
"@webiny/handler-aws": "5.39.0-beta.
|
|
34
|
-
"@webiny/project-utils": "5.39.0-beta.
|
|
32
|
+
"@webiny/cli": "5.39.0-beta.3",
|
|
33
|
+
"@webiny/handler-aws": "5.39.0-beta.3",
|
|
34
|
+
"@webiny/project-utils": "5.39.0-beta.3",
|
|
35
35
|
"jest": "29.5.0",
|
|
36
36
|
"jest-mock-console": "1.3.0",
|
|
37
37
|
"rimraf": "3.0.2",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"build": "yarn webiny run build",
|
|
47
47
|
"watch": "yarn webiny run watch"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "3846541fd9c1764e6a8041f0b4208d720eb9c314"
|
|
50
50
|
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.GraphQLSchemaPlugin = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
7
|
var _plugins = require("@webiny/plugins");
|
|
10
8
|
class GraphQLSchemaPlugin extends _plugins.Plugin {
|
|
9
|
+
static type = "graphql-schema";
|
|
11
10
|
constructor(config) {
|
|
12
11
|
super();
|
|
13
|
-
(0, _defineProperty2.default)(this, "config", void 0);
|
|
14
12
|
this.config = config;
|
|
15
13
|
}
|
|
16
14
|
get schema() {
|
|
@@ -21,6 +19,5 @@ class GraphQLSchemaPlugin extends _plugins.Plugin {
|
|
|
21
19
|
}
|
|
22
20
|
}
|
|
23
21
|
exports.GraphQLSchemaPlugin = GraphQLSchemaPlugin;
|
|
24
|
-
(0, _defineProperty2.default)(GraphQLSchemaPlugin, "type", "graphql-schema");
|
|
25
22
|
|
|
26
23
|
//# sourceMappingURL=GraphQLSchemaPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_plugins","require","GraphQLSchemaPlugin","Plugin","
|
|
1
|
+
{"version":3,"names":["_plugins","require","GraphQLSchemaPlugin","Plugin","type","constructor","config","schema","typeDefs","resolvers","exports"],"sources":["GraphQLSchemaPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { GraphQLSchemaDefinition, Resolvers, Types } from \"~/types\";\nimport { Context } from \"@webiny/api/types\";\n\nexport interface GraphQLSchemaPluginConfig<TContext> {\n typeDefs?: Types;\n resolvers?: Resolvers<TContext>;\n}\n\nexport class GraphQLSchemaPlugin<TContext = Context> extends Plugin {\n public static override readonly type: string = \"graphql-schema\";\n private config: GraphQLSchemaPluginConfig<TContext>;\n\n constructor(config: GraphQLSchemaPluginConfig<TContext>) {\n super();\n this.config = config;\n }\n\n get schema(): GraphQLSchemaDefinition<TContext> {\n return {\n typeDefs: this.config.typeDefs || \"\",\n resolvers: this.config.resolvers\n };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,mBAAmB,SAA6BC,eAAM,CAAC;EAChE,OAAgCC,IAAI,GAAW,gBAAgB;EAG/DC,WAAWA,CAACC,MAA2C,EAAE;IACrD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,IAAIC,MAAMA,CAAA,EAAsC;IAC5C,OAAO;MACHC,QAAQ,EAAE,IAAI,CAACF,MAAM,CAACE,QAAQ,IAAI,EAAE;MACpCC,SAAS,EAAE,IAAI,CAACH,MAAM,CAACG;IAC3B,CAAC;EACL;AACJ;AAACC,OAAA,CAAAR,mBAAA,GAAAA,mBAAA"}
|
package/responses.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.Response = exports.NotFoundResponse = exports.ListResponse = exports.ListErrorResponse = exports.ErrorResponse = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
7
|
const defaultParams = {
|
|
10
8
|
code: "",
|
|
11
9
|
message: "",
|
|
@@ -14,8 +12,6 @@ const defaultParams = {
|
|
|
14
12
|
};
|
|
15
13
|
class ErrorResponse {
|
|
16
14
|
constructor(params) {
|
|
17
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
18
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
19
15
|
this.data = null;
|
|
20
16
|
const debug = process.env.DEBUG === "true";
|
|
21
17
|
|
|
@@ -44,9 +40,6 @@ class NotFoundResponse extends ErrorResponse {
|
|
|
44
40
|
exports.NotFoundResponse = NotFoundResponse;
|
|
45
41
|
class ListErrorResponse {
|
|
46
42
|
constructor(params) {
|
|
47
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
48
|
-
(0, _defineProperty2.default)(this, "meta", void 0);
|
|
49
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
50
43
|
this.meta = null;
|
|
51
44
|
this.data = null;
|
|
52
45
|
const debug = process.env.DEBUG === "true";
|
|
@@ -67,8 +60,6 @@ class ListErrorResponse {
|
|
|
67
60
|
exports.ListErrorResponse = ListErrorResponse;
|
|
68
61
|
class Response {
|
|
69
62
|
constructor(data) {
|
|
70
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
71
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
72
63
|
this.data = data;
|
|
73
64
|
this.error = null;
|
|
74
65
|
}
|
|
@@ -76,9 +67,6 @@ class Response {
|
|
|
76
67
|
exports.Response = Response;
|
|
77
68
|
class ListResponse {
|
|
78
69
|
constructor(data, meta) {
|
|
79
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
80
|
-
(0, _defineProperty2.default)(this, "meta", void 0);
|
|
81
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
82
70
|
this.data = Array.isArray(data) ? data : [];
|
|
83
71
|
this.meta = meta || {};
|
|
84
72
|
this.error = null;
|
package/responses.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defaultParams","code","message","data","stack","ErrorResponse","constructor","params","
|
|
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,OA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AC3C,IAAI,CAACa,IAAI,GAAGA,IAAI,IAAK,CAAC,CAAO;IAC7B,IAAI,CAACJ,KAAK,GAAG,IAAI;EACrB;AACJ;AAACC,OAAA,CAAAK,YAAA,GAAAA,YAAA"}
|
package/types.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface HandlerGraphQLOptions {
|
|
|
11
11
|
debug?: boolean | string;
|
|
12
12
|
}
|
|
13
13
|
export declare type GraphQLFieldResolver<TSource = any, TArgs = any, TContext = Context> = BaseGraphQLFieldResolver<TSource, TContext, TArgs>;
|
|
14
|
-
export declare type Types = string | (() => string | Promise<string>);
|
|
14
|
+
export declare type Types = string | string[] | (() => string | string[] | Promise<string | string[]>);
|
|
15
15
|
export interface GraphQLSchemaPluginTypeArgs {
|
|
16
16
|
context?: any;
|
|
17
17
|
args?: any;
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import {\n GraphQLScalarType,\n GraphQLFieldResolver as BaseGraphQLFieldResolver,\n GraphQLSchema\n} from \"graphql\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { Context } from \"@webiny/api/types\";\nimport { RouteMethodPath } from \"@webiny/handler/types\";\n\nexport interface GraphQLScalarPlugin extends Plugin {\n type: \"graphql-scalar\";\n scalar: GraphQLScalarType;\n}\n\nexport interface HandlerGraphQLOptions {\n path?: RouteMethodPath;\n debug?: boolean | string;\n}\n\nexport type GraphQLFieldResolver<\n TSource = any,\n TArgs = any,\n TContext = Context\n> = BaseGraphQLFieldResolver<TSource, TContext, TArgs>;\n\n// `GraphQLSchemaPlugin` types.\nexport type Types = string | (() => string | Promise<string>);\n\nexport interface GraphQLSchemaPluginTypeArgs {\n context?: any;\n args?: any;\n source?: any;\n}\n\nexport type Resolvers<TContext> =\n | GraphQLScalarType\n | GraphQLFieldResolver<any, Record<string, any>, TContext>\n | { [property: string]: Resolvers<TContext> };\n\nexport interface GraphQLSchemaDefinition<TContext> {\n typeDefs: Types;\n resolvers?: Resolvers<TContext>;\n}\n\nexport interface GraphQLSchemaPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-schema\";\n schema: GraphQLSchemaDefinition<TContext>;\n}\n\nexport interface GraphQLRequestBody {\n query: string;\n variables: Record<string, any>;\n operationName: string;\n}\n\nexport interface GraphQLBeforeQueryPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-before-query\";\n apply(params: { body: GraphQLRequestBody; schema: GraphQLSchema; context: TContext }): void;\n}\n\nexport interface GraphQLAfterQueryPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-after-query\";\n apply(params: {\n result: any;\n body: GraphQLRequestBody;\n schema: GraphQLSchema;\n context: TContext;\n }): void;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import {\n GraphQLScalarType,\n GraphQLFieldResolver as BaseGraphQLFieldResolver,\n GraphQLSchema\n} from \"graphql\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { Context } from \"@webiny/api/types\";\nimport { RouteMethodPath } from \"@webiny/handler/types\";\n\nexport interface GraphQLScalarPlugin extends Plugin {\n type: \"graphql-scalar\";\n scalar: GraphQLScalarType;\n}\n\nexport interface HandlerGraphQLOptions {\n path?: RouteMethodPath;\n debug?: boolean | string;\n}\n\nexport type GraphQLFieldResolver<\n TSource = any,\n TArgs = any,\n TContext = Context\n> = BaseGraphQLFieldResolver<TSource, TContext, TArgs>;\n\n// `GraphQLSchemaPlugin` types.\nexport type Types = string | string[] | (() => string | string[] | Promise<string | string[]>);\n\nexport interface GraphQLSchemaPluginTypeArgs {\n context?: any;\n args?: any;\n source?: any;\n}\n\nexport type Resolvers<TContext> =\n | GraphQLScalarType\n | GraphQLFieldResolver<any, Record<string, any>, TContext>\n | { [property: string]: Resolvers<TContext> };\n\nexport interface GraphQLSchemaDefinition<TContext> {\n typeDefs: Types;\n resolvers?: Resolvers<TContext>;\n}\n\nexport interface GraphQLSchemaPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-schema\";\n schema: GraphQLSchemaDefinition<TContext>;\n}\n\nexport interface GraphQLRequestBody {\n query: string;\n variables: Record<string, any>;\n operationName: string;\n}\n\nexport interface GraphQLBeforeQueryPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-before-query\";\n apply(params: { body: GraphQLRequestBody; schema: GraphQLSchema; context: TContext }): void;\n}\n\nexport interface GraphQLAfterQueryPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-after-query\";\n apply(params: {\n result: any;\n body: GraphQLRequestBody;\n schema: GraphQLSchema;\n context: TContext;\n }): void;\n}\n"],"mappings":""}
|