@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.
Files changed (102) hide show
  1. package/README.md +9 -5
  2. package/ResolverDecoration.d.ts +6 -0
  3. package/ResolverDecoration.js +23 -0
  4. package/ResolverDecoration.js.map +1 -0
  5. package/builtInTypes/AnyScalar.d.ts +1 -1
  6. package/builtInTypes/AnyScalar.js +9 -18
  7. package/builtInTypes/AnyScalar.js.map +1 -1
  8. package/builtInTypes/DateScalar.d.ts +1 -1
  9. package/builtInTypes/DateScalar.js +16 -32
  10. package/builtInTypes/DateScalar.js.map +1 -1
  11. package/builtInTypes/DateTimeScalar.d.ts +1 -1
  12. package/builtInTypes/DateTimeScalar.js +16 -32
  13. package/builtInTypes/DateTimeScalar.js.map +1 -1
  14. package/builtInTypes/DateTimeZScalar.d.ts +1 -1
  15. package/builtInTypes/DateTimeZScalar.js +27 -58
  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 +4 -10
  22. package/builtInTypes/JsonScalar.js.map +1 -1
  23. package/builtInTypes/LongScalar.d.ts +2 -1
  24. package/builtInTypes/LongScalar.js +38 -9
  25. package/builtInTypes/LongScalar.js.map +1 -1
  26. package/builtInTypes/NumberScalar.d.ts +1 -1
  27. package/builtInTypes/NumberScalar.js +35 -58
  28. package/builtInTypes/NumberScalar.js.map +1 -1
  29. package/builtInTypes/RefInputScalar.d.ts +1 -1
  30. package/builtInTypes/RefInputScalar.js +48 -60
  31. package/builtInTypes/RefInputScalar.js.map +1 -1
  32. package/builtInTypes/TimeScalar.d.ts +1 -1
  33. package/builtInTypes/TimeScalar.js +31 -62
  34. package/builtInTypes/TimeScalar.js.map +1 -1
  35. package/builtInTypes/index.d.ts +10 -9
  36. package/builtInTypes/index.js +10 -122
  37. package/createGraphQLHandler.d.ts +3 -3
  38. package/createGraphQLHandler.js +77 -55
  39. package/createGraphQLHandler.js.map +1 -1
  40. package/createGraphQLSchema.d.ts +4 -2
  41. package/createGraphQLSchema.js +67 -54
  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 +2 -0
  47. package/createResolverDecorator.js +4 -0
  48. package/createResolverDecorator.js.map +1 -0
  49. package/debugPlugins.d.ts +2 -2
  50. package/debugPlugins.js +28 -45
  51. package/debugPlugins.js.map +1 -1
  52. package/errors.js +7 -17
  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 -5
  77. package/index.js +12 -57
  78. package/index.js.map +1 -1
  79. package/interceptConsole.js +31 -39
  80. package/interceptConsole.js.map +1 -1
  81. package/package.json +32 -29
  82. package/plugins/GraphQLSchemaPlugin.d.ts +13 -5
  83. package/plugins/GraphQLSchemaPlugin.js +23 -29
  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 +4 -5
  88. package/processRequestBody.js +35 -42
  89. package/processRequestBody.js.map +1 -1
  90. package/responses.d.ts +11 -1
  91. package/responses.js +44 -92
  92. package/responses.js.map +1 -1
  93. package/types.d.ts +20 -13
  94. package/types.js +0 -5
  95. package/utils/index.d.ts +1 -0
  96. package/utils/index.js +1 -0
  97. package/utils/resolve.d.ts +21 -0
  98. package/utils/resolve.js +20 -0
  99. package/utils/resolve.js.map +1 -0
  100. package/builtInTypes/index.js.map +0 -1
  101. package/plugins/index.js.map +0 -1
  102. package/types.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js","sources":["../../../src/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.ts"],"sourcesContent":["import type { GraphQLSchemaBuilder as Abstraction } from \"./abstractions.js\";\nimport type { IGraphQLSchema } from \"~/graphql/abstractions.public.js\";\nimport type { ResolverDecorator, ResolverDecorators, Resolvers } from \"~/types.js\";\nimport type { Dependency } from \"@webiny/di\";\n\nexport class GraphQLSchemaBuilder implements Abstraction.Interface {\n private readonly typeDefsArray: string[] = [];\n private readonly resolvers: Resolvers<any> = {};\n private readonly resolverDecorators: ResolverDecorators = {};\n\n addTypeDefs(typeDefs: string): this {\n this.typeDefsArray.push(typeDefs);\n return this;\n }\n\n addResolver<TArgs = any>(config: Abstraction.Config<TArgs>): this {\n const { path, dependencies = [], resolver } = config;\n\n const pathParts = path.split(\".\");\n\n const graphqlResolver = (parent: any, args: TArgs, context: any, info: any) => {\n const resolvedDeps = dependencies.map((dep: Dependency) => {\n const [abstraction] = Array.isArray(dep) ? dep : [dep];\n return context.container.resolve(abstraction);\n });\n\n const actualResolver = resolver(...resolvedDeps);\n\n return actualResolver({ parent, args, context, info });\n };\n\n this.setResolverAtPath(pathParts, graphqlResolver);\n\n return this;\n }\n\n /**\n * @internal This method needs revisiting, to align with DI concepts.\n */\n addResolverDecorator(path: string, decorator: ResolverDecorator): this {\n if (!this.resolverDecorators[path]) {\n this.resolverDecorators[path] = [];\n }\n this.resolverDecorators[path].push(decorator);\n return this;\n }\n\n build(): IGraphQLSchema {\n return {\n typeDefs: this.typeDefsArray.join(\"\\n\"),\n resolvers: this.resolvers,\n resolverDecorators: this.resolverDecorators\n };\n }\n\n private setResolverAtPath(pathParts: string[], resolver: any): void {\n let current: any = this.resolvers;\n\n for (let i = 0; i < pathParts.length - 1; i++) {\n const part = pathParts[i];\n if (!current[part]) {\n current[part] = {};\n }\n current = current[part];\n }\n\n const finalKey = pathParts[pathParts.length - 1];\n current[finalKey] = resolver;\n }\n}\n"],"names":["GraphQLSchemaBuilder","typeDefs","config","path","dependencies","resolver","pathParts","graphqlResolver","parent","args","context","info","resolvedDeps","dep","abstraction","Array","actualResolver","decorator","current","i","part","finalKey"],"mappings":"AAKO,MAAMA;IAKT,YAAYC,QAAgB,EAAQ;QAChC,IAAI,CAAC,aAAa,CAAC,IAAI,CAACA;QACxB,OAAO,IAAI;IACf;IAEA,YAAyBC,MAAiC,EAAQ;QAC9D,MAAM,EAAEC,IAAI,EAAEC,eAAe,EAAE,EAAEC,QAAQ,EAAE,GAAGH;QAE9C,MAAMI,YAAYH,KAAK,KAAK,CAAC;QAE7B,MAAMI,kBAAkB,CAACC,QAAaC,MAAaC,SAAcC;YAC7D,MAAMC,eAAeR,aAAa,GAAG,CAAC,CAACS;gBACnC,MAAM,CAACC,YAAY,GAAGC,MAAM,OAAO,CAACF,OAAOA,MAAM;oBAACA;iBAAI;gBACtD,OAAOH,QAAQ,SAAS,CAAC,OAAO,CAACI;YACrC;YAEA,MAAME,iBAAiBX,YAAYO;YAEnC,OAAOI,eAAe;gBAAER;gBAAQC;gBAAMC;gBAASC;YAAK;QACxD;QAEA,IAAI,CAAC,iBAAiB,CAACL,WAAWC;QAElC,OAAO,IAAI;IACf;IAKA,qBAAqBJ,IAAY,EAAEc,SAA4B,EAAQ;QACnE,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAACd,KAAK,EAC9B,IAAI,CAAC,kBAAkB,CAACA,KAAK,GAAG,EAAE;QAEtC,IAAI,CAAC,kBAAkB,CAACA,KAAK,CAAC,IAAI,CAACc;QACnC,OAAO,IAAI;IACf;IAEA,QAAwB;QACpB,OAAO;YACH,UAAU,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;YAClC,WAAW,IAAI,CAAC,SAAS;YACzB,oBAAoB,IAAI,CAAC,kBAAkB;QAC/C;IACJ;IAEQ,kBAAkBX,SAAmB,EAAED,QAAa,EAAQ;QAChE,IAAIa,UAAe,IAAI,CAAC,SAAS;QAEjC,IAAK,IAAIC,IAAI,GAAGA,IAAIb,UAAU,MAAM,GAAG,GAAGa,IAAK;YAC3C,MAAMC,OAAOd,SAAS,CAACa,EAAE;YACzB,IAAI,CAACD,OAAO,CAACE,KAAK,EACdF,OAAO,CAACE,KAAK,GAAG,CAAC;YAErBF,UAAUA,OAAO,CAACE,KAAK;QAC3B;QAEA,MAAMC,WAAWf,SAAS,CAACA,UAAU,MAAM,GAAG,EAAE;QAChDY,OAAO,CAACG,SAAS,GAAGhB;IACxB;;aA9DiB,aAAa,GAAa,EAAE;aAC5B,SAAS,GAAmB,CAAC;aAC7B,kBAAkB,GAAuB,CAAC;;AA6D/D"}
