@webiny/handler-graphql 0.0.0-unstable.9bd236cf5e → 0.0.0-unstable.9f53ea597d

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.
Files changed (103) hide show
  1. package/README.md +9 -5
  2. package/ResolverDecoration.d.ts +1 -1
  3. package/ResolverDecoration.js +18 -21
  4. package/ResolverDecoration.js.map +1 -1
  5. package/builtInTypes/AnyScalar.d.ts +1 -1
  6. package/builtInTypes/AnyScalar.js +8 -15
  7. package/builtInTypes/AnyScalar.js.map +1 -1
  8. package/builtInTypes/DateScalar.d.ts +1 -1
  9. package/builtInTypes/DateScalar.js +19 -23
  10. package/builtInTypes/DateScalar.js.map +1 -1
  11. package/builtInTypes/DateTimeScalar.d.ts +1 -1
  12. package/builtInTypes/DateTimeScalar.js +14 -23
  13. package/builtInTypes/DateTimeScalar.js.map +1 -1
  14. package/builtInTypes/DateTimeZScalar.d.ts +1 -1
  15. package/builtInTypes/DateTimeZScalar.js +25 -44
  16. package/builtInTypes/DateTimeZScalar.js.map +1 -1
  17. package/builtInTypes/IconScalar.d.ts +10 -0
  18. package/builtInTypes/IconScalar.js +65 -0
  19. package/builtInTypes/IconScalar.js.map +1 -0
  20. package/builtInTypes/JsonScalar.d.ts +1 -1
  21. package/builtInTypes/JsonScalar.js +3 -8
  22. package/builtInTypes/JsonScalar.js.map +1 -1
  23. package/builtInTypes/LongScalar.d.ts +1 -1
  24. package/builtInTypes/LongScalar.js +32 -48
  25. package/builtInTypes/LongScalar.js.map +1 -1
  26. package/builtInTypes/NumberScalar.d.ts +1 -1
  27. package/builtInTypes/NumberScalar.js +33 -47
  28. package/builtInTypes/NumberScalar.js.map +1 -1
  29. package/builtInTypes/RefInputScalar.d.ts +1 -1
  30. package/builtInTypes/RefInputScalar.js +46 -69
  31. package/builtInTypes/RefInputScalar.js.map +1 -1
  32. package/builtInTypes/TimeScalar.d.ts +1 -1
  33. package/builtInTypes/TimeScalar.js +29 -49
  34. package/builtInTypes/TimeScalar.js.map +1 -1
  35. package/builtInTypes/index.d.ts +10 -9
  36. package/builtInTypes/index.js +10 -106
  37. package/createGraphQLHandler.d.ts +3 -3
  38. package/createGraphQLHandler.js +74 -102
  39. package/createGraphQLHandler.js.map +1 -1
  40. package/createGraphQLSchema.d.ts +4 -4
  41. package/createGraphQLSchema.js +55 -67
  42. package/createGraphQLSchema.js.map +1 -1
  43. package/createRequestBody.d.ts +2 -0
  44. package/createRequestBody.js +28 -0
  45. package/createRequestBody.js.map +1 -0
  46. package/createResolverDecorator.d.ts +1 -1
  47. package/createResolverDecorator.js +2 -10
  48. package/createResolverDecorator.js.map +1 -1
  49. package/debugPlugins.d.ts +3 -3
  50. package/debugPlugins.js +26 -36
  51. package/debugPlugins.js.map +1 -1
  52. package/errors.js +6 -13
  53. package/errors.js.map +1 -1
  54. package/exports/api/graphql.d.ts +2 -0
  55. package/exports/api/graphql.js +2 -0
  56. package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.d.ts +16 -0
  57. package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js +57 -0
  58. package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js.map +1 -0
  59. package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.d.ts +13 -0
  60. package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js +35 -0
  61. package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js.map +1 -0
  62. package/features/GraphQLSchemaBuilder/abstractions.d.ts +34 -0
  63. package/features/GraphQLSchemaBuilder/abstractions.js +6 -0
  64. package/features/GraphQLSchemaBuilder/abstractions.js.map +1 -0
  65. package/features/GraphQLSchemaBuilder/feature.d.ts +4 -0
  66. package/features/GraphQLSchemaBuilder/feature.js +11 -0
  67. package/features/GraphQLSchemaBuilder/feature.js.map +1 -0
  68. package/graphql/abstractions.core.d.ts +11 -0
  69. package/graphql/abstractions.core.js +5 -0
  70. package/graphql/abstractions.core.js.map +1 -0
  71. package/graphql/abstractions.d.ts +2 -0
  72. package/graphql/abstractions.js +2 -0
  73. package/graphql/abstractions.public.d.ts +18 -0
  74. package/graphql/abstractions.public.js +5 -0
  75. package/graphql/abstractions.public.js.map +1 -0
  76. package/index.d.ts +10 -10
  77. package/index.js +10 -97
  78. package/index.js.map +1 -1
  79. package/interceptConsole.js +30 -34
  80. package/interceptConsole.js.map +1 -1
  81. package/package.json +32 -27
  82. package/plugins/GraphQLSchemaPlugin.d.ts +2 -2
  83. package/plugins/GraphQLSchemaPlugin.js +21 -30
  84. package/plugins/GraphQLSchemaPlugin.js.map +1 -1
  85. package/plugins/index.d.ts +1 -1
  86. package/plugins/index.js +1 -18
  87. package/processRequestBody.d.ts +3 -3
  88. package/processRequestBody.js +34 -44
  89. package/processRequestBody.js.map +1 -1
  90. package/responses.d.ts +11 -1
  91. package/responses.js +43 -61
  92. package/responses.js.map +1 -1
  93. package/types.d.ts +6 -6
  94. package/types.js +0 -7
  95. package/utils/index.d.ts +1 -1
  96. package/utils/index.js +1 -18
  97. package/utils/resolve.d.ts +2 -2
  98. package/utils/resolve.js +16 -24
  99. package/utils/resolve.js.map +1 -1
  100. package/builtInTypes/index.js.map +0 -1
  101. package/plugins/index.js.map +0 -1
  102. package/types.js.map +0 -1
  103. package/utils/index.js.map +0 -1
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@webiny/handler-graphql",
3
- "version": "0.0.0-unstable.9bd236cf5e",
4
- "main": "index.js",
3
+ "version": "0.0.0-unstable.9f53ea597d",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
5
9
  "license": "MIT",
