@webiny/handler-graphql 0.0.0-unstable.6f45466a1d → 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.
Files changed (74) hide show
  1. package/ResolverDecoration.js +18 -14
  2. package/ResolverDecoration.js.map +1 -1
  3. package/builtInTypes/AnyScalar.js +7 -8
  4. package/builtInTypes/AnyScalar.js.map +1 -1
  5. package/builtInTypes/DateScalar.js +12 -18
  6. package/builtInTypes/DateScalar.js.map +1 -1
  7. package/builtInTypes/DateTimeScalar.js +12 -18
  8. package/builtInTypes/DateTimeScalar.js.map +1 -1
  9. package/builtInTypes/DateTimeZScalar.js +23 -35
  10. package/builtInTypes/DateTimeZScalar.js.map +1 -1
  11. package/builtInTypes/IconScalar.js +59 -87
  12. package/builtInTypes/IconScalar.js.map +1 -1
  13. package/builtInTypes/JsonScalar.js +2 -1
  14. package/builtInTypes/JsonScalar.js.map +1 -1
  15. package/builtInTypes/LongScalar.js +30 -39
  16. package/builtInTypes/LongScalar.js.map +1 -1
  17. package/builtInTypes/NumberScalar.js +31 -38
  18. package/builtInTypes/NumberScalar.js.map +1 -1
  19. package/builtInTypes/RefInputScalar.js +45 -68
  20. package/builtInTypes/RefInputScalar.js.map +1 -1
  21. package/builtInTypes/TimeScalar.js +28 -41
  22. package/builtInTypes/TimeScalar.js.map +1 -1
  23. package/builtInTypes/index.js +0 -2
  24. package/createGraphQLHandler.js +69 -80
  25. package/createGraphQLHandler.js.map +1 -1
  26. package/createGraphQLSchema.js +49 -66
  27. package/createGraphQLSchema.js.map +1 -1
  28. package/createRequestBody.js +22 -20
  29. package/createRequestBody.js.map +1 -1
  30. package/createResolverDecorator.js +2 -3
  31. package/createResolverDecorator.js.map +1 -1
  32. package/debugPlugins.js +24 -27
  33. package/debugPlugins.js.map +1 -1
  34. package/errors.js +6 -5
  35. package/errors.js.map +1 -1
  36. package/exports/api/graphql.js +1 -3
  37. package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js +52 -59
  38. package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js.map +1 -1
  39. package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js +27 -21
  40. package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js.map +1 -1
  41. package/features/GraphQLSchemaBuilder/abstractions.js +3 -2
  42. package/features/GraphQLSchemaBuilder/abstractions.js.map +1 -1
  43. package/features/GraphQLSchemaBuilder/feature.d.ts +4 -1
  44. package/features/GraphQLSchemaBuilder/feature.js +6 -5
  45. package/features/GraphQLSchemaBuilder/feature.js.map +1 -1
  46. package/graphql/abstractions.core.js +2 -7
  47. package/graphql/abstractions.core.js.map +1 -1
  48. package/graphql/abstractions.js +0 -2
  49. package/graphql/abstractions.public.d.ts +2 -3
  50. package/graphql/abstractions.public.js +2 -9
  51. package/graphql/abstractions.public.js.map +1 -1
  52. package/index.js +2 -3
  53. package/index.js.map +1 -1
  54. package/interceptConsole.js +30 -27
  55. package/interceptConsole.js.map +1 -1
  56. package/package.json +29 -24
  57. package/plugins/GraphQLSchemaPlugin.js +20 -21
  58. package/plugins/GraphQLSchemaPlugin.js.map +1 -1
  59. package/plugins/index.js +0 -2
  60. package/processRequestBody.js +33 -36
  61. package/processRequestBody.js.map +1 -1
  62. package/responses.d.ts +11 -1
  63. package/responses.js +48 -55
  64. package/responses.js.map +1 -1
  65. package/types.js +0 -3
  66. package/utils/index.js +0 -2
  67. package/utils/resolve.js +15 -14
  68. package/utils/resolve.js.map +1 -1
  69. package/builtInTypes/index.js.map +0 -1
  70. package/exports/api/graphql.js.map +0 -1
  71. package/graphql/abstractions.js.map +0 -1
  72. package/plugins/index.js.map +0 -1
  73. package/types.js.map +0 -1
  74. package/utils/index.js.map +0 -1