@@ -0,0 +1,13 @@
1
+ import { GraphQLSchemaComposer as Abstraction } from "./abstractions.js";
2
+ import { GraphQLSchemaFactory, CoreGraphQLSchemaFactory } from "../../graphql/abstractions.js";
3
+ import type { IGraphQLSchema } from "../../graphql/abstractions.public.js";
4
+ declare class GraphQLSchemaComposerImpl implements Abstraction.Interface {
5
+ private coreSchemas;
6
+ private userSchemas;
7
+ constructor(coreSchemas: CoreGraphQLSchemaFactory.Interface[], userSchemas: GraphQLSchemaFactory.Interface[]);
8
+ build(): Promise<IGraphQLSchema>;
9
+ }
10
+ export declare const GraphQLSchemaComposer: typeof GraphQLSchemaComposerImpl & {
11
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGraphQLSchemaComposer>;
12
+ };
13
+ export {};
@@ -0,0 +1,35 @@
1
+ import { GraphQLSchemaComposer } from "./abstractions.js";
2
+ import { CoreGraphQLSchemaFactory, GraphQLSchemaFactory } from "../../graphql/abstractions.js";
3
+ import { GraphQLSchemaBuilder } from "./GraphQLSchemaBuilder.js";
4
+ class GraphQLSchemaComposerImpl {
5
+ constructor(coreSchemas, userSchemas){
6
+ this.coreSchemas = coreSchemas;
7
+ this.userSchemas = userSchemas;
8
+ }
9
+ async build() {
10
+ const builder = new GraphQLSchemaBuilder();
11
+ for (const factory of this.coreSchemas)await factory.execute(builder);
12
+ for (const factory of this.userSchemas)await factory.execute(builder);
13
+ return builder.build();
14
+ }
15
+ }
16
+ const GraphQLSchemaComposer_GraphQLSchemaComposer = GraphQLSchemaComposer.createImplementation({
17
+ implementation: GraphQLSchemaComposerImpl,
18
+ dependencies: [
19
+ [
20
+ CoreGraphQLSchemaFactory,
21
+ {
22
+ multiple: true
23
+ }
24
+ ],
25
+ [
26
+ GraphQLSchemaFactory,
27
+ {
28
+ multiple: true
29
+ }
30
+ ]
31
+ ]
32
+ });
33
+ export { GraphQLSchemaComposer_GraphQLSchemaComposer as GraphQLSchemaComposer };
34
+
35
+ //# sourceMappingURL=GraphQLSchemaComposer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js","sources":["../../../src/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.ts"],"sourcesContent":["import { GraphQLSchemaComposer as Abstraction } from \"./abstractions.js\";\nimport { GraphQLSchemaFactory, CoreGraphQLSchemaFactory } from \"~/graphql/abstractions.js\";\nimport { GraphQLSchemaBuilder } from \"./GraphQLSchemaBuilder.js\";\nimport type { IGraphQLSchema } from \"~/graphql/abstractions.public.js\";\n\nclass GraphQLSchemaComposerImpl implements Abstraction.Interface {\n constructor(\n private coreSchemas: CoreGraphQLSchemaFactory.Interface[],\n private userSchemas: GraphQLSchemaFactory.Interface[]\n ) {}\n\n async build(): Promise<IGraphQLSchema> {\n const builder = new GraphQLSchemaBuilder();\n\n for (const factory of this.coreSchemas) {\n await factory.execute(builder);\n }\n\n for (const factory of this.userSchemas) {\n await factory.execute(builder);\n }\n\n return builder.build();\n }\n}\n\nexport const GraphQLSchemaComposer = Abstraction.createImplementation({\n implementation: GraphQLSchemaComposerImpl,\n dependencies: [\n [CoreGraphQLSchemaFactory, { multiple: true }],\n [GraphQLSchemaFactory, { multiple: true }]\n ]\n});\n"],"names":["GraphQLSchemaComposerImpl","coreSchemas","userSchemas","builder","GraphQLSchemaBuilder","factory","GraphQLSchemaComposer","Abstraction","CoreGraphQLSchemaFactory","GraphQLSchemaFactory"],"mappings":";;;AAKA,MAAMA;IACF,YACYC,WAAiD,EACjDC,WAA6C,CACvD;aAFUD,WAAW,GAAXA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QAAiC;QACnC,MAAMC,UAAU,IAAIC;QAEpB,KAAK,MAAMC,WAAW,IAAI,CAAC,WAAW,CAClC,MAAMA,QAAQ,OAAO,CAACF;QAG1B,KAAK,MAAME,WAAW,IAAI,CAAC,WAAW,CAClC,MAAMA,QAAQ,OAAO,CAACF;QAG1B,OAAOA,QAAQ,KAAK;IACxB;AACJ;AAEO,MAAMG,8CAAwBC,sBAAAA,oBAAgC,CAAC;IAClE,gBAAgBP;IAChB,cAAc;QACV;YAACQ;YAA0B;gBAAE,UAAU;YAAK;SAAE;QAC9C;YAACC;YAAsB;gBAAE,UAAU;YAAK;SAAE;KAC7C;AACL"}
@@ -0,0 +1,34 @@
1
+ import type { ResolverDecorator, TypeDefs } from "../../types.js";
2
+ import type { Dependency } from "@webiny/di";
3
+ import type { IGraphQLSchema } from "../../graphql/abstractions.public.js";
4
+ export interface ResolverConfig<TArgs = any, TParent = any> {
5
+ path: string;
6
+ dependencies?: Dependency[];
7
+ resolver: (...resolvedDeps: any[]) => (params: {
8
+ parent: TParent;
9
+ args: TArgs;
10
+ context: any;
11
+ info: any;
12
+ }) => any;
13
+ }
14
+ export interface IGraphQLSchemaBuilder {
15
+ addTypeDefs(typeDefs: TypeDefs): this;
16
+ addResolver<TArgs = any, TParent = any>(config: ResolverConfig<TArgs, TParent>): this;
17
+ /**
18
+ * @internal This method needs revisiting, to align with DI concepts.
19
+ */
20
+ addResolverDecorator(path: string, decorator: ResolverDecorator): this;
21
+ build(): IGraphQLSchema;
22
+ }
23
+ export declare const GraphQLSchemaBuilder: import("@webiny/di").Abstraction<IGraphQLSchemaBuilder>;
24
+ export declare namespace GraphQLSchemaBuilder {
25
+ type Interface = IGraphQLSchemaBuilder;
26
+ type Config<TArgs = any> = ResolverConfig<TArgs>;
27
+ }
28
+ export interface IGraphQLSchemaComposer {
29
+ build(): Promise<IGraphQLSchema>;
30
+ }
31
+ export declare const GraphQLSchemaComposer: import("@webiny/di").Abstraction<IGraphQLSchemaComposer>;
32
+ export declare namespace GraphQLSchemaComposer {
33
+ type Interface = IGraphQLSchemaComposer;
34
+ }
@@ -0,0 +1,6 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const GraphQLSchemaBuilder = createAbstraction("GraphQLSchemaBuilder");
3
+ const GraphQLSchemaComposer = createAbstraction("GraphQLSchemaComposer");
4
+ export { GraphQLSchemaBuilder, GraphQLSchemaComposer };
5
+
6
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/GraphQLSchemaBuilder/abstractions.js","sources":["../../../src/features/GraphQLSchemaBuilder/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { ResolverDecorator, TypeDefs } from \"~/types.js\";\nimport type { Dependency } from \"@webiny/di\";\nimport type { IGraphQLSchema } from \"~/graphql/abstractions.public.js\";\n\nexport interface ResolverConfig<TArgs = any, TParent = any> {\n path: string;\n dependencies?: Dependency[];\n resolver: (\n ...resolvedDeps: any[]\n ) => (params: { parent: TParent; args: TArgs; context: any; info: any }) => any;\n}\n\nexport interface IGraphQLSchemaBuilder {\n addTypeDefs(typeDefs: TypeDefs): this;\n addResolver<TArgs = any, TParent = any>(config: ResolverConfig<TArgs, TParent>): this;\n /**\n * @internal This method needs revisiting, to align with DI concepts.\n */\n addResolverDecorator(path: string, decorator: ResolverDecorator): this;\n build(): IGraphQLSchema;\n}\n\nexport const GraphQLSchemaBuilder =\n createAbstraction<IGraphQLSchemaBuilder>(\"GraphQLSchemaBuilder\");\n\nexport namespace GraphQLSchemaBuilder {\n export type Interface = IGraphQLSchemaBuilder;\n export type Config<TArgs = any> = ResolverConfig<TArgs>;\n}\n\nexport interface IGraphQLSchemaComposer {\n build(): Promise<IGraphQLSchema>;\n}\n\nexport const GraphQLSchemaComposer =\n createAbstraction<IGraphQLSchemaComposer>(\"GraphQLSchemaComposer\");\n\nexport namespace GraphQLSchemaComposer {\n export type Interface = IGraphQLSchemaComposer;\n}\n"],"names":["GraphQLSchemaBuilder","createAbstraction","GraphQLSchemaComposer"],"mappings":";AAuBO,MAAMA,uBACTC,kBAAyC;AAWtC,MAAMC,wBACTD,kBAA0C"}
@@ -0,0 +1,4 @@
1
+ export declare const GraphQLSchemaComposerFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { GraphQLSchemaComposer } from "./GraphQLSchemaComposer.js";
3
+ const GraphQLSchemaComposerFeature = createFeature({
4
+ name: "GraphQLSchemaComposer",
5
+ register (container) {
6
+ container.register(GraphQLSchemaComposer);
7
+ }
8
+ });
9
+ export { GraphQLSchemaComposerFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,11 @@
1
+ import type { IGraphQLSchemaFactory } from "./abstractions.public.js";
2
+ import type { GraphQLSchemaBuilder } from "../features/GraphQLSchemaBuilder/abstractions.js";
3
+ /**
4
+ * CoreGraphQLSchemaFactory
5
+ */
6
+ export declare const CoreGraphQLSchemaFactory: import("@webiny/di").Abstraction<IGraphQLSchemaFactory>;
7
+ export declare namespace CoreGraphQLSchemaFactory {
8
+ type Interface = IGraphQLSchemaFactory;
9
+ type SchemaBuilder = GraphQLSchemaBuilder.Interface;
10
+ type Return = Promise<GraphQLSchemaBuilder.Interface>;
11
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const CoreGraphQLSchemaFactory = createAbstraction("CoreGraphQLSchemaFactory");
3
+ export { CoreGraphQLSchemaFactory };
4
+
5
+ //# sourceMappingURL=abstractions.core.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,2 @@
1
+ export * from "./abstractions.core.js";
2
+ export * from "./abstractions.public.js";
@@ -0,0 +1,2 @@
1
+ export * from "./abstractions.core.js";
2
+ export * from "./abstractions.public.js";
@@ -0,0 +1,18 @@
1
+ import type { Resolvers as IResolvers, TypeDefs as ITypeDefs, ResolverDecorators as IResolverDecorators } from "../types.js";
2
+ import type { GraphQLSchemaBuilder } from "../features/GraphQLSchemaBuilder/abstractions.js";
3
+ export interface IGraphQLSchema {
4
+ typeDefs?: ITypeDefs;
5
+ resolvers?: IResolvers<any>;
6
+ resolverDecorators?: IResolverDecorators;
7
+ }
8
+ /** Define custom GraphQL schema extensions. */
9
+ export interface IGraphQLSchemaFactory {
10
+ execute(builder: GraphQLSchemaBuilder.Interface): Promise<GraphQLSchemaBuilder.Interface>;
11
+ }
12
+ /** Define custom GraphQL schema extensions. */
13
+ export declare const GraphQLSchemaFactory: import("@webiny/di").Abstraction<IGraphQLSchemaFactory>;
14
+ export declare namespace GraphQLSchemaFactory {
15
+ type Interface = IGraphQLSchemaFactory;
16
+ type SchemaBuilder = GraphQLSchemaBuilder.Interface;
17
+ type Return = Promise<GraphQLSchemaBuilder.Interface>;
18
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const GraphQLSchemaFactory = createAbstraction("GraphQLSchemaFactory");
3
+ export { GraphQLSchemaFactory };
4
+
5
+ //# sourceMappingURL=abstractions.public.js.map
@@ -0,0 +1 @@
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.d.ts CHANGED
@@ -1,6 +1,11 @@
1
- import { HandlerGraphQLOptions } from "./types";
2
- export * from "./errors";
3
- export * from "./responses";
4
- export * from "./plugins";
5
- declare const _default: (options?: HandlerGraphQLOptions) => import("@webiny/plugins/types").PluginCollection[];
1
+ import type { Plugin } from "@webiny/plugins/types.js";
2
+ import type { HandlerGraphQLOptions } from "./types.js";
3
+ export * from "./errors.js";
4
+ export * from "./responses.js";
5
+ export * from "./utils/index.js";
6
+ export * from "./plugins/index.js";
7
+ export * from "./processRequestBody.js";
8
+ export * from "./createResolverDecorator.js";
9
+ export * from "./ResolverDecoration.js";
10
+ declare const _default: (options?: HandlerGraphQLOptions) => Plugin[];
6
11
  export default _default;
package/index.js CHANGED
@@ -1,57 +1,12 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- var _exportNames = {};
9
- exports.default = void 0;
10
-
11
- var _createGraphQLHandler = _interopRequireDefault(require("./createGraphQLHandler"));
12
-
13
- var _errors = require("./errors");
14
-
15
- Object.keys(_errors).forEach(function (key) {
16
- if (key === "default" || key === "__esModule") return;
17
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
18
- if (key in exports && exports[key] === _errors[key]) return;
19
- Object.defineProperty(exports, key, {
20
- enumerable: true,
21
- get: function () {
22
- return _errors[key];
23
- }
24
- });
25
- });
26
-
27
- var _responses = require("./responses");
28
-
29
- Object.keys(_responses).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
32
- if (key in exports && exports[key] === _responses[key]) return;
33
- Object.defineProperty(exports, key, {
34
- enumerable: true,
35
- get: function () {
36
- return _responses[key];
37
- }
38
- });
39
- });
40
-
41
- var _plugins = require("./plugins");
42
-
43
- Object.keys(_plugins).forEach(function (key) {
44
- if (key === "default" || key === "__esModule") return;
45
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
46
- if (key in exports && exports[key] === _plugins[key]) return;
47
- Object.defineProperty(exports, key, {
48
- enumerable: true,
49
- get: function () {
50
- return _plugins[key];
51
- }
52
- });
53
- });
54
-
55
- var _default = (options = {}) => [(0, _createGraphQLHandler.default)(options)];
56
-
57
- exports.default = _default;
1
+ import createGraphQLHandler from "./createGraphQLHandler.js";
2
+ export * from "./errors.js";
3
+ export * from "./responses.js";
4
+ export * from "./utils/index.js";
5
+ export * from "./plugins/index.js";
6
+ export * from "./processRequestBody.js";
7
+ export * from "./createResolverDecorator.js";
8
+ export * from "./ResolverDecoration.js";
9
+ const src = (options = {})=>createGraphQLHandler(options);
10
+ export default src;
11
+
12
+ //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["options","createGraphQLHandler"],"sources":["index.ts"],"sourcesContent":["import { HandlerGraphQLOptions } from \"./types\";\nimport createGraphQLHandler from \"./createGraphQLHandler\";\n\nexport * from \"./errors\";\nexport * from \"./responses\";\nexport * from \"./plugins\";\n\nexport default (options: HandlerGraphQLOptions = {}) => [createGraphQLHandler(options)];\n"],"mappings":";;;;;;;;;;AACA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;eAEe,CAACA,OAA8B,GAAG,EAAlC,KAAyC,CAAC,IAAAC,6BAAA,EAAqBD,OAArB,CAAD,C"}
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,43 +1,35 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.interceptConsole = void 0;
7
- 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
+ ];
8
14
  const originalMethods = {};