6
10
  "repository": {
7
11
  "type": "git",
@@ -14,34 +18,35 @@
14
18
  "Adrian Smijulj <adrian@webiny.com>"
15
19
  ],
16
20
  "dependencies": {
17
- "@graphql-tools/merge": "9.0.8",
18
- "@graphql-tools/resolvers-composition": "7.0.2",
19
- "@graphql-tools/schema": "10.0.7",
20
- "@graphql-tools/utils": "10.5.5",
21
- "@webiny/api": "0.0.0-unstable.9bd236cf5e",
22
- "@webiny/error": "0.0.0-unstable.9bd236cf5e",
23
- "@webiny/handler": "0.0.0-unstable.9bd236cf5e",
24
- "@webiny/plugins": "0.0.0-unstable.9bd236cf5e",
25
- "boolean": "3.2.0",
26
- "graphql": "15.9.0",
27
- "graphql-scalars": "1.12.0",
28
- "graphql-tag": "2.12.6"
21
+ "@graphql-tools/merge": "9.2.2",
22
+ "@graphql-tools/resolvers-composition": "7.0.35",
23
+ "@graphql-tools/schema": "10.0.38",
24
+ "@graphql-tools/utils": "11.2.2",
25
+ "@webiny/api": "0.0.0-unstable.9f53ea597d",
26
+ "@webiny/di": "1.0.2",
27
+ "@webiny/error": "0.0.0-unstable.9f53ea597d",
28
+ "@webiny/feature": "0.0.0-unstable.9f53ea597d",
29
+ "@webiny/handler": "0.0.0-unstable.9f53ea597d",
30
+ "@webiny/plugins": "0.0.0-unstable.9f53ea597d",
31
+ "@webiny/stdlib": "0.0.12",
32
+ "@webiny/utils": "0.0.0-unstable.9f53ea597d",
33
+ "graphql": "16.14.2",
34
+ "graphql-scalars": "1.25.0",
35
+ "graphql-tag": "2.12.7",
36
+ "zod": "4.4.3"
29
37
  },
30
38
  "devDependencies": {
31
- "@webiny/handler-aws": "0.0.0-unstable.9bd236cf5e",
32
- "@webiny/project-utils": "0.0.0-unstable.9bd236cf5e",
33
- "jest": "29.7.0",
34
- "jest-mock-console": "2.0.0",
35
- "rimraf": "6.0.1",
36
- "typescript": "5.3.3"
39
+ "@webiny/build-tools": "0.0.0-unstable.9f53ea597d",
40
+ "@webiny/handler-aws": "0.0.0-unstable.9f53ea597d",
41
+ "rimraf": "6.1.3",
42
+ "typescript": "7.0.2",
43
+ "vitest": "4.1.10"
37
44
  },
38
45
  "publishConfig": {
39
- "access": "public",
40
- "directory": "dist"
41
- },
42
- "scripts": {
43
- "build": "node ../cli/bin.js run build",
44
- "watch": "node ../cli/bin.js run watch"
46
+ "access": "public"
45
47
  },
46
- "gitHead": "9bd236cf5e689f209a11bec089207dcc2d41a53c"
48
+ "gitHead": "b8aec8a1be3f25c3b428b357fe1e352c7cbff9ae",
49
+ "webiny": {
50
+ "publishFrom": "dist"
51
+ }
47
52
  }
@@ -1,6 +1,6 @@
1
- import type { Context } from "@webiny/api/types";
1
+ import type { Context } from "@webiny/api/types.js";
2
2
  import { Plugin } from "@webiny/plugins";