@@ -1 +1,4 @@
1
- export declare const GraphQLSchemaComposerFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
1
+ export declare const GraphQLSchemaComposerFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -1,10 +1,11 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { GraphQLSchemaComposer } from "./GraphQLSchemaComposer.js";
3
- export const GraphQLSchemaComposerFeature = createFeature({
4
- name: "GraphQLSchemaComposer",
5
- register(container) {
6
- container.register(GraphQLSchemaComposer);
7
- }
3
+ const GraphQLSchemaComposerFeature = createFeature({
4
+ name: "GraphQLSchemaComposer",
5
+ register (container) {
6
+ container.register(GraphQLSchemaComposer);
7
+ }
8
8
  });
9
+ export { GraphQLSchemaComposerFeature };
9
10
 
10
11
  //# sourceMappingURL=feature.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFeature","GraphQLSchemaComposer","GraphQLSchemaComposerFeature","name","register","container"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GraphQLSchemaComposer } from \"./GraphQLSchemaComposer.js\";\n\nexport const GraphQLSchemaComposerFeature = createFeature({\n name: \"GraphQLSchemaComposer\",\n register(container) {\n container.register(GraphQLSchemaComposer);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,4BAA4B,GAAGF,aAAa,CAAC;EACtDG,IAAI,EAAE,uBAAuB;EAC7BC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,qBAAqB,CAAC;EAC7C;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/GraphQLSchemaBuilder/feature.js","sources":["../../../src/features/GraphQLSchemaBuilder/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GraphQLSchemaComposer } from \"./GraphQLSchemaComposer.js\";\n\nexport const GraphQLSchemaComposerFeature = createFeature({\n name: \"GraphQLSchemaComposer\",\n register(container) {\n container.register(GraphQLSchemaComposer);\n }\n});\n"],"names":["GraphQLSchemaComposerFeature","createFeature","container","GraphQLSchemaComposer"],"mappings":";;AAGO,MAAMA,+BAA+BC,cAAc;IACtD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
@@ -1,10 +1,5 @@
1
- /**
2
- * This file contains abstraction for use by the core Webiny team, or anyone contributing to the webiny-js repository.
3
- */
4
1
  import { createAbstraction } from "@webiny/feature/api";
5
- /**
6
- * CoreGraphQLSchemaFactory
7
- */
8
- export const CoreGraphQLSchemaFactory = createAbstraction("CoreGraphQLSchemaFactory");
2
+ const CoreGraphQLSchemaFactory = createAbstraction("CoreGraphQLSchemaFactory");
3
+ export { CoreGraphQLSchemaFactory };
9
4
 
10
5
  //# sourceMappingURL=abstractions.core.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","CoreGraphQLSchemaFactory"],"sources":["abstractions.core.ts"],"sourcesContent":["/**\n * This file contains abstraction for use by the core Webiny team, or anyone contributing to the webiny-js repository.\n */\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { IGraphQLSchemaFactory } from \"./abstractions.public.js\";\nimport type { GraphQLSchemaBuilder } from \"~/features/GraphQLSchemaBuilder/abstractions.js\";\n\n/**\n * CoreGraphQLSchemaFactory\n */\nexport const CoreGraphQLSchemaFactory = createAbstraction<IGraphQLSchemaFactory>(\n \"CoreGraphQLSchemaFactory\"\n);\nexport namespace CoreGraphQLSchemaFactory {\n export type Interface = IGraphQLSchemaFactory;\n export type SchemaBuilder = GraphQLSchemaBuilder.Interface;\n export type Return = Promise<GraphQLSchemaBuilder.Interface>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,iBAAiB,QAAQ,qBAAqB;AAIvD;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAGD,iBAAiB,CACrD,0BACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"graphql/abstractions.core.js","sources":["../../src/graphql/abstractions.core.ts"],"sourcesContent":["/**\n * This file contains abstraction for use by the core Webiny team, or anyone contributing to the webiny-js repository.\n */\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { IGraphQLSchemaFactory } from \"./abstractions.public.js\";\nimport type { GraphQLSchemaBuilder } from \"~/features/GraphQLSchemaBuilder/abstractions.js\";\n\n/**\n * CoreGraphQLSchemaFactory\n */\nexport const CoreGraphQLSchemaFactory = createAbstraction<IGraphQLSchemaFactory>(\n \"CoreGraphQLSchemaFactory\"\n);\nexport namespace CoreGraphQLSchemaFactory {\n export type Interface = IGraphQLSchemaFactory;\n export type SchemaBuilder = GraphQLSchemaBuilder.Interface;\n export type Return = Promise<GraphQLSchemaBuilder.Interface>;\n}\n"],"names":["CoreGraphQLSchemaFactory","createAbstraction"],"mappings":";AAUO,MAAMA,2BAA2BC,kBACpC"}
@@ -1,4 +1,2 @@
1
1
  export * from "./abstractions.core.js";
2
2
  export * from "./abstractions.public.js";
3
-
4
- //# sourceMappingURL=abstractions.js.map
@@ -5,12 +5,11 @@ export interface IGraphQLSchema {
5
5
  resolvers?: IResolvers<any>;
6
6
  resolverDecorators?: IResolverDecorators;
7
7
  }
8
- /**
9
- * GraphQLSchemaFactory
10
- */
8
+ /** Define custom GraphQL schema extensions. */
11
9
  export interface IGraphQLSchemaFactory {
12
10
  execute(builder: GraphQLSchemaBuilder.Interface): Promise<GraphQLSchemaBuilder.Interface>;
13
11
  }
12
+ /** Define custom GraphQL schema extensions. */
14
13
  export declare const GraphQLSchemaFactory: import("@webiny/di").Abstraction<IGraphQLSchemaFactory>;
15
14
  export declare namespace GraphQLSchemaFactory {
16
15
  type Interface = IGraphQLSchemaFactory;
@@ -1,12 +1,5 @@
1
- /**
2
- * This file contains abstraction for use by third party developers.
3
- */
4
1
  import { createAbstraction } from "@webiny/feature/api";
5
-
6
- /**
7
- * GraphQLSchemaFactory
8
- */
9
-
10
- export const GraphQLSchemaFactory = createAbstraction("GraphQLSchemaFactory");
2
+ const GraphQLSchemaFactory = createAbstraction("GraphQLSchemaFactory");
3
+ export { GraphQLSchemaFactory };
11
4
 
12
5
  //# sourceMappingURL=abstractions.public.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","GraphQLSchemaFactory"],"sources":["abstractions.public.ts"],"sourcesContent":["/**\n * This file contains abstraction for use by third party developers.\n */\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type {\n Resolvers as IResolvers,\n TypeDefs as ITypeDefs,\n ResolverDecorators as IResolverDecorators\n} from \"~/types.js\";\nimport type { GraphQLSchemaBuilder } from \"~/features/GraphQLSchemaBuilder/abstractions.js\";\n\nexport interface IGraphQLSchema {\n typeDefs?: ITypeDefs;\n resolvers?: IResolvers<any>;\n resolverDecorators?: IResolverDecorators;\n}\n\n/**\n * GraphQLSchemaFactory\n */\nexport interface IGraphQLSchemaFactory {\n execute(builder: GraphQLSchemaBuilder.Interface): Promise<GraphQLSchemaBuilder.Interface>;\n}\n\nexport const GraphQLSchemaFactory =\n createAbstraction<IGraphQLSchemaFactory>(\"GraphQLSchemaFactory\");\n\nexport namespace GraphQLSchemaFactory {\n export type Interface = IGraphQLSchemaFactory;\n export type SchemaBuilder = GraphQLSchemaBuilder.Interface;\n export type Return = Promise<GraphQLSchemaBuilder.Interface>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAcvD;AACA;AACA;;AAKA,OAAO,MAAMC,oBAAoB,GAC7BD,iBAAiB,CAAwB,sBAAsB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"graphql/abstractions.public.js","sources":["../../src/graphql/abstractions.public.ts"],"sourcesContent":["/**\n * This file contains abstraction for use by third party developers.\n */\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type {\n Resolvers as IResolvers,\n TypeDefs as ITypeDefs,\n ResolverDecorators as IResolverDecorators\n} from \"~/types.js\";\nimport type { GraphQLSchemaBuilder } from \"~/features/GraphQLSchemaBuilder/abstractions.js\";\n\nexport interface IGraphQLSchema {\n typeDefs?: ITypeDefs;\n resolvers?: IResolvers<any>;\n resolverDecorators?: IResolverDecorators;\n}\n\n/** Define custom GraphQL schema extensions. */\nexport interface IGraphQLSchemaFactory {\n execute(builder: GraphQLSchemaBuilder.Interface): Promise<GraphQLSchemaBuilder.Interface>;\n}\n\n/** Define custom GraphQL schema extensions. */\nexport const GraphQLSchemaFactory =\n createAbstraction<IGraphQLSchemaFactory>(\"GraphQLSchemaFactory\");\n\nexport namespace GraphQLSchemaFactory {\n export type Interface = IGraphQLSchemaFactory;\n export type SchemaBuilder = GraphQLSchemaBuilder.Interface;\n export type Return = Promise<GraphQLSchemaBuilder.Interface>;\n}\n"],"names":["GraphQLSchemaFactory","createAbstraction"],"mappings":";AAuBO,MAAMA,uBACTC,kBAAyC"}
package/index.js CHANGED
@@ -6,8 +6,7 @@ export * from "./plugins/index.js";
6
6
  export * from "./processRequestBody.js";
7
7
  export * from "./createResolverDecorator.js";
8
8
  export * from "./ResolverDecoration.js";
9
- export default (options = {}) => {
10
- return createGraphQLHandler(options);
11
- };
9
+ const src = (options = {})=>createGraphQLHandler(options);
10
+ export default src;
12
11
 
13
12
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["createGraphQLHandler","options"],"sources":["index.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\nimport type { HandlerGraphQLOptions } from \"./types.js\";\nimport createGraphQLHandler from \"./createGraphQLHandler.js\";\n\nexport * from \"./errors.js\";\nexport * from \"./responses.js\";\nexport * from \"./utils/index.js\";\nexport * from \"./plugins/index.js\";\nexport * from \"./processRequestBody.js\";\nexport * from \"./createResolverDecorator.js\";\nexport * from \"./ResolverDecoration.js\";\n\nexport default (options: HandlerGraphQLOptions = {}): Plugin[] => {\n return createGraphQLHandler(options);\n};\n"],"mappings":"AAEA,OAAOA,oBAAoB;AAE3B;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,eAAe,CAACC,OAA8B,GAAG,CAAC,CAAC,KAAe;EAC9D,OAAOD,oBAAoB,CAACC,OAAO,CAAC;AACxC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\nimport type { HandlerGraphQLOptions } from \"./types.js\";\nimport createGraphQLHandler from \"./createGraphQLHandler.js\";\n\nexport * from \"./errors.js\";\nexport * from \"./responses.js\";\nexport * from \"./utils/index.js\";\nexport * from \"./plugins/index.js\";\nexport * from \"./processRequestBody.js\";\nexport * from \"./createResolverDecorator.js\";\nexport * from \"./ResolverDecoration.js\";\n\nexport default (options: HandlerGraphQLOptions = {}): Plugin[] => {\n return createGraphQLHandler(options);\n};\n"],"names":["options","createGraphQLHandler"],"mappings":";;;;;;;;AAYA,YAAgB,CAAAA,UAAiC,CAAC,CAAC,GACxCC,qBAAqBD"}
@@ -1,32 +1,35 @@
1
- const consoleMethods = ["assert", "debug", "dir", "error", "group", "groupCollapsed", "groupEnd", "info", "log", "table", "warn"];
1
+ const consoleMethods = [
2
+ "assert",
3
+ "debug",
4
+ "dir",
5
+ "error",
6
+ "group",
7
+ "groupCollapsed",
8
+ "groupEnd",
9
+ "info",
10
+ "log",
11
+ "table",
12
+ "warn"
13
+ ];
2
14
  const originalMethods = {};
3
- const skipOriginal = ["table"];
4
- const restoreOriginalMethods = () => {
5
- for (const method of consoleMethods) {
6
- // @ts-expect-error
7
- console[method] = originalMethods[method];
8
- }
15
+ const skipOriginal = [
16
+ "table"
17
+ ];
18
+ const restoreOriginalMethods = ()=>{
19
+ for (const method of consoleMethods)console[method] = originalMethods[method];
9
20
  };
10
- export const interceptConsole = callback => {
11
- // @ts-expect-error
12
- if (console["__WEBINY__"] === true) {
13
- restoreOriginalMethods();
14
- }
15
-
16
- // @ts-expect-error
17
- console["__WEBINY__"] = true;
18
- for (const method of consoleMethods) {
19
- // @ts-expect-error
20
- originalMethods[method] = console[method];
21
- // @ts-expect-error
22
- console[method] = (...args) => {
23
- callback(method, args);
24
- if (skipOriginal.includes(method)) {
25
- return;
26
- }
27
- originalMethods[method](...args);
28
- };
29
- }
21
+ const interceptConsole = (callback)=>{
22
+ if (true === console["__WEBINY__"]) restoreOriginalMethods();
23
+ console["__WEBINY__"] = true;
24
+ for (const method of consoleMethods){
25
+ originalMethods[method] = console[method];
26
+ console[method] = (...args)=>{
27
+ callback(method, args);
28
+ if (skipOriginal.includes(method)) return;
29
+ originalMethods[method](...args);
30
+ };
31
+ }
30
32
  };
33
+ export { interceptConsole };
31
34
 
32
35
  //# sourceMappingURL=interceptConsole.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["consoleMethods","originalMethods","skipOriginal","restoreOriginalMethods","method","console","interceptConsole","callback","args","includes"],"sources":["interceptConsole.ts"],"sourcesContent":["const consoleMethods = [\n \"assert\",\n \"debug\",\n \"dir\",\n \"error\",\n \"group\",\n \"groupCollapsed\",\n \"groupEnd\",\n \"info\",\n \"log\",\n \"table\",\n \"warn\"\n];\n\nconst originalMethods: Record<string, any> = {};\nconst skipOriginal: string[] = [\"table\"];\n\nconst restoreOriginalMethods = () => {\n for (const method of consoleMethods) {\n // @ts-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;AAMD,OAAO,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","ignoreList":[]}
1
+ {"version":3,"file":"interceptConsole.js","sources":["../src/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"],"names":["consoleMethods","originalMethods","skipOriginal","restoreOriginalMethods","method","console","interceptConsole","callback","args"],"mappings":"AAAA,MAAMA,iBAAiB;IACnB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAED,MAAMC,kBAAuC,CAAC;AAC9C,MAAMC,eAAyB;IAAC;CAAQ;AAExC,MAAMC,yBAAyB;IAC3B,KAAK,MAAMC,UAAUJ,eAEjBK,OAAO,CAACD,OAAO,GAAGH,eAAe,CAACG,OAAO;AAEjD;AAMO,MAAME,mBAAmB,CAACC;IAE7B,IAAIF,AAA0B,SAA1BA,OAAO,CAAC,aAAa,EACrBF;IAIJE,OAAO,CAAC,aAAa,GAAG;IAExB,KAAK,MAAMD,UAAUJ,eAAgB;QAEjCC,eAAe,CAACG,OAAO,GAAGC,OAAO,CAACD,OAAO;QAEzCC,OAAO,CAACD,OAAO,GAAG,CAAC,GAAGI;YAClBD,SAASH,QAAQI;YACjB,IAAIN,aAAa,QAAQ,CAACE,SACtB;YAEJH,eAAe,CAACG,OAAO,IAAII;QAC/B;IACJ;AACJ"}
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@webiny/handler-graphql",
3
- "version": "0.0.0-unstable.6f45466a1d",
3
+ "version": "0.0.0-unstable.7be00a75a9",
4
4
  "type": "module",
5
- "main": "index.js",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
6
9
  "license": "MIT",
7
10
  "repository": {
8
11
  "type": "git",
@@ -15,33 +18,35 @@
15
18
  "Adrian Smijulj <adrian@webiny.com>"
16
19
  ],
17
20
  "dependencies": {
18
- "@graphql-tools/merge": "9.1.7",
19
- "@graphql-tools/resolvers-composition": "7.0.26",
20
- "@graphql-tools/schema": "10.0.31",
21
- "@graphql-tools/utils": "11.0.0",
22
- "@webiny/api": "0.0.0-unstable.6f45466a1d",
23
- "@webiny/di": "0.2.3",
24
- "@webiny/error": "0.0.0-unstable.6f45466a1d",
25
- "@webiny/feature": "0.0.0-unstable.6f45466a1d",
26
- "@webiny/handler": "0.0.0-unstable.6f45466a1d",
27
- "@webiny/plugins": "0.0.0-unstable.6f45466a1d",
28
- "@webiny/utils": "0.0.0-unstable.6f45466a1d",
29
- "boolean": "3.2.0",
30
- "graphql": "16.12.0",
21
+ "@graphql-tools/merge": "9.1.9",
22
+ "@graphql-tools/resolvers-composition": "7.0.31",
23
+ "@graphql-tools/schema": "10.0.33",
24
+ "@graphql-tools/utils": "11.1.0",
25
+ "@webiny/api": "0.0.0-unstable.7be00a75a9",
26
+ "@webiny/di": "0.0.0-unstable.7be00a75a9",
27
+ "@webiny/error": "0.0.0-unstable.7be00a75a9",
28
+ "@webiny/feature": "0.0.0-unstable.7be00a75a9",
29
+ "@webiny/handler": "0.0.0-unstable.7be00a75a9",
30
+ "@webiny/plugins": "0.0.0-unstable.7be00a75a9",
31
+ "@webiny/stdlib": "0.0.0-unstable.7be00a75a9",
32
+ "@webiny/utils": "0.0.0-unstable.7be00a75a9",
33
+ "graphql": "16.14.0",
31
34
  "graphql-scalars": "1.25.0",
32
35
  "graphql-tag": "2.12.6",
33
- "zod": "3.25.76"
36
+ "zod": "4.4.3"
34
37
  },
35
38
  "devDependencies": {
36
- "@webiny/build-tools": "0.0.0-unstable.6f45466a1d",
37
- "@webiny/handler-aws": "0.0.0-unstable.6f45466a1d",
38
- "rimraf": "6.1.2",
39
- "typescript": "5.9.3",
40
- "vitest": "3.2.4"
39
+ "@webiny/build-tools": "0.0.0-unstable.7be00a75a9",
40
+ "@webiny/handler-aws": "0.0.0-unstable.7be00a75a9",
41
+ "rimraf": "6.1.3",
42
+ "typescript": "6.0.3",
43
+ "vitest": "4.1.7"
41
44
  },
42
45
  "publishConfig": {
43
- "access": "public",
44
- "directory": "dist"
46
+ "access": "public"
45
47
  },
46
- "gitHead": "6f45466a1d9fb94f6156923501eb90ac303b81a5"
48
+ "gitHead": "b8aec8a1be3f25c3b428b357fe1e352c7cbff9ae",
49
+ "webiny": {
50
+ "publishFrom": "dist"
51
+ }
47
52
  }
@@ -1,26 +1,25 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- export class GraphQLSchemaPlugin extends Plugin {
3
- static type = "graphql-schema";
4
- constructor(config) {
5
- super();
6
- this.config = config;
7
- }
8
- get schema() {
9
- return {
10
- typeDefs: this.config.typeDefs || "",
11
- resolvers: this.config.resolvers,
12
- resolverDecorators: this.config.resolverDecorators
13
- };
14
- }
15
- isApplicable(context) {
16
- if (this.config.isApplicable) {
17
- return this.config.isApplicable(context);
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;
18
20
  }
19
- return true;
20
- }
21
21
  }
22
- export const createGraphQLSchemaPlugin = config => {
23
- return new GraphQLSchemaPlugin(config);
24
- };
22
+ const createGraphQLSchemaPlugin = (config)=>new GraphQLSchemaPlugin(config);
23
+ export { GraphQLSchemaPlugin, createGraphQLSchemaPlugin };
25
24
 
26
25
  //# sourceMappingURL=GraphQLSchemaPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Plugin","GraphQLSchemaPlugin","type","constructor","config","schema","typeDefs","resolvers","resolverDecorators","isApplicable","context","createGraphQLSchemaPlugin"],"sources":["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"],"mappings":"AACA,SAASA,MAAM,QAAQ,iBAAiB;AAexC,OAAO,MAAMC,mBAAmB,SACpBD,MAAM,CAElB;EACI,OAAgCE,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;AAEA,OAAO,MAAMC,yBAAyB,GAAiBP,MAAoC,IAAK;EAC5F,OAAO,IAAIH,mBAAmB,CAAIG,MAAM,CAAC;AAC7C,CAAC","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"}
package/plugins/index.js CHANGED
@@ -1,3 +1 @@
1
1
  export * from "./GraphQLSchemaPlugin.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1,43 +1,40 @@
1
1
  import { graphql } from "graphql";
2
- const executeGraphQl = async (body, schema, context) => {
3
- const {
4
- query,
5
- variables,
6
- operationName
7
- } = body;
8
- context.plugins.byType("graphql-before-query").forEach(pl => pl.apply({
9
- body,
10
- schema,
11
- context
12
- }));
13
- const result = await graphql({
14
- schema,
15
- source: query,
16
- rootValue: {},
17
- contextValue: context,
18
- variableValues: variables,
19
- operationName
20
- });
21
- context.plugins.byType("graphql-after-query").forEach(pl => {
22
- pl.apply({
23
- result,
24
- body,
25
- schema,
26
- context
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
27
16
  });
28
- });
29
- return result;
17
+ context.plugins.byType("graphql-after-query").forEach((pl)=>{
18
+ pl.apply({
19
+ result,
20
+ body,
21
+ schema,
22
+ context
23
+ });
24
+ });
25
+ return result;
30
26
  };
31
- export const processRequestBody = async (requestBody, schema, context) => {
32
- if (Array.isArray(requestBody)) {
33
- const results = [];
34
- for (const body of requestBody) {
35
- const result = await executeGraphQl(body, schema, context);
36
- 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;
37
35
  }
38
- return results;
39
- }
40
- return await executeGraphQl(requestBody, schema, context);
36
+ return await executeGraphQl(requestBody, schema, context);
41
37
  };
38
+ export { processRequestBody };
42
39
 
43
40
  //# sourceMappingURL=processRequestBody.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["graphql","executeGraphQl","body","schema","context","query","variables","operationName","plugins","byType","forEach","pl","apply","result","source","rootValue","contextValue","variableValues","processRequestBody","requestBody","Array","isArray","results","push"],"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.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"],"mappings":"AACA,SAASA,OAAO,QAAQ,SAAS;AAQjC,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,MAAMb,OAAO,CAAC;IACzBG,MAAM;IACNW,MAAM,EAAET,KAAK;IACbU,SAAS,EAAE,CAAC,CAAC;IACbC,YAAY,EAAEZ,OAAO;IACrBa,cAAc,EAAEX,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;AAED,OAAO,MAAMK,kBAAkB,GAAG,MAAAA,CAI9BC,WAAsD,EACtDhB,MAAqB,EACrBC,OAAgB,KACuE;EACvF,IAAIgB,KAAK,CAACC,OAAO,CAACF,WAAW,CAAC,EAAE;IAC5B,MAAMG,OAA8C,GAAG,EAAE;IACzD,KAAK,MAAMpB,IAAI,IAAIiB,WAAW,EAAE;MAC5B,MAAMN,MAAM,GAAG,MAAMZ,cAAc,CAAqBC,IAAI,EAAEC,MAAM,EAAEC,OAAO,CAAC;MAC9EkB,OAAO,CAACC,IAAI,CAACV,MAAM,CAAC;IACxB;IACA,OAAOS,OAAO;EAClB;EACA,OAAO,MAAMrB,cAAc,CAAqBkB,WAAW,EAAEhB,MAAM,EAAEC,OAAO,CAAC;AACjF,CAAC","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,66 +1,59 @@
1
1
  const defaultParams = {
2
- code: "",
3
- message: "",
4
- data: null,
5
- stack: null
2
+ code: "",
3
+ message: "",
4
+ data: null,
5
+ stack: null
6
6
  };
7
- export class ErrorResponse {
8
- constructor(params) {
9
- this.data = null;
10
- const debug = process.env.DEBUG === "true";
11
-
12
- // Ensure `stack` is either `string` or `null`.
13
- let stack = defaultParams.stack;
14
- if (debug && params.stack) {
15
- stack = params.stack;
7
+ class ErrorResponse {
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
+ };
16
19
  }
17
- this.error = {
18
- code: params.code || defaultParams.code,
19
- message: params.message || defaultParams.message,
20
- data: params.data || defaultParams.data,
21
- stack: stack
22
- };
23
- }
24
20
  }
25
- export class NotFoundResponse extends ErrorResponse {
26
- constructor(message) {
27
- super({
28
- code: "NOT_FOUND",
29
- message
30
- });
31
- }
21
+ class NotFoundResponse extends ErrorResponse {
22
+ constructor(message){
23
+ super({
24
+ code: "NOT_FOUND",
25
+ message
26
+ });
27
+ }
32
28
  }
33
- export class ListErrorResponse {
34
- constructor(params) {
35
- this.meta = null;
36
- this.data = null;
37
- const debug = process.env.DEBUG === "true";
38
-
39
- // Ensure `stack` is either `string` or `null`.
40
- let stack = defaultParams.stack;
41
- if (debug && params.stack) {
42
- stack = params.stack;
29
+ class ListErrorResponse {
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
+ };
43
42
  }
44
- this.error = {
45
- code: params.code || defaultParams.code,
46
- message: params.message || defaultParams.message,
47
- data: params.data || defaultParams.data,
48
- stack: stack
49
- };
50
- }
51
43
  }
52
- export class Response {
53
- constructor(data) {
54
- this.data = data;
55
- this.error = null;
56
- }
44
+ class Response {
45
+ constructor(data){
46
+ this.data = data;
47
+ this.error = null;
48
+ }
57
49
  }
58
- export class ListResponse {
59
- constructor(data, meta) {
60
- this.data = Array.isArray(data) ? data : [];
61
- this.meta = meta || {};
62
- this.error = null;
63
- }
50
+ class ListResponse {
51
+ constructor(data, meta){
52
+ this.data = Array.isArray(data) ? data : [];
53
+ this.meta = meta || {};
54
+ this.error = null;
55
+ }
64
56
  }
57
+ export { ErrorResponse, ListErrorResponse, ListResponse, NotFoundResponse, Response };
65
58
 
66
59
  //# sourceMappingURL=responses.js.map