9
- const skipOriginal = ["table"];
10
-
11
- const restoreOriginalMethods = () => {
12
- for (const method of consoleMethods) {
13
- // @ts-ignore
14
- console[method] = originalMethods[method];
15
- }
15
+ const skipOriginal = [
16
+ "table"
17
+ ];
18
+ const restoreOriginalMethods = ()=>{
19
+ for (const method of consoleMethods)console[method] = originalMethods[method];
16
20
  };
17
-
18
- const interceptConsole = callback => {
19
- // @ts-ignore
20
- if (console["__WEBINY__"] === true) {
21
- restoreOriginalMethods();
22
- } // @ts-ignore
23
-
24
-
25
- console["__WEBINY__"] = true;
26
-
27
- for (const method of consoleMethods) {
28
- // @ts-ignore
29
- originalMethods[method] = console[method]; // @ts-ignore
30
-
31
- console[method] = (...args) => {
32
- callback(method, args);
33
-
34
- if (skipOriginal.includes(method)) {
35
- return;
36
- }
37
-
38
- originalMethods[method](...args);
39
- };
40
- }
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
+ }
41
32
  };
33
+ export { interceptConsole };
42
34
 
43
- exports.interceptConsole = interceptConsole;
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-ignore\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-ignore\n if (console[\"__WEBINY__\"] === true) {\n restoreOriginalMethods();\n }\n\n // @ts-ignore\n console[\"__WEBINY__\"] = true;\n\n for (const method of consoleMethods) {\n // @ts-ignore\n originalMethods[method] = console[method];\n // @ts-ignore\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,QADmB,EAEnB,OAFmB,EAGnB,KAHmB,EAInB,OAJmB,EAKnB,OALmB,EAMnB,gBANmB,EAOnB,UAPmB,EAQnB,MARmB,EASnB,KATmB,EAUnB,OAVmB,EAWnB,MAXmB,CAAvB;AAcA,MAAMC,eAAoC,GAAG,EAA7C;AACA,MAAMC,YAAsB,GAAG,CAAC,OAAD,CAA/B;;AAEA,MAAMC,sBAAsB,GAAG,MAAM;EACjC,KAAK,MAAMC,MAAX,IAAqBJ,cAArB,EAAqC;IACjC;IACAK,OAAO,CAACD,MAAD,CAAP,GAAkBH,eAAe,CAACG,MAAD,CAAjC;EACH;AACJ,CALD;;AAWO,MAAME,gBAAgB,GAAIC,QAAD,IAAwC;EACpE;EACA,IAAIF,OAAO,CAAC,YAAD,CAAP,KAA0B,IAA9B,EAAoC;IAChCF,sBAAsB;EACzB,CAJmE,CAMpE;;;EACAE,OAAO,CAAC,YAAD,CAAP,GAAwB,IAAxB;;EAEA,KAAK,MAAMD,MAAX,IAAqBJ,cAArB,EAAqC;IACjC;IACAC,eAAe,CAACG,MAAD,CAAf,GAA0BC,OAAO,CAACD,MAAD,CAAjC,CAFiC,CAGjC;;IACAC,OAAO,CAACD,MAAD,CAAP,GAAkB,CAAC,GAAGI,IAAJ,KAAa;MAC3BD,QAAQ,CAACH,MAAD,EAASI,IAAT,CAAR;;MACA,IAAIN,YAAY,CAACO,QAAb,CAAsBL,MAAtB,CAAJ,EAAmC;QAC/B;MACH;;MACDH,eAAe,CAACG,MAAD,CAAf,CAAwB,GAAGI,IAA3B;IACH,CAND;EAOH;AACJ,CArBM"}
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,7 +1,11 @@
1
1
  {
2
2
  "name": "@webiny/handler-graphql",
3
- "version": "0.0.0-unstable.78f581c1d2",
4
- "main": "index.js",
3
+ "version": "0.0.0-unstable.7be00a75a9",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
5
9
  "license": "MIT",
6
10
  "repository": {
7
11
  "type": "git",
@@ -14,36 +18,35 @@
14
18
  "Adrian Smijulj <adrian@webiny.com>"
15
19
  ],
16
20
  "dependencies": {
17
- "@babel/runtime": "7.19.0",
18
- "@graphql-tools/schema": "7.1.5",
19
- "@webiny/api": "0.0.0-unstable.78f581c1d2",
20
- "@webiny/error": "0.0.0-unstable.78f581c1d2",
21
- "@webiny/handler": "0.0.0-unstable.78f581c1d2",
22
- "@webiny/plugins": "0.0.0-unstable.78f581c1d2",
23
- "boolean": "3.2.0",
24
- "graphql": "15.8.0",
25
- "graphql-scalars": "1.12.0",
26
- "graphql-tag": "2.12.6"
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",
34
+ "graphql-scalars": "1.25.0",
35
+ "graphql-tag": "2.12.6",
36
+ "zod": "4.4.3"
27
37
  },
28
38
  "devDependencies": {
29
- "@babel/cli": "^7.19.3",
30
- "@babel/core": "^7.19.3",
31
- "@babel/preset-env": "^7.19.4",
32
- "@webiny/cli": "^0.0.0-unstable.78f581c1d2",
33
- "@webiny/handler-aws": "^0.0.0-unstable.78f581c1d2",
34
- "@webiny/project-utils": "^0.0.0-unstable.78f581c1d2",
35
- "jest": "^28.1.0",
36
- "jest-mock-console": "^1.0.0",
37
- "rimraf": "^3.0.2",
38
- "typescript": "4.7.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"
39
44
  },
40
45
  "publishConfig": {
41
- "access": "public",
42
- "directory": "dist"
43
- },
44
- "scripts": {
45
- "build": "yarn webiny run build",
46
- "watch": "yarn webiny run watch"
46
+ "access": "public"
47
47
  },
48
- "gitHead": "78f581c1d2e5e6936aa11b9452a66d2a3652a1b2"
48
+ "gitHead": "b8aec8a1be3f25c3b428b357fe1e352c7cbff9ae",
49
+ "webiny": {
50
+ "publishFrom": "dist"
51
+ }
49
52
  }
@@ -1,13 +1,21 @@
1
+ import type { Context } from "@webiny/api/types.js";
1
2
  import { Plugin } from "@webiny/plugins";
2
- import { GraphQLSchemaDefinition, Resolvers, Types } from "../types";
3
- import { Context } from "@webiny/api/types";
3
+ import type { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from "../types.js";
4
+ export interface IGraphQLSchemaPlugin<TContext = Context> extends Plugin {
5
+ schema: GraphQLSchemaDefinition<TContext>;
6
+ isApplicable: (context: TContext) => boolean;
7
+ }
4
8
  export interface GraphQLSchemaPluginConfig<TContext> {
5
- typeDefs?: Types;
9
+ typeDefs?: TypeDefs;
6
10
  resolvers?: Resolvers<TContext>;
11
+ resolverDecorators?: ResolverDecorators;
12
+ isApplicable?: (context: TContext) => boolean;
7
13
  }
8
- export declare class GraphQLSchemaPlugin<TContext = Context> extends Plugin {
14
+ export declare class GraphQLSchemaPlugin<TContext = Context> extends Plugin implements IGraphQLSchemaPlugin<TContext> {
9
15
  static readonly type: string;
10
- private config;
16
+ protected config: GraphQLSchemaPluginConfig<TContext>;
11
17
  constructor(config: GraphQLSchemaPluginConfig<TContext>);
12
18
  get schema(): GraphQLSchemaDefinition<TContext>;
19
+ isApplicable(context: TContext): boolean;
13
20
  }
21
+ export declare const createGraphQLSchemaPlugin: <T = Context>(config: GraphQLSchemaPluginConfig<T>) => GraphQLSchemaPlugin<T>;
@@ -1,31 +1,25 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.GraphQLSchemaPlugin = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _plugins = require("@webiny/plugins");
13
-
14
- class GraphQLSchemaPlugin extends _plugins.Plugin {
15
- constructor(config) {
16
- super();
17
- (0, _defineProperty2.default)(this, "config", void 0);
18
- this.config = config;
19
- }
20
-
21
- get schema() {
22
- return {
23
- typeDefs: this.config.typeDefs || "",
24
- resolvers: this.config.resolvers
25
- };
26
- }
27
-
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;
20
+ }
28
21
  }
22
+ const createGraphQLSchemaPlugin = (config)=>new GraphQLSchemaPlugin(config);
23
+ export { GraphQLSchemaPlugin, createGraphQLSchemaPlugin };
29
24
 
30
- exports.GraphQLSchemaPlugin = GraphQLSchemaPlugin;
31
- (0, _defineProperty2.default)(GraphQLSchemaPlugin, "type", "graphql-schema");
25
+ //# sourceMappingURL=GraphQLSchemaPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["GraphQLSchemaPlugin","Plugin","constructor","config","schema","typeDefs","resolvers"],"sources":["GraphQLSchemaPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { GraphQLSchemaDefinition, Resolvers, Types } from \"~/types\";\nimport { Context } from \"@webiny/api/types\";\n\nexport interface GraphQLSchemaPluginConfig<TContext> {\n typeDefs?: Types;\n resolvers?: Resolvers<TContext>;\n}\n\nexport class GraphQLSchemaPlugin<TContext = Context> extends Plugin {\n public static override readonly type: string = \"graphql-schema\";\n private config: GraphQLSchemaPluginConfig<TContext>;\n\n constructor(config: GraphQLSchemaPluginConfig<TContext>) {\n super();\n this.config = config;\n }\n\n get schema(): GraphQLSchemaDefinition<TContext> {\n return {\n typeDefs: this.config.typeDefs || \"\",\n resolvers: this.config.resolvers\n };\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AASO,MAAMA,mBAAN,SAAsDC,eAAtD,CAA6D;EAIhEC,WAAW,CAACC,MAAD,EAA8C;IACrD;IADqD;IAErD,KAAKA,MAAL,GAAcA,MAAd;EACH;;EAES,IAANC,MAAM,GAAsC;IAC5C,OAAO;MACHC,QAAQ,EAAE,KAAKF,MAAL,CAAYE,QAAZ,IAAwB,EAD/B;MAEHC,SAAS,EAAE,KAAKH,MAAL,CAAYG;IAFpB,CAAP;EAIH;;AAd+D;;;8BAAvDN,mB,UACsC,gB"}
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
-
7
- var _GraphQLSchemaPlugin = require("./GraphQLSchemaPlugin");
8
-
9
- Object.keys(_GraphQLSchemaPlugin).forEach(function (key) {
10
- if (key === "default" || key === "__esModule") return;
11
- if (key in exports && exports[key] === _GraphQLSchemaPlugin[key]) return;
12
- Object.defineProperty(exports, key, {
13
- enumerable: true,
14
- get: function () {
15
- return _GraphQLSchemaPlugin[key];
16
- }
17
- });
18
- });
1
+ export * from "./GraphQLSchemaPlugin.js";
@@ -1,5 +1,4 @@
1
- import { ExecutionResult, GraphQLSchema } from "graphql";
2
- import { GraphQLRequestBody } from "./types";
3
- import { Context } from "@webiny/api/types";
4
- declare const _default: (requestBody: GraphQLRequestBody | GraphQLRequestBody[], schema: GraphQLSchema, context: Context) => Promise<ExecutionResult[] | ExecutionResult>;
5
- export default _default;
1
+ import type { ExecutionResult, GraphQLSchema } from "graphql";
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>>;