3
- import type { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from "../types";
3
+ import type { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from "../types.js";
4
4
  export interface IGraphQLSchemaPlugin<TContext = Context> extends Plugin {
5
5
  schema: GraphQLSchemaDefinition<TContext>;
6
6
  isApplicable: (context: TContext) => boolean;
@@ -1,34 +1,25 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createGraphQLSchemaPlugin = exports.GraphQLSchemaPlugin = void 0;
7
- var _plugins = require("@webiny/plugins");
8
- class GraphQLSchemaPlugin extends _plugins.Plugin {
9
- static type = "graphql-schema";
10
- constructor(config) {
11
- super();
12
- this.config = config;
13
- }
14
- get schema() {
15
- return {
16
- typeDefs: this.config.typeDefs || "",
17
- resolvers: this.config.resolvers,
18
- resolverDecorators: this.config.resolverDecorators
19
- };
20
- }
21
- isApplicable(context) {
22
- if (this.config.isApplicable) {
23
- return this.config.isApplicable(context);
1
+ import { Plugin } from "@webiny/plugins";
2
+ class GraphQLSchemaPlugin extends Plugin {
3
+ static{
4
+ this.type = "graphql-schema";
5
+ }
6
+ constructor(config){
7
+ super();
8
+ this.config = config;
9
+ }
10
+ get schema() {
11
+ return {
12
+ typeDefs: this.config.typeDefs || "",
13
+ resolvers: this.config.resolvers,
14
+ resolverDecorators: this.config.resolverDecorators
15
+ };
16
+ }
17
+ isApplicable(context) {
18
+ if (this.config.isApplicable) return this.config.isApplicable(context);
19
+ return true;
24
20
  }
25
- return true;
26
- }
27
21
  }
28
- exports.GraphQLSchemaPlugin = GraphQLSchemaPlugin;
29
- const createGraphQLSchemaPlugin = config => {
30
- return new GraphQLSchemaPlugin(config);
31
- };
32
- exports.createGraphQLSchemaPlugin = createGraphQLSchemaPlugin;
22
+ const createGraphQLSchemaPlugin = (config)=>new GraphQLSchemaPlugin(config);
23
+ export { GraphQLSchemaPlugin, createGraphQLSchemaPlugin };
33
24
 
34
25
  //# sourceMappingURL=GraphQLSchemaPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","GraphQLSchemaPlugin","Plugin","type","constructor","config","schema","typeDefs","resolvers","resolverDecorators","isApplicable","context","exports","createGraphQLSchemaPlugin"],"sources":["GraphQLSchemaPlugin.ts"],"sourcesContent":["import type { Context } from \"@webiny/api/types\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from \"~/types\";\n\nexport interface IGraphQLSchemaPlugin<TContext = Context> extends Plugin {\n schema: GraphQLSchemaDefinition<TContext>;\n isApplicable: (context: TContext) => boolean;\n}\n\nexport interface GraphQLSchemaPluginConfig<TContext> {\n typeDefs?: TypeDefs;\n resolvers?: Resolvers<TContext>;\n resolverDecorators?: ResolverDecorators;\n isApplicable?: (context: TContext) => boolean;\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 resolverDecorators: this.config.resolverDecorators\n };\n }\n\n isApplicable(context: TContext): boolean {\n if (this.config.isApplicable) {\n return this.config.isApplicable(context);\n }\n return true;\n }\n}\n\nexport const createGraphQLSchemaPlugin = <T = Context>(config: GraphQLSchemaPluginConfig<T>) => {\n return new GraphQLSchemaPlugin<T>(config);\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAeO,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,SAAS;MAChCC,kBAAkB,EAAE,IAAI,CAACJ,MAAM,CAACI;IACpC,CAAC;EACL;EAEAC,YAAYA,CAACC,OAAiB,EAAW;IACrC,IAAI,IAAI,CAACN,MAAM,CAACK,YAAY,EAAE;MAC1B,OAAO,IAAI,CAACL,MAAM,CAACK,YAAY,CAACC,OAAO,CAAC;IAC5C;IACA,OAAO,IAAI;EACf;AACJ;AAACC,OAAA,CAAAX,mBAAA,GAAAA,mBAAA;AAEM,MAAMY,yBAAyB,GAAiBR,MAAoC,IAAK;EAC5F,OAAO,IAAIJ,mBAAmB,CAAII,MAAM,CAAC;AAC7C,CAAC;AAACO,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
1
+ {"version":3,"file":"plugins/GraphQLSchemaPlugin.js","sources":["../../src/plugins/GraphQLSchemaPlugin.ts"],"sourcesContent":["import type { Context } from \"@webiny/api/types.js\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from \"~/types.js\";\n\nexport interface IGraphQLSchemaPlugin<TContext = Context> extends Plugin {\n schema: GraphQLSchemaDefinition<TContext>;\n isApplicable: (context: TContext) => boolean;\n}\n\nexport interface GraphQLSchemaPluginConfig<TContext> {\n typeDefs?: TypeDefs;\n resolvers?: Resolvers<TContext>;\n resolverDecorators?: ResolverDecorators;\n isApplicable?: (context: TContext) => boolean;\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 resolverDecorators: this.config.resolverDecorators\n };\n }\n\n isApplicable(context: TContext): boolean {\n if (this.config.isApplicable) {\n return this.config.isApplicable(context);\n }\n return true;\n }\n}\n\nexport const createGraphQLSchemaPlugin = <T = Context>(config: GraphQLSchemaPluginConfig<T>) => {\n return new GraphQLSchemaPlugin<T>(config);\n};\n"],"names":["GraphQLSchemaPlugin","Plugin","config","context","createGraphQLSchemaPlugin"],"mappings":";AAgBO,MAAMA,4BACDC;;aAGwB,IAAI,GAAW;;IAG/C,YAAYC,MAA2C,CAAE;QACrD,KAAK;QACL,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEA,IAAI,SAA4C;QAC5C,OAAO;YACH,UAAU,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI;YAClC,WAAW,IAAI,CAAC,MAAM,CAAC,SAAS;YAChC,oBAAoB,IAAI,CAAC,MAAM,CAAC,kBAAkB;QACtD;IACJ;IAEA,aAAaC,OAAiB,EAAW;QACrC,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,EACxB,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAACA;QAEpC,OAAO;IACX;AACJ;AAEO,MAAMC,4BAA4B,CAAcF,SAC5C,IAAIF,oBAAuBE"}
@@ -1 +1 @@
1
- export * from "./GraphQLSchemaPlugin";
1
+ export * from "./GraphQLSchemaPlugin.js";
package/plugins/index.js CHANGED
@@ -1,18 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _GraphQLSchemaPlugin = require("./GraphQLSchemaPlugin");
7
- Object.keys(_GraphQLSchemaPlugin).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _GraphQLSchemaPlugin[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _GraphQLSchemaPlugin[key];
14
- }
15
- });
16
- });
17
-
18
- //# sourceMappingURL=index.js.map
1
+ export * from "./GraphQLSchemaPlugin.js";
@@ -1,4 +1,4 @@
1
1
  import type { ExecutionResult, GraphQLSchema } from "graphql";
2
- import type { GraphQLRequestBody } from "./types";
3
- import type { Context } from "@webiny/api/types";
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>[]>;
2
+ import type { GraphQLRequestBody } from "./types.js";
3
+ import type { Context } from "@webiny/api/types.js";
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>>;
@@ -1,50 +1,40 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.processRequestBody = void 0;
7
- var _graphql = require("graphql");
8
- const executeGraphQl = async (body, schema, context) => {
9
- const {
10
- query,
11
- variables,
12
- operationName
13
- } = body;
14
- context.plugins.byType("graphql-before-query").forEach(pl => pl.apply({
15
- body,
16
- schema,
17
- context
18
- }));
19
- const result = await (0, _graphql.graphql)({
20
- schema,
21
- source: query,
22
- rootValue: {},
23
- contextValue: context,
24
- variableValues: variables,
25
- operationName
26
- });
27
- context.plugins.byType("graphql-after-query").forEach(pl => {
28
- pl.apply({
29
- result,
30
- body,
31
- schema,
32
- context
1
+ import { graphql } from "graphql";
2
+ const executeGraphQl = async (body, schema, context)=>{
3
+ const { query, variables, operationName } = body;
4
+ context.plugins.byType("graphql-before-query").forEach((pl)=>pl.apply({
5
+ body,
6
+ schema,
7
+ context
8
+ }));
9
+ const result = await graphql({
10
+ schema,
11
+ source: query,
12
+ rootValue: {},
13
+ contextValue: context,
14
+ variableValues: variables,
15
+ operationName
16
+ });
17
+ context.plugins.byType("graphql-after-query").forEach((pl)=>{
18
+ pl.apply({
19
+ result,
20
+ body,
21
+ schema,
22
+ context
23
+ });
33
24
  });
34
- });
35
- return result;
25
+ return result;
36
26
  };
37
- const processRequestBody = async (requestBody, schema, context) => {
38
- if (Array.isArray(requestBody)) {
39
- const results = [];
40
- for (const body of requestBody) {
41
- const result = await executeGraphQl(body, schema, context);
42
- results.push(result);
27
+ const processRequestBody = async (requestBody, schema, context)=>{
28
+ if (Array.isArray(requestBody)) {
29
+ const results = [];
30
+ for (const body of requestBody){
31
+ const result = await executeGraphQl(body, schema, context);
32
+ results.push(result);
33
+ }
34
+ return results;
43
35
  }
44
- return results;
45
- }
46
- return await executeGraphQl(requestBody, schema, context);
36
+ return await executeGraphQl(requestBody, schema, context);
47
37
  };
48
- exports.processRequestBody = processRequestBody;
38
+ export { processRequestBody };
49
39
 
50
40
  //# sourceMappingURL=processRequestBody.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_graphql","require","executeGraphQl","body","schema","context","query","variables","operationName","plugins","byType","forEach","pl","apply","result","graphql","source","rootValue","contextValue","variableValues","processRequestBody","requestBody","Array","isArray","results","push","exports"],"sources":["processRequestBody.ts"],"sourcesContent":["import type { ExecutionResult, GraphQLSchema } from \"graphql\";\nimport { graphql } from \"graphql\";\nimport type {\n GraphQLAfterQueryPlugin,\n GraphQLBeforeQueryPlugin,\n GraphQLRequestBody\n} from \"~/types\";\nimport type { Context } from \"@webiny/api/types\";\n\nconst executeGraphQl = async <TData = Record<string, any>, TExtensions = Record<string, any>>(\n body: GraphQLRequestBody,\n schema: GraphQLSchema,\n context: Context\n): Promise<ExecutionResult<TData, TExtensions>> => {\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({\n schema,\n source: query,\n rootValue: {},\n contextValue: context,\n variableValues: variables,\n operationName\n });\n\n context.plugins.byType<GraphQLAfterQueryPlugin>(\"graphql-after-query\").forEach(pl => {\n pl.apply({ result, body, schema, context });\n });\n\n return result as ExecutionResult<TData, TExtensions>;\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<TData, TExtensions>(body, schema, context);\n results.push(result);\n }\n return results;\n }\n return await executeGraphQl<TData, TExtensions>(requestBody, schema, context);\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAQA,MAAMC,cAAc,GAAG,MAAAA,CACnBC,IAAwB,EACxBC,MAAqB,EACrBC,OAAgB,KAC+B;EAC/C,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,EAAC;IACzBX,MAAM;IACNY,MAAM,EAAEV,KAAK;IACbW,SAAS,EAAE,CAAC,CAAC;IACbC,YAAY,EAAEb,OAAO;IACrBc,cAAc,EAAEZ,SAAS;IACzBC;EACJ,CAAC,CAAC;EAEFH,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,MAAMM,kBAAkB,GAAG,MAAAA,CAI9BC,WAAsD,EACtDjB,MAAqB,EACrBC,OAAgB,KACuE;EACvF,IAAIiB,KAAK,CAACC,OAAO,CAACF,WAAW,CAAC,EAAE;IAC5B,MAAMG,OAA8C,GAAG,EAAE;IACzD,KAAK,MAAMrB,IAAI,IAAIkB,WAAW,EAAE;MAC5B,MAAMP,MAAM,GAAG,MAAMZ,cAAc,CAAqBC,IAAI,EAAEC,MAAM,EAAEC,OAAO,CAAC;MAC9EmB,OAAO,CAACC,IAAI,CAACX,MAAM,CAAC;IACxB;IACA,OAAOU,OAAO;EAClB;EACA,OAAO,MAAMtB,cAAc,CAAqBmB,WAAW,EAAEjB,MAAM,EAAEC,OAAO,CAAC;AACjF,CAAC;AAACqB,OAAA,CAAAN,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"file":"processRequestBody.js","sources":["../src/processRequestBody.ts"],"sourcesContent":["import type { ExecutionResult, GraphQLSchema } from \"graphql\";\nimport { graphql } from \"graphql\";\nimport type {\n GraphQLAfterQueryPlugin,\n GraphQLBeforeQueryPlugin,\n GraphQLRequestBody\n} from \"~/types.js\";\nimport type { Context } from \"@webiny/api/types.js\";\n\nconst executeGraphQl = async <TData = Record<string, any>, TExtensions = Record<string, any>>(\n body: GraphQLRequestBody,\n schema: GraphQLSchema,\n context: Context\n): Promise<ExecutionResult<TData, TExtensions>> => {\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({\n schema,\n source: query,\n rootValue: {},\n contextValue: context,\n variableValues: variables,\n operationName\n });\n\n context.plugins.byType<GraphQLAfterQueryPlugin>(\"graphql-after-query\").forEach(pl => {\n pl.apply({ result, body, schema, context });\n });\n\n return result as ExecutionResult<TData, TExtensions>;\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<TData, TExtensions>(body, schema, context);\n results.push(result);\n }\n return results;\n }\n return await executeGraphQl<TData, TExtensions>(requestBody, schema, context);\n};\n"],"names":["executeGraphQl","body","schema","context","query","variables","operationName","pl","result","graphql","processRequestBody","requestBody","Array","results"],"mappings":";AASA,MAAMA,iBAAiB,OACnBC,MACAC,QACAC;IAEA,MAAM,EAAEC,KAAK,EAAEC,SAAS,EAAEC,aAAa,EAAE,GAAGL;IAE5CE,QAAQ,OAAO,CACV,MAAM,CAA2B,wBACjC,OAAO,CAACI,CAAAA,KAAMA,GAAG,KAAK,CAAC;YAAEN;YAAMC;YAAQC;QAAQ;IAEpD,MAAMK,SAAS,MAAMC,QAAQ;QACzBP;QACA,QAAQE;QACR,WAAW,CAAC;QACZ,cAAcD;QACd,gBAAgBE;QAChBC;IACJ;IAEAH,QAAQ,OAAO,CAAC,MAAM,CAA0B,uBAAuB,OAAO,CAACI,CAAAA;QAC3EA,GAAG,KAAK,CAAC;YAAEC;YAAQP;YAAMC;YAAQC;QAAQ;IAC7C;IAEA,OAAOK;AACX;AAEO,MAAME,qBAAqB,OAI9BC,aACAT,QACAC;IAEA,IAAIS,MAAM,OAAO,CAACD,cAAc;QAC5B,MAAME,UAAiD,EAAE;QACzD,KAAK,MAAMZ,QAAQU,YAAa;YAC5B,MAAMH,SAAS,MAAMR,eAAmCC,MAAMC,QAAQC;YACtEU,QAAQ,IAAI,CAACL;QACjB;QACA,OAAOK;IACX;IACA,OAAO,MAAMb,eAAmCW,aAAaT,QAAQC;AACzE"}
package/responses.d.ts CHANGED
@@ -1,9 +1,15 @@
1
+ export interface IMeta {
2
+ hasMoreItems: boolean;
3
+ totalCount: number;
4
+ cursor?: string | null;
5
+ }
1
6
  export interface ErrorResponseParams {
2
7
  message: string;
3
8
  code?: string;
4
9
  data?: any;
5
10
  stack?: string | null;
6
11
  }
12
+ /** GraphQL error response helper. */
7
13
  export declare class ErrorResponse {
8
14
  readonly data: null;
9
15
  readonly error: {
@@ -14,9 +20,11 @@ export declare class ErrorResponse {
14
20
  };
15
21
  constructor(params: ErrorResponseParams);
16
22
  }
23
+ /** GraphQL not-found response helper. */
17
24
  export declare class NotFoundResponse extends ErrorResponse {
18
25
  constructor(message: string);
19
26
  }
27
+ /** GraphQL list error response helper. */
20
28
  export declare class ListErrorResponse {
21
29
  readonly data: null;
22
30
  readonly meta: null;
@@ -28,12 +36,14 @@ export declare class ListErrorResponse {
28
36
  };
29
37
  constructor(params: ErrorResponseParams);
30
38
  }
39
+ /** GraphQL response helper. */
31
40
  export declare class Response<T = any> {
32
41
  readonly data: T;
33
42
  readonly error: null;
34
43
  constructor(data: T);
35
44
  }
36
- export declare class ListResponse<T, M> {
45
+ /** GraphQL list response helper. */
46
+ export declare class ListResponse<T, M = IMeta> {
37
47
  readonly data: Array<T>;
38
48
  readonly meta: M;
39
49
  readonly error: null;
package/responses.js CHANGED
@@ -1,77 +1,59 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Response = exports.NotFoundResponse = exports.ListResponse = exports.ListErrorResponse = exports.ErrorResponse = void 0;
7
1
  const defaultParams = {
8
- code: "",
9
- message: "",
10
- data: null,
11
- stack: null
2
+ code: "",
3
+ message: "",
4
+ data: null,
5
+ stack: null
12
6
  };
13
7
  class ErrorResponse {
14
- constructor(params) {
15
- this.data = null;
16
- const debug = process.env.DEBUG === "true";
17
-
18
- // Ensure `stack` is either `string` or `null`.
19
- let stack = defaultParams.stack;
20
- if (debug && params.stack) {
21
- stack = params.stack;
8
+ constructor(params){
9
+ this.data = null;
10
+ const debug = "true" === process.env.DEBUG;
11
+ let stack = defaultParams.stack;
12
+ if (debug && params.stack) stack = params.stack;
13
+ this.error = {
14
+ code: params.code || defaultParams.code,
15
+ message: params.message || defaultParams.message,
16
+ data: params.data || defaultParams.data,
17
+ stack: stack
18
+ };
22
19
  }
23
- this.error = {
24
- code: params.code || defaultParams.code,
25
- message: params.message || defaultParams.message,
26
- data: params.data || defaultParams.data,
27
- stack: stack
28
- };
29
- }
30
20
  }
31
- exports.ErrorResponse = ErrorResponse;
32
21
  class NotFoundResponse extends ErrorResponse {
33
- constructor(message) {
34
- super({
35
- code: "NOT_FOUND",
36
- message
37
- });
38
- }
22
+ constructor(message){
23
+ super({
24
+ code: "NOT_FOUND",
25
+ message
26
+ });
27
+ }
39
28
  }
40
- exports.NotFoundResponse = NotFoundResponse;
41
29
  class ListErrorResponse {
42
- constructor(params) {
43
- this.meta = null;
44
- this.data = null;
45
- const debug = process.env.DEBUG === "true";
46
-
47
- // Ensure `stack` is either `string` or `null`.
48
- let stack = defaultParams.stack;
49
- if (debug && params.stack) {
50
- stack = params.stack;
30
+ constructor(params){
31
+ this.meta = null;
32
+ this.data = null;
33
+ const debug = "true" === process.env.DEBUG;
34
+ let stack = defaultParams.stack;
35
+ if (debug && params.stack) stack = params.stack;
36
+ this.error = {
37
+ code: params.code || defaultParams.code,
38
+ message: params.message || defaultParams.message,
39
+ data: params.data || defaultParams.data,
40
+ stack: stack
41
+ };
51
42
  }
52
- this.error = {
53
- code: params.code || defaultParams.code,
54
- message: params.message || defaultParams.message,
55
- data: params.data || defaultParams.data,
56
- stack: stack
57
- };
58
- }
59
43
  }
60
- exports.ListErrorResponse = ListErrorResponse;
61
44
  class Response {
62
- constructor(data) {
63
- this.data = data;
64
- this.error = null;
65
- }
45
+ constructor(data){
46
+ this.data = data;
47
+ this.error = null;
48
+ }
66
49
  }
67
- exports.Response = Response;
68
50
  class ListResponse {
69
- constructor(data, meta) {
70
- this.data = Array.isArray(data) ? data : [];
71
- this.meta = meta || {};
72
- this.error = null;
73
- }
51
+ constructor(data, meta){
52
+ this.data = Array.isArray(data) ? data : [];
53
+ this.meta = meta || {};
54
+ this.error = null;
55
+ }
74
56
  }
75
- exports.ListResponse = ListResponse;
57
+ export { ErrorResponse, ListErrorResponse, ListResponse, NotFoundResponse, Response };
76
58
 
77
59
  //# sourceMappingURL=responses.js.map
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,CAAC;EACN;AACJ;AAACW,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAEM,MAAMC,iBAAiB,CAAC;EAU3BT,WAAWA,CAACC,MAA2B,EAAE;IACrC,IAAI,CAACS,IAAI,GAAG,IAAI;IAChB,IAAI,CAACb,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,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":[]}
1
+ {"version":3,"file":"responses.js","sources":["../src/responses.ts"],"sourcesContent":["export interface IMeta {\n hasMoreItems: boolean;\n totalCount: number;\n cursor?: string | null;\n}\n\nexport 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\n/** GraphQL error response helper. */\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\n/** GraphQL not-found response helper. */\nexport class NotFoundResponse extends ErrorResponse {\n constructor(message: string) {\n super({\n code: \"NOT_FOUND\",\n message\n });\n }\n}\n\n/** GraphQL list error response helper. */\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\n/** GraphQL response helper. */\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\n/** GraphQL list response helper. */\nexport class ListResponse<T, M = IMeta> {\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"],"names":["defaultParams","ErrorResponse","params","debug","process","stack","NotFoundResponse","message","ListErrorResponse","Response","data","ListResponse","meta","Array"],"mappings":"AAaA,MAAMA,gBAA+C;IACjD,MAAM;IACN,SAAS;IACT,MAAM;IACN,OAAO;AACX;AAGO,MAAMC;IAST,YAAYC,MAA2B,CAAE;QACrC,IAAI,CAAC,IAAI,GAAG;QAEZ,MAAMC,QAAQC,AAAsB,WAAtBA,QAAQ,GAAG,CAAC,KAAK;QAG/B,IAAIC,QAAQL,cAAc,KAAK;QAC/B,IAAIG,SAASD,OAAO,KAAK,EACrBG,QAAQH,OAAO,KAAK;QAGxB,IAAI,CAAC,KAAK,GAAG;YACT,MAAMA,OAAO,IAAI,IAAIF,cAAc,IAAI;YACvC,SAASE,OAAO,OAAO,IAAIF,cAAc,OAAO;YAChD,MAAME,OAAO,IAAI,IAAIF,cAAc,IAAI;YACvC,OAAOK;QACX;IACJ;AACJ;AAGO,MAAMC,yBAAyBL;IAClC,YAAYM,OAAe,CAAE;QACzB,KAAK,CAAC;YACF,MAAM;YACNA;QACJ;IACJ;AACJ;AAGO,MAAMC;IAUT,YAAYN,MAA2B,CAAE;QACrC,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,IAAI,GAAG;QAEZ,MAAMC,QAAQC,AAAsB,WAAtBA,QAAQ,GAAG,CAAC,KAAK;QAG/B,IAAIC,QAAQL,cAAc,KAAK;QAC/B,IAAIG,SAASD,OAAO,KAAK,EACrBG,QAAQH,OAAO,KAAK;QAGxB,IAAI,CAAC,KAAK,GAAG;YACT,MAAMA,OAAO,IAAI,IAAIF,cAAc,IAAI;YACvC,SAASE,OAAO,OAAO,IAAIF,cAAc,OAAO;YAChD,MAAME,OAAO,IAAI,IAAIF,cAAc,IAAI;YACvC,OAAOK;QACX;IACJ;AACJ;AAGO,MAAMI;IAIT,YAAYC,IAAO,CAAE;QACjB,IAAI,CAAC,IAAI,GAAGA;QACZ,IAAI,CAAC,KAAK,GAAG;IACjB;AACJ;AAGO,MAAMC;IAKT,YAAYD,IAAc,EAAEE,IAAQ,CAAE;QAClC,IAAI,CAAC,IAAI,GAAGC,MAAM,OAAO,CAACH,QAAQA,OAAO,EAAE;QAC3C,IAAI,CAAC,IAAI,GAAGE,QAAS,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG;IACjB;AACJ"}
package/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { GraphQLScalarType, GraphQLFieldResolver as BaseGraphQLFieldResolver, GraphQLSchema } from "graphql";
2
- import type { Plugin } from "@webiny/plugins/types";
3
- import type { Context, GenericRecord } from "@webiny/api/types";
4
- import type { RouteMethodPath } from "@webiny/handler/types";
2
+ import type { Plugin } from "@webiny/plugins/types.js";
3
+ import type { Context, GenericRecord } from "@webiny/api/types.js";
4
+ import type { RouteMethodPath } from "@webiny/handler/types.js";
5
5
  import type { ResolversComposition } from "@graphql-tools/resolvers-composition";
6
6
  import type { IResolvers, TypeSource } from "@graphql-tools/utils";
7
7
  export interface GraphQLScalarPlugin extends Plugin {
@@ -26,7 +26,7 @@ export interface GraphQLSchemaPluginTypeArgs {
26
26
  export type Resolvers<TContext> = IResolvers<any, TContext>;
27
27
  export type ResolverDecorator<TSource = any, TContext = any, TArgs = any> = ResolversComposition<GraphQLFieldResolver<TSource, TContext, TArgs>>;
28
28
  export type ResolverDecorators = GenericRecord<string, ResolverDecorator[]>;
29
- export interface GraphQLSchemaDefinition<TContext> {
29
+ export interface GraphQLSchemaDefinition<TContext = any> {
30
30
  typeDefs: TypeDefs;
31
31
  resolvers?: Resolvers<TContext>;
32
32
  resolverDecorators?: ResolverDecorators;
@@ -37,8 +37,8 @@ export interface GraphQLSchemaPlugin<TContext extends Context = Context> extends
37
37
  }
38
38
  export interface GraphQLRequestBody {
39
39
  query: string;
40
- variables: Record<string, any>;
41
- operationName: string;
40
+ variables?: Record<string, any> | null;
41
+ operationName?: string;
42
42
  }
43
43
  export interface GraphQLBeforeQueryPlugin<TContext extends Context = Context> extends Plugin {
44
44
  type: "graphql-before-query";
package/types.js CHANGED
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- //# sourceMappingURL=types.js.map
package/utils/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./resolve";
1
+ export * from "./resolve.js";
package/utils/index.js CHANGED
@@ -1,18 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _resolve = require("./resolve");
7
- Object.keys(_resolve).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _resolve[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _resolve[key];
14
- }
15
- });
16
- });
17
-
18
- //# sourceMappingURL=index.js.map
1
+ export * from "./resolve.js";
@@ -1,5 +1,5 @@
1
- import { ErrorResponse, ListErrorResponse, ListResponse, Response } from "../responses";
2
- import type { GenericRecord } from "@webiny/api/types";
1
+ import { ErrorResponse, ListErrorResponse, ListResponse, Response } from "../responses.js";
2
+ import type { GenericRecord } from "@webiny/api/types.js";
3
3
  export interface Meta {
4
4
  totalCount: number;
5
5
  hasMoreItems: boolean;
package/utils/resolve.js CHANGED
@@ -1,28 +1,20 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.resolveList = exports.resolve = exports.emptyResolver = void 0;
7
- var _responses = require("../responses");
8
- const emptyResolver = () => ({});
9
- exports.emptyResolver = emptyResolver;
10
- const resolve = async fn => {
11
- try {
12
- return new _responses.Response(await fn());
13
- } catch (ex) {
14
- return new _responses.ErrorResponse(ex);
15
- }
1
+ import { ErrorResponse, ListErrorResponse, ListResponse, Response } from "../responses.js";
2
+ const emptyResolver = ()=>({});
3
+ const resolve = async (fn)=>{
4
+ try {
5
+ return new Response(await fn());
6
+ } catch (ex) {
7
+ return new ErrorResponse(ex);
8
+ }
16
9
  };
17
- exports.resolve = resolve;
18
- const resolveList = async fn => {
19
- try {
20
- const result = await fn();
21
- return new _responses.ListResponse(result.items, result.meta);
22
- } catch (ex) {
23
- return new _responses.ListErrorResponse(ex);
24
- }
10
+ const resolveList = async (fn)=>{
11
+ try {
12
+ const result = await fn();
13
+ return new ListResponse(result.items, result.meta);
14
+ } catch (ex) {
15
+ return new ListErrorResponse(ex);
16
+ }
25
17
  };
26
- exports.resolveList = resolveList;
18
+ export { emptyResolver, resolve, resolveList };
27
19
 
28
20
  //# sourceMappingURL=resolve.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_responses","require","emptyResolver","exports","resolve","fn","Response","ex","ErrorResponse","resolveList","result","ListResponse","items","meta","ListErrorResponse"],"sources":["resolve.ts"],"sourcesContent":["import { ErrorResponse, ListErrorResponse, ListResponse, Response } from \"~/responses\";\nimport type { GenericRecord } from \"@webiny/api/types\";\n\nexport interface Meta {\n totalCount: number;\n hasMoreItems: boolean;\n cursor: string | null;\n}\n\nexport const emptyResolver = () => ({});\n\ninterface ResolveCallable<T = GenericRecord> {\n (): Promise<T>;\n}\n\nexport const resolve = async <T = GenericRecord>(fn: ResolveCallable<T>) => {\n try {\n return new Response(await fn());\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\ninterface ResolveListCallable<T> {\n (): Promise<IListResult<T>>;\n}\n\ninterface IListResult<T = GenericRecord> {\n items: T[];\n meta: Meta;\n}\n\nexport const resolveList = async <T = GenericRecord>(fn: ResolveListCallable<T>) => {\n try {\n const result = (await fn()) as IListResult<T>;\n return new ListResponse(result.items, result.meta);\n } catch (ex) {\n return new ListErrorResponse(ex);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AASO,MAAMC,aAAa,GAAGA,CAAA,MAAO,CAAC,CAAC,CAAC;AAACC,OAAA,CAAAD,aAAA,GAAAA,aAAA;AAMjC,MAAME,OAAO,GAAG,MAA0BC,EAAsB,IAAK;EACxE,IAAI;IACA,OAAO,IAAIC,mBAAQ,CAAC,MAAMD,EAAE,CAAC,CAAC,CAAC;EACnC,CAAC,CAAC,OAAOE,EAAE,EAAE;IACT,OAAO,IAAIC,wBAAa,CAACD,EAAE,CAAC;EAChC;AACJ,CAAC;AAACJ,OAAA,CAAAC,OAAA,GAAAA,OAAA;AAWK,MAAMK,WAAW,GAAG,MAA0BJ,EAA0B,IAAK;EAChF,IAAI;IACA,MAAMK,MAAM,GAAI,MAAML,EAAE,CAAC,CAAoB;IAC7C,OAAO,IAAIM,uBAAY,CAACD,MAAM,CAACE,KAAK,EAAEF,MAAM,CAACG,IAAI,CAAC;EACtD,CAAC,CAAC,OAAON,EAAE,EAAE;IACT,OAAO,IAAIO,4BAAiB,CAACP,EAAE,CAAC;EACpC;AACJ,CAAC;AAACJ,OAAA,CAAAM,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"file":"utils/resolve.js","sources":["../../src/utils/resolve.ts"],"sourcesContent":["import { ErrorResponse, ListErrorResponse, ListResponse, Response } from \"~/responses.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport interface Meta {\n totalCount: number;\n hasMoreItems: boolean;\n cursor: string | null;\n}\n\nexport const emptyResolver = () => ({});\n\ninterface ResolveCallable<T = GenericRecord> {\n (): Promise<T>;\n}\n\nexport const resolve = async <T = GenericRecord>(fn: ResolveCallable<T>) => {\n try {\n return new Response(await fn());\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\ninterface ResolveListCallable<T> {\n (): Promise<IListResult<T>>;\n}\n\ninterface IListResult<T = GenericRecord> {\n items: T[];\n meta: Meta;\n}\n\nexport const resolveList = async <T = GenericRecord>(fn: ResolveListCallable<T>) => {\n try {\n const result = (await fn()) as IListResult<T>;\n return new ListResponse(result.items, result.meta);\n } catch (ex) {\n return new ListErrorResponse(ex);\n }\n};\n"],"names":["emptyResolver","resolve","fn","Response","ex","ErrorResponse","resolveList","result","ListResponse","ListErrorResponse"],"mappings":";AASO,MAAMA,gBAAgB,IAAO,EAAC;AAM9B,MAAMC,UAAU,OAA0BC;IAC7C,IAAI;QACA,OAAO,IAAIC,SAAS,MAAMD;IAC9B,EAAE,OAAOE,IAAI;QACT,OAAO,IAAIC,cAAcD;IAC7B;AACJ;AAWO,MAAME,cAAc,OAA0BJ;IACjD,IAAI;QACA,MAAMK,SAAU,MAAML;QACtB,OAAO,IAAIM,aAAaD,OAAO,KAAK,EAAEA,OAAO,IAAI;IACrD,EAAE,OAAOH,IAAI;QACT,OAAO,IAAIK,kBAAkBL;IACjC;AACJ"}