@webiny/handler-graphql 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9
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/README.md +9 -5
- package/ResolverDecoration.d.ts +6 -0
- package/ResolverDecoration.js +23 -0
- package/ResolverDecoration.js.map +1 -0
- package/builtInTypes/AnyScalar.d.ts +1 -1
- package/builtInTypes/AnyScalar.js +9 -18
- package/builtInTypes/AnyScalar.js.map +1 -1
- package/builtInTypes/DateScalar.d.ts +1 -1
- package/builtInTypes/DateScalar.js +16 -32
- package/builtInTypes/DateScalar.js.map +1 -1
- package/builtInTypes/DateTimeScalar.d.ts +1 -1
- package/builtInTypes/DateTimeScalar.js +16 -32
- package/builtInTypes/DateTimeScalar.js.map +1 -1
- package/builtInTypes/DateTimeZScalar.d.ts +1 -1
- package/builtInTypes/DateTimeZScalar.js +27 -58
- package/builtInTypes/DateTimeZScalar.js.map +1 -1
- package/builtInTypes/IconScalar.d.ts +10 -0
- package/builtInTypes/IconScalar.js +65 -0
- package/builtInTypes/IconScalar.js.map +1 -0
- package/builtInTypes/JsonScalar.d.ts +1 -1
- package/builtInTypes/JsonScalar.js +4 -10
- package/builtInTypes/JsonScalar.js.map +1 -1
- package/builtInTypes/LongScalar.d.ts +2 -1
- package/builtInTypes/LongScalar.js +38 -9
- package/builtInTypes/LongScalar.js.map +1 -1
- package/builtInTypes/NumberScalar.d.ts +1 -1
- package/builtInTypes/NumberScalar.js +35 -58
- package/builtInTypes/NumberScalar.js.map +1 -1
- package/builtInTypes/RefInputScalar.d.ts +1 -1
- package/builtInTypes/RefInputScalar.js +48 -60
- package/builtInTypes/RefInputScalar.js.map +1 -1
- package/builtInTypes/TimeScalar.d.ts +1 -1
- package/builtInTypes/TimeScalar.js +31 -62
- package/builtInTypes/TimeScalar.js.map +1 -1
- package/builtInTypes/index.d.ts +10 -9
- package/builtInTypes/index.js +10 -122
- package/createGraphQLHandler.d.ts +3 -3
- package/createGraphQLHandler.js +77 -55
- package/createGraphQLHandler.js.map +1 -1
- package/createGraphQLSchema.d.ts +4 -2
- package/createGraphQLSchema.js +67 -54
- package/createGraphQLSchema.js.map +1 -1
- package/createRequestBody.d.ts +2 -0
- package/createRequestBody.js +28 -0
- package/createRequestBody.js.map +1 -0
- package/createResolverDecorator.d.ts +2 -0
- package/createResolverDecorator.js +4 -0
- package/createResolverDecorator.js.map +1 -0
- package/debugPlugins.d.ts +2 -2
- package/debugPlugins.js +28 -45
- package/debugPlugins.js.map +1 -1
- package/errors.js +7 -17
- package/errors.js.map +1 -1
- package/exports/api/graphql.d.ts +2 -0
- package/exports/api/graphql.js +2 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.d.ts +16 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js +57 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js.map +1 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.d.ts +13 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js +35 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js.map +1 -0
- package/features/GraphQLSchemaBuilder/abstractions.d.ts +34 -0
- package/features/GraphQLSchemaBuilder/abstractions.js +6 -0
- package/features/GraphQLSchemaBuilder/abstractions.js.map +1 -0
- package/features/GraphQLSchemaBuilder/feature.d.ts +4 -0
- package/features/GraphQLSchemaBuilder/feature.js +11 -0
- package/features/GraphQLSchemaBuilder/feature.js.map +1 -0
- package/graphql/abstractions.core.d.ts +11 -0
- package/graphql/abstractions.core.js +5 -0
- package/graphql/abstractions.core.js.map +1 -0
- package/graphql/abstractions.d.ts +2 -0
- package/graphql/abstractions.js +2 -0
- package/graphql/abstractions.public.d.ts +18 -0
- package/graphql/abstractions.public.js +5 -0
- package/graphql/abstractions.public.js.map +1 -0
- package/index.d.ts +10 -5
- package/index.js +12 -57
- package/index.js.map +1 -1
- package/interceptConsole.js +31 -39
- package/interceptConsole.js.map +1 -1
- package/package.json +32 -29
- package/plugins/GraphQLSchemaPlugin.d.ts +13 -5
- package/plugins/GraphQLSchemaPlugin.js +23 -29
- package/plugins/GraphQLSchemaPlugin.js.map +1 -1
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +1 -18
- package/processRequestBody.d.ts +4 -5
- package/processRequestBody.js +35 -42
- package/processRequestBody.js.map +1 -1
- package/responses.d.ts +11 -1
- package/responses.js +44 -92
- package/responses.js.map +1 -1
- package/types.d.ts +20 -13
- package/types.js +0 -5
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/resolve.d.ts +21 -0
- package/utils/resolve.js +20 -0
- package/utils/resolve.js.map +1 -0
- package/builtInTypes/index.js.map +0 -1
- package/plugins/index.js.map +0 -1
- package/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# @webiny/handler-graphql
|
|
2
|
-
[](https://www.npmjs.com/package/@webiny/handler-graphql)
|
|
3
|
-
[](https://www.npmjs.com/package/@webiny/handler-graphql)
|
|
4
|
-
[](https://github.com/prettier/prettier)
|
|
5
|
-
[](http://makeapullrequest.com)
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { composeResolvers } from "@graphql-tools/resolvers-composition";
|
|
2
|
+
class ResolverDecoration {
|
|
3
|
+
addDecorators(resolverDecorators) {
|
|
4
|
+
for(const key in resolverDecorators){
|
|
5
|
+
const decorators = resolverDecorators[key];
|
|
6
|
+
if (!decorators) continue;
|
|
7
|
+
const existingDecorators = this.decorators[key] ?? [];
|
|
8
|
+
this.decorators[key] = [
|
|
9
|
+
...existingDecorators,
|
|
10
|
+
...decorators
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
decorateResolvers(resolvers) {
|
|
15
|
+
return composeResolvers(resolvers, this.decorators);
|
|
16
|
+
}
|
|
17
|
+
constructor(){
|
|
18
|
+
this.decorators = {};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export { ResolverDecoration };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=ResolverDecoration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolverDecoration.js","sources":["../src/ResolverDecoration.ts"],"sourcesContent":["import { composeResolvers } from \"@graphql-tools/resolvers-composition\";\nimport type { ResolverDecorators, Resolvers } from \"./types.js\";\n\nexport class ResolverDecoration {\n private decorators: ResolverDecorators = {};\n\n addDecorators(resolverDecorators: ResolverDecorators) {\n for (const key in resolverDecorators) {\n const decorators = resolverDecorators[key];\n if (!decorators) {\n continue;\n }\n\n const existingDecorators = this.decorators[key] ?? [];\n this.decorators[key] = [...existingDecorators, ...decorators];\n }\n }\n\n decorateResolvers(resolvers: Resolvers<unknown>) {\n return composeResolvers(resolvers, this.decorators);\n }\n}\n"],"names":["ResolverDecoration","resolverDecorators","key","decorators","existingDecorators","resolvers","composeResolvers"],"mappings":";AAGO,MAAMA;IAGT,cAAcC,kBAAsC,EAAE;QAClD,IAAK,MAAMC,OAAOD,mBAAoB;YAClC,MAAME,aAAaF,kBAAkB,CAACC,IAAI;YAC1C,IAAI,CAACC,YACD;YAGJ,MAAMC,qBAAqB,IAAI,CAAC,UAAU,CAACF,IAAI,IAAI,EAAE;YACrD,IAAI,CAAC,UAAU,CAACA,IAAI,GAAG;mBAAIE;mBAAuBD;aAAW;QACjE;IACJ;IAEA,kBAAkBE,SAA6B,EAAE;QAC7C,OAAOC,iBAAiBD,WAAW,IAAI,CAAC,UAAU;IACtD;;aAhBQ,UAAU,GAAuB,CAAC;;AAiB9C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GraphQLScalarType } from "graphql";
|
|
2
|
-
export declare const AnyScalar: GraphQLScalarType
|
|
2
|
+
export declare const AnyScalar: GraphQLScalarType<any, any>;
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { GraphQLScalarType } from "graphql";
|
|
2
|
+
const returnValue = (value)=>value;
|
|
3
|
+
const AnyScalar = new GraphQLScalarType({
|
|
4
|
+
name: "Any",
|
|
5
|
+
description: "A scalar type that represents an ambiguous value.",
|
|
6
|
+
serialize: returnValue,
|
|
7
|
+
parseValue: returnValue
|
|
5
8
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _graphql = require("graphql");
|
|
9
|
+
export { AnyScalar };
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
return value;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const AnyScalar = new _graphql.GraphQLScalarType({
|
|
15
|
-
name: "Any",
|
|
16
|
-
description: `A scalar type that represents an ambiguous value.`,
|
|
17
|
-
serialize: returnValue,
|
|
18
|
-
parseValue: returnValue
|
|
19
|
-
});
|
|
20
|
-
exports.AnyScalar = AnyScalar;
|
|
11
|
+
//# sourceMappingURL=AnyScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"builtInTypes/AnyScalar.js","sources":["../../src/builtInTypes/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"],"names":["returnValue","value","AnyScalar","GraphQLScalarType"],"mappings":";AAEA,MAAMA,cAAc,CAACC,QACVA;AAGJ,MAAMC,YAAY,IAAIC,kBAAkB;IAC3C,MAAM;IACN,aAAa;IACb,WAAWH;IACX,YAAYA;AAChB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GraphQLScalarType } from "graphql";
|
|
2
|
-
export declare const DateScalar: GraphQLScalarType
|
|
2
|
+
export declare const DateScalar: GraphQLScalarType<string | Date, string>;
|
|
@@ -1,34 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _graphql = require("graphql");
|
|
15
|
-
|
|
16
|
-
const DateScalar = new _graphql.GraphQLScalarType((0, _objectSpread2.default)((0, _objectSpread2.default)({}, _graphqlScalars.DateResolver), {}, {
|
|
17
|
-
serialize: value => {
|
|
18
|
-
if (!value) {
|
|
19
|
-
return null;
|
|
1
|
+
import { DateResolver } from "graphql-scalars";
|
|
2
|
+
import { GraphQLScalarType } from "graphql";
|
|
3
|
+
const DateScalar = new GraphQLScalarType({
|
|
4
|
+
...DateResolver,
|
|
5
|
+
serialize: (value)=>{
|
|
6
|
+
if (!value) return null;
|
|
7
|
+
try {
|
|
8
|
+
const date = new Date(value);
|
|
9
|
+
return date.toISOString().slice(0, 10);
|
|
10
|
+
} catch (ex) {
|
|
11
|
+
if (value.toISOString) return value.toISOString().slice(0, 10);
|
|
12
|
+
throw ex;
|
|
13
|
+
}
|
|
20
14
|
}
|
|
15
|
+
});
|
|
16
|
+
export { DateScalar };
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
const date = new Date(value);
|
|
24
|
-
return date.toISOString().slice(0, 10);
|
|
25
|
-
} catch (ex) {
|
|
26
|
-
if (value.toISOString) {
|
|
27
|
-
return value.toISOString().slice(0, 10);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
throw ex;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}));
|
|
34
|
-
exports.DateScalar = DateScalar;
|
|
18
|
+
//# sourceMappingURL=DateScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"builtInTypes/DateScalar.js","sources":["../../src/builtInTypes/DateScalar.ts"],"sourcesContent":["import { DateResolver } from \"graphql-scalars\";\nimport { GraphQLScalarType } from \"graphql\";\nexport const DateScalar = new GraphQLScalarType<Date | string, string>({\n ...DateResolver,\n /**\n * We can set value as any because we are handling it.\n */\n serialize: (value: any) => {\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"],"names":["DateScalar","GraphQLScalarType","DateResolver","value","date","Date","ex"],"mappings":";;AAEO,MAAMA,aAAa,IAAIC,kBAAyC;IACnE,GAAGC,YAAY;IAIf,WAAW,CAACC;QACR,IAAI,CAACA,OACD,OAAO;QAEX,IAAI;YACA,MAAMC,OAAO,IAAIC,KAAKF;YACtB,OAAOC,KAAK,WAAW,GAAG,KAAK,CAAC,GAAG;QACvC,EAAE,OAAOE,IAAI;YACT,IAAIH,MAAM,WAAW,EACjB,OAAOA,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG;YAExC,MAAMG;QACV;IACJ;AACJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GraphQLScalarType } from "graphql";
|
|
2
|
-
export declare const DateTimeScalar: GraphQLScalarType
|
|
2
|
+
export declare const DateTimeScalar: GraphQLScalarType<Date, any>;
|
|
@@ -1,34 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _graphql = require("graphql");
|
|
15
|
-
|
|
16
|
-
const DateTimeScalar = new _graphql.GraphQLScalarType((0, _objectSpread2.default)((0, _objectSpread2.default)({}, _graphqlScalars.DateTimeResolver), {}, {
|
|
17
|
-
serialize: value => {
|
|
18
|
-
if (!value) {
|
|
19
|
-
return null;
|
|
1
|
+
import { DateTimeResolver } from "graphql-scalars";
|
|
2
|
+
import { GraphQLScalarType } from "graphql";
|
|
3
|
+
const DateTimeScalar = new GraphQLScalarType({
|
|
4
|
+
...DateTimeResolver,
|
|
5
|
+
serialize: (value)=>{
|
|
6
|
+
if (!value) return null;
|
|
7
|
+
try {
|
|
8
|
+
const date = new Date(value);
|
|
9
|
+
return date.toISOString();
|
|
10
|
+
} catch (ex) {
|
|
11
|
+
if (value.toISOString) return value.toISOString();
|
|
12
|
+
throw ex;
|
|
13
|
+
}
|
|
20
14
|
}
|
|
15
|
+
});
|
|
16
|
+
export { DateTimeScalar };
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
const date = new Date(value);
|
|
24
|
-
return date.toISOString();
|
|
25
|
-
} catch (ex) {
|
|
26
|
-
if (value.toISOString) {
|
|
27
|
-
return value.toISOString();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
throw ex;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}));
|
|
34
|
-
exports.DateTimeScalar = DateTimeScalar;
|
|
18
|
+
//# sourceMappingURL=DateTimeScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"builtInTypes/DateTimeScalar.js","sources":["../../src/builtInTypes/DateTimeScalar.ts"],"sourcesContent":["import { DateTimeResolver } from \"graphql-scalars\";\nimport { GraphQLScalarType } from \"graphql\";\nexport const DateTimeScalar = new GraphQLScalarType({\n ...DateTimeResolver,\n /**\n * We can set value as any because we are handling it.\n */\n serialize: (value: any) => {\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"],"names":["DateTimeScalar","GraphQLScalarType","DateTimeResolver","value","date","Date","ex"],"mappings":";;AAEO,MAAMA,iBAAiB,IAAIC,kBAAkB;IAChD,GAAGC,gBAAgB;IAInB,WAAW,CAACC;QACR,IAAI,CAACA,OACD,OAAO;QAEX,IAAI;YACA,MAAMC,OAAO,IAAIC,KAAKF;YACtB,OAAOC,KAAK,WAAW;QAC3B,EAAE,OAAOE,IAAI;YACT,IAAIH,MAAM,WAAW,EACjB,OAAOA,MAAM,WAAW;YAE5B,MAAMG;QACV;IACJ;AACJ"}
|
|
@@ -3,4 +3,4 @@ import { GraphQLScalarType } from "graphql";
|
|
|
3
3
|
* A custom type for dateTime with the timezone.
|
|
4
4
|
* Must be in format "YYYY-MM-ddTHH:mm:ss+HH:mm".
|
|
5
5
|
*/
|
|
6
|
-
export declare const DateTimeZScalar: GraphQLScalarType
|
|
6
|
+
export declare const DateTimeZScalar: GraphQLScalarType<unknown, unknown>;
|
|
@@ -1,63 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.DateTimeZScalar = void 0;
|
|
9
|
-
|
|
10
|
-
var _graphqlScalars = require("graphql-scalars");
|
|
11
|
-
|
|
12
|
-
var _graphql = require("graphql");
|
|
13
|
-
|
|
14
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
|
-
const validateTimeZone = value => {
|
|
17
|
-
const timeWithTimezone = value.split("T")[1];
|
|
18
|
-
|
|
19
|
-
if (!timeWithTimezone) {
|
|
20
|
-
throw new _error.default("Could not extract time with timezone from value.", "DATE_TIME_TIMEZONE_ERROR", {
|
|
21
|
-
value
|
|
1
|
+
import { DateTimeResolver } from "graphql-scalars";
|
|
2
|
+
import { GraphQLScalarType } from "graphql";
|
|
3
|
+
import error from "@webiny/error";
|
|
4
|
+
const validateTimeZone = (value)=>{
|
|
5
|
+
const timeWithTimezone = value.split("T")[1];
|
|
6
|
+
if (!timeWithTimezone) throw new error("Could not extract time with timezone from value.", "DATE_TIME_TIMEZONE_ERROR", {
|
|
7
|
+
value
|
|
22
8
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (!zone) {
|
|
29
|
-
throw new _error.default("Could not extract timezone from value.", "DATE_TIME_TIMEZONE_ERROR", {
|
|
30
|
-
value: timeWithTimezone
|
|
9
|
+
const separator = timeWithTimezone.includes("-") ? "-" : "+";
|
|
10
|
+
const zone = timeWithTimezone.split(separator)[1];
|
|
11
|
+
if (!zone) throw new error("Could not extract timezone from value.", "DATE_TIME_TIMEZONE_ERROR", {
|
|
12
|
+
value: timeWithTimezone
|
|
31
13
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (hours === undefined || minutes === undefined || hoursMinutes.length !== 2) {
|
|
38
|
-
throw new _error.default("Could not extract hours or minutes from value.", "DATE_TIME_TIMEZONE_ERROR", {
|
|
39
|
-
value: zone
|
|
14
|
+
const hoursMinutes = zone.split(":");
|
|
15
|
+
const [hours, minutes] = hoursMinutes;
|
|
16
|
+
if (void 0 === hours || void 0 === minutes || 2 !== hoursMinutes.length) throw new error("Could not extract hours or minutes from value.", "DATE_TIME_TIMEZONE_ERROR", {
|
|
17
|
+
value: zone
|
|
40
18
|
});
|
|
41
|
-
}
|
|
42
19
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
parseValue: value => {
|
|
53
|
-
// this serves as validator
|
|
54
|
-
_graphqlScalars.DateTimeResolver.parseValue(value);
|
|
55
|
-
|
|
56
|
-
validateTimeZone(value);
|
|
57
|
-
return value;
|
|
58
|
-
},
|
|
59
|
-
serialize: value => {
|
|
60
|
-
return value;
|
|
61
|
-
}
|
|
20
|
+
const DateTimeZScalar = new GraphQLScalarType({
|
|
21
|
+
name: "DateTimeZ",
|
|
22
|
+
description: "A custom type for dateTime with the timezone.",
|
|
23
|
+
parseValue: (value)=>{
|
|
24
|
+
DateTimeResolver.parseValue(value);
|
|
25
|
+
validateTimeZone(value);
|
|
26
|
+
return value;
|
|
27
|
+
},
|
|
28
|
+
serialize: (value)=>value
|
|
62
29
|
});
|
|
63
|
-
|
|
30
|
+
export { DateTimeZScalar };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=DateTimeZScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"builtInTypes/DateTimeZScalar.js","sources":["../../src/builtInTypes/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 as string);\n return value;\n },\n serialize: value => {\n return value;\n }\n});\n"],"names":["validateTimeZone","value","timeWithTimezone","WebinyError","separator","zone","hoursMinutes","hours","minutes","undefined","DateTimeZScalar","GraphQLScalarType","DateTimeResolver"],"mappings":";;;AAIA,MAAMA,mBAAmB,CAACC;IACtB,MAAMC,mBAAmBD,MAAM,KAAK,CAAC,IAAI,CAAC,EAAE;IAC5C,IAAI,CAACC,kBACD,MAAM,IAAIC,MACN,oDACA,4BACA;QACIF;IACJ;IAGR,MAAMG,YAAYF,iBAAiB,QAAQ,CAAC,OAAO,MAAM;IACzD,MAAMG,OAAOH,iBAAiB,KAAK,CAACE,UAAU,CAAC,EAAE;IACjD,IAAI,CAACC,MACD,MAAM,IAAIF,MACN,0CACA,4BACA;QACI,OAAOD;IACX;IAGR,MAAMI,eAAeD,KAAK,KAAK,CAAC;IAChC,MAAM,CAACE,OAAOC,QAAQ,GAAGF;IACzB,IAAIC,AAAUE,WAAVF,SAAuBC,AAAYC,WAAZD,WAAyBF,AAAwB,MAAxBA,aAAa,MAAM,EACnE,MAAM,IAAIH,MACN,kDACA,4BACA;QACI,OAAOE;IACX;AAGZ;AAKO,MAAMK,kBAAkB,IAAIC,kBAAkB;IACjD,MAAM;IACN,aAAa;IACb,YAAYV,CAAAA;QAERW,iBAAiB,UAAU,CAACX;QAC5BD,iBAAiBC;QACjB,OAAOA;IACX;IACA,WAAWA,CAAAA,QACAA;AAEf"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { GraphQLError, GraphQLScalarType } from "graphql";
|
|
2
|
+
import { Kind } from "graphql/language/index.js";
|
|
3
|
+
const IconScalar = new GraphQLScalarType({
|
|
4
|
+
name: "Icon",
|
|
5
|
+
description: "Icon scalar that accepts string or object {type, name, value}",
|
|
6
|
+
serialize (value) {
|
|
7
|
+
if ("string" == typeof value) return {
|
|
8
|
+
type: "icon",
|
|
9
|
+
name: value,
|
|
10
|
+
value: void 0
|
|
11
|
+
};
|
|
12
|
+
if (value && "object" == typeof value) {
|
|
13
|
+
if ("string" != typeof value.type || "string" != typeof value.name) throw new GraphQLError("Icon object must have string type and name");
|
|
14
|
+
return {
|
|
15
|
+
type: value.type,
|
|
16
|
+
name: value.name,
|
|
17
|
+
value: value.value
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
throw new GraphQLError("Icon must be a string or object");
|
|
21
|
+
},
|
|
22
|
+
parseValue (value) {
|
|
23
|
+
if ("string" == typeof value) return {
|
|
24
|
+
type: "icon",
|
|
25
|
+
name: value
|
|
26
|
+
};
|
|
27
|
+
if (value && "object" == typeof value) {
|
|
28
|
+
if ("string" != typeof value.type || "string" != typeof value.name) throw new GraphQLError("Icon object must have string type and name");
|
|
29
|
+
if (void 0 !== value.value && "string" != typeof value.value) throw new GraphQLError("Icon value must be a string if provided");
|
|
30
|
+
return {
|
|
31
|
+
type: value.type,
|
|
32
|
+
name: value.name,
|
|
33
|
+
...void 0 !== value.value && {
|
|
34
|
+
value: value.value
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
throw new GraphQLError("Icon must be a string or object");
|
|
39
|
+
},
|
|
40
|
+
parseLiteral (ast) {
|
|
41
|
+
if (ast.kind === Kind.STRING) return {
|
|
42
|
+
type: "icon",
|
|
43
|
+
name: ast.value
|
|
44
|
+
};
|
|
45
|
+
if (ast.kind === Kind.OBJECT) {
|
|
46
|
+
const fields = {};
|
|
47
|
+
ast.fields.forEach((field)=>{
|
|
48
|
+
if (field.value.kind === Kind.STRING) fields[field.name.value] = field.value.value;
|
|
49
|
+
else throw new GraphQLError("Icon object fields must be strings");
|
|
50
|
+
});
|
|
51
|
+
if (!fields.type || !fields.name) throw new GraphQLError("Icon object must have type and name");
|
|
52
|
+
return {
|
|
53
|
+
type: fields.type,
|
|
54
|
+
name: fields.name,
|
|
55
|
+
...fields.value && {
|
|
56
|
+
value: fields.value
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
throw new GraphQLError("Icon must be a string or object literal");
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
export { IconScalar };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=IconScalar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtInTypes/IconScalar.js","sources":["../../src/builtInTypes/IconScalar.ts"],"sourcesContent":["import { GraphQLScalarType, GraphQLError } from \"graphql\";\nimport { Kind } from \"graphql/language/index.js\";\n\nexport const IconScalar = new GraphQLScalarType({\n name: \"Icon\",\n description: \"Icon scalar that accepts string or object {type, name, value}\",\n\n // Serialize for output - always return object structure\n serialize(value: any) {\n if (typeof value === \"string\") {\n return { type: \"icon\", name: value, value: undefined };\n }\n\n if (value && typeof value === \"object\") {\n // Validate structure\n if (typeof value.type !== \"string\" || typeof value.name !== \"string\") {\n throw new GraphQLError(\"Icon object must have string type and name\");\n }\n\n return {\n type: value.type,\n name: value.name,\n value: value.value\n };\n }\n\n throw new GraphQLError(\"Icon must be a string or object\");\n },\n\n // Parse from variables (JSON input)\n parseValue(value: any) {\n // String input → convert to object\n if (typeof value === \"string\") {\n return { type: \"icon\", name: value };\n }\n\n // Object input → validate and return\n if (value && typeof value === \"object\") {\n if (typeof value.type !== \"string\" || typeof value.name !== \"string\") {\n throw new GraphQLError(\"Icon object must have string type and name\");\n }\n\n if (value.value !== undefined && typeof value.value !== \"string\") {\n throw new GraphQLError(\"Icon value must be a string if provided\");\n }\n\n return {\n type: value.type,\n name: value.name,\n ...(value.value !== undefined && { value: value.value })\n };\n }\n\n throw new GraphQLError(\"Icon must be a string or object\");\n },\n\n // Parse from inline query literals\n parseLiteral(ast) {\n // String literal\n if (ast.kind === Kind.STRING) {\n return { type: \"icon\", name: ast.value };\n }\n\n // Object literal\n if (ast.kind === Kind.OBJECT) {\n const fields: Record<string, string> = {};\n\n ast.fields.forEach(field => {\n if (field.value.kind === Kind.STRING) {\n fields[field.name.value] = field.value.value;\n } else {\n throw new GraphQLError(\"Icon object fields must be strings\");\n }\n });\n\n // Validate required fields\n if (!fields.type || !fields.name) {\n throw new GraphQLError(\"Icon object must have type and name\");\n }\n\n return {\n type: fields.type,\n name: fields.name,\n ...(fields.value && { value: fields.value })\n };\n }\n\n throw new GraphQLError(\"Icon must be a string or object literal\");\n }\n});\n"],"names":["IconScalar","GraphQLScalarType","value","undefined","GraphQLError","ast","Kind","fields","field"],"mappings":";;AAGO,MAAMA,aAAa,IAAIC,kBAAkB;IAC5C,MAAM;IACN,aAAa;IAGb,WAAUC,KAAU;QAChB,IAAI,AAAiB,YAAjB,OAAOA,OACP,OAAO;YAAE,MAAM;YAAQ,MAAMA;YAAO,OAAOC;QAAU;QAGzD,IAAID,SAAS,AAAiB,YAAjB,OAAOA,OAAoB;YAEpC,IAAI,AAAsB,YAAtB,OAAOA,MAAM,IAAI,IAAiB,AAAsB,YAAtB,OAAOA,MAAM,IAAI,EACnD,MAAM,IAAIE,aAAa;YAG3B,OAAO;gBACH,MAAMF,MAAM,IAAI;gBAChB,MAAMA,MAAM,IAAI;gBAChB,OAAOA,MAAM,KAAK;YACtB;QACJ;QAEA,MAAM,IAAIE,aAAa;IAC3B;IAGA,YAAWF,KAAU;QAEjB,IAAI,AAAiB,YAAjB,OAAOA,OACP,OAAO;YAAE,MAAM;YAAQ,MAAMA;QAAM;QAIvC,IAAIA,SAAS,AAAiB,YAAjB,OAAOA,OAAoB;YACpC,IAAI,AAAsB,YAAtB,OAAOA,MAAM,IAAI,IAAiB,AAAsB,YAAtB,OAAOA,MAAM,IAAI,EACnD,MAAM,IAAIE,aAAa;YAG3B,IAAIF,AAAgBC,WAAhBD,MAAM,KAAK,IAAkB,AAAuB,YAAvB,OAAOA,MAAM,KAAK,EAC/C,MAAM,IAAIE,aAAa;YAG3B,OAAO;gBACH,MAAMF,MAAM,IAAI;gBAChB,MAAMA,MAAM,IAAI;gBAChB,GAAIA,AAAgBC,WAAhBD,MAAM,KAAK,IAAkB;oBAAE,OAAOA,MAAM,KAAK;gBAAC,CAAC;YAC3D;QACJ;QAEA,MAAM,IAAIE,aAAa;IAC3B;IAGA,cAAaC,GAAG;QAEZ,IAAIA,IAAI,IAAI,KAAKC,KAAK,MAAM,EACxB,OAAO;YAAE,MAAM;YAAQ,MAAMD,IAAI,KAAK;QAAC;QAI3C,IAAIA,IAAI,IAAI,KAAKC,KAAK,MAAM,EAAE;YAC1B,MAAMC,SAAiC,CAAC;YAExCF,IAAI,MAAM,CAAC,OAAO,CAACG,CAAAA;gBACf,IAAIA,MAAM,KAAK,CAAC,IAAI,KAAKF,KAAK,MAAM,EAChCC,MAAM,CAACC,MAAM,IAAI,CAAC,KAAK,CAAC,GAAGA,MAAM,KAAK,CAAC,KAAK;qBAE5C,MAAM,IAAIJ,aAAa;YAE/B;YAGA,IAAI,CAACG,OAAO,IAAI,IAAI,CAACA,OAAO,IAAI,EAC5B,MAAM,IAAIH,aAAa;YAG3B,OAAO;gBACH,MAAMG,OAAO,IAAI;gBACjB,MAAMA,OAAO,IAAI;gBACjB,GAAIA,OAAO,KAAK,IAAI;oBAAE,OAAOA,OAAO,KAAK;gBAAC,CAAC;YAC/C;QACJ;QAEA,MAAM,IAAIH,aAAa;IAC3B;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const JsonScalar: import("graphql").GraphQLScalarType
|
|
1
|
+
export declare const JsonScalar: import("graphql").GraphQLScalarType<any, any>;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { JSONResolver } from "graphql-scalars";
|
|
2
|
+
const JsonScalar = JSONResolver;
|
|
3
|
+
export { JsonScalar };
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.JsonScalar = void 0;
|
|
7
|
-
|
|
8
|
-
var _graphqlScalars = require("graphql-scalars");
|
|
9
|
-
|
|
10
|
-
const JsonScalar = _graphqlScalars.JSONResolver;
|
|
11
|
-
exports.JsonScalar = JsonScalar;
|
|
5
|
+
//# sourceMappingURL=JsonScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"builtInTypes/JsonScalar.js","sources":["../../src/builtInTypes/JsonScalar.ts"],"sourcesContent":["import { JSONResolver } from \"graphql-scalars\";\nexport const JsonScalar = JSONResolver;\n"],"names":["JsonScalar","JSONResolver"],"mappings":";AACO,MAAMA,aAAaC"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { GraphQLScalarType } from "graphql";
|
|
2
|
+
export declare const LongScalar: GraphQLScalarType<number | null, number | null>;
|
|
@@ -1,11 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { GraphQLScalarType } from "graphql";
|
|
2
|
+
import { Kind } from "graphql/language/index.js";
|
|
3
|
+
import error from "@webiny/error";
|
|
4
|
+
const parseValue = (value)=>{
|
|
5
|
+
if (String(value).includes(".")) throw new error("Value sent must be an integer.", "INVALID_VALUE", {
|
|
6
|
+
value
|
|
7
|
+
});
|
|
8
|
+
if ("number" == typeof value) return value;
|
|
9
|
+
if (null == value) return null;
|
|
10
|
+
if (true === isNaN(value)) throw new error("Value sent must be an integer.", "INVALID_VALUE", {
|
|
11
|
+
value
|
|
12
|
+
});
|
|
13
|
+
return parseInt(value);
|
|
14
|
+
};
|
|
15
|
+
const LongScalar = new GraphQLScalarType({
|
|
16
|
+
name: "Long",
|
|
17
|
+
description: "A custom input type to be used for large integers (Long).",
|
|
18
|
+
serialize: (value)=>{
|
|
19
|
+
try {
|
|
20
|
+
return parseValue(value);
|
|
21
|
+
} catch {
|
|
22
|
+
console.log({
|
|
23
|
+
message: "Value sent must be an integer.",
|
|
24
|
+
code: "INVALID_VALUE",
|
|
25
|
+
data: {
|
|
26
|
+
value
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
parseValue: parseValue,
|
|
33
|
+
parseLiteral: (ast)=>{
|
|
34
|
+
if (ast.kind === Kind.INT) return parseInt(ast.value);
|
|
35
|
+
throw new Error(`Expected type Long, found {${ast.kind}}`);
|
|
36
|
+
}
|
|
5
37
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _graphqlScalars = require("graphql-scalars");
|
|
38
|
+
export { LongScalar };
|
|
9
39
|
|
|
10
|
-
|
|
11
|
-
exports.LongScalar = LongScalar;
|
|
40
|
+
//# sourceMappingURL=LongScalar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"builtInTypes/LongScalar.js","sources":["../../src/builtInTypes/LongScalar.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\nimport { Kind } from \"graphql/language/index.js\";\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 {\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"],"names":["parseValue","value","String","WebinyError","isNaN","parseInt","LongScalar","GraphQLScalarType","console","ast","Kind","Error"],"mappings":";;;AAIA,MAAMA,aAAa,CAACC;IAChB,IAAIC,OAAOD,OAAO,QAAQ,CAAC,MACvB,MAAM,IAAIE,MAAY,kCAAkC,iBAAiB;QACrEF;IACJ;IAEJ,IAAI,AAAiB,YAAjB,OAAOA,OACP,OAAOA;IAGX,IAAIA,QAAAA,OACA,OAAO;IAGX,IAAIG,AAAiB,SAAjBA,MAAMH,QACN,MAAM,IAAIE,MAAY,kCAAkC,iBAAiB;QACrEF;IACJ;IAGJ,OAAOI,SAASJ;AACpB;AAEO,MAAMK,aAAa,IAAIC,kBAAkB;IAC5C,MAAM;IACN,aAAa;IACb,WAAW,CAACN;QACR,IAAI;YACA,OAAOD,WAAWC;QACtB,EAAE,OAAM;YACJO,QAAQ,GAAG,CAAC;gBACR,SAAS;gBACT,MAAM;gBACN,MAAM;oBACFP;gBACJ;YACJ;YACA,OAAO;QACX;IACJ;IACAD,YAAAA;IACA,cAAcS,CAAAA;QACV,IAAIA,IAAI,IAAI,KAAKC,KAAK,GAAG,EACrB,OAAOL,SAASI,IAAI,KAAK;QAG7B,MAAM,IAAIE,MAAM,CAAC,2BAA2B,EAAEF,IAAI,IAAI,CAAC,CAAC,CAAC;IAC7D;AACJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GraphQLScalarType } from "graphql";
|
|
2
|
-
export declare const NumberScalar: GraphQLScalarType
|
|
2
|
+
export declare const NumberScalar: GraphQLScalarType<number | null, number | null>;
|