@webiny/handler-graphql 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/ResolverDecoration.d.ts +6 -0
- package/ResolverDecoration.js +23 -0
- package/ResolverDecoration.js.map +1 -0
- package/builtInTypes/AnyScalar.d.ts +1 -1
- package/builtInTypes/AnyScalar.js +9 -18
- package/builtInTypes/AnyScalar.js.map +1 -1
- package/builtInTypes/DateScalar.d.ts +1 -1
- package/builtInTypes/DateScalar.js +16 -32
- package/builtInTypes/DateScalar.js.map +1 -1
- package/builtInTypes/DateTimeScalar.d.ts +1 -1
- package/builtInTypes/DateTimeScalar.js +16 -32
- package/builtInTypes/DateTimeScalar.js.map +1 -1
- package/builtInTypes/DateTimeZScalar.d.ts +1 -1
- package/builtInTypes/DateTimeZScalar.js +27 -58
- package/builtInTypes/DateTimeZScalar.js.map +1 -1
- package/builtInTypes/IconScalar.d.ts +10 -0
- package/builtInTypes/IconScalar.js +65 -0
- package/builtInTypes/IconScalar.js.map +1 -0
- package/builtInTypes/JsonScalar.d.ts +1 -1
- package/builtInTypes/JsonScalar.js +4 -10
- package/builtInTypes/JsonScalar.js.map +1 -1
- package/builtInTypes/LongScalar.d.ts +2 -1
- package/builtInTypes/LongScalar.js +38 -9
- package/builtInTypes/LongScalar.js.map +1 -1
- package/builtInTypes/NumberScalar.d.ts +1 -1
- package/builtInTypes/NumberScalar.js +35 -58
- package/builtInTypes/NumberScalar.js.map +1 -1
- package/builtInTypes/RefInputScalar.d.ts +1 -1
- package/builtInTypes/RefInputScalar.js +48 -60
- package/builtInTypes/RefInputScalar.js.map +1 -1
- package/builtInTypes/TimeScalar.d.ts +1 -1
- package/builtInTypes/TimeScalar.js +31 -62
- package/builtInTypes/TimeScalar.js.map +1 -1
- package/builtInTypes/index.d.ts +10 -9
- package/builtInTypes/index.js +10 -122
- package/createGraphQLHandler.d.ts +3 -3
- package/createGraphQLHandler.js +77 -55
- package/createGraphQLHandler.js.map +1 -1
- package/createGraphQLSchema.d.ts +4 -2
- package/createGraphQLSchema.js +67 -54
- package/createGraphQLSchema.js.map +1 -1
- package/createRequestBody.d.ts +2 -0
- package/createRequestBody.js +28 -0
- package/createRequestBody.js.map +1 -0
- package/createResolverDecorator.d.ts +2 -0
- package/createResolverDecorator.js +4 -0
- package/createResolverDecorator.js.map +1 -0
- package/debugPlugins.d.ts +2 -2
- package/debugPlugins.js +28 -45
- package/debugPlugins.js.map +1 -1
- package/errors.js +7 -17
- package/errors.js.map +1 -1
- package/exports/api/graphql.d.ts +2 -0
- package/exports/api/graphql.js +2 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.d.ts +16 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js +57 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js.map +1 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.d.ts +13 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js +35 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js.map +1 -0
- package/features/GraphQLSchemaBuilder/abstractions.d.ts +34 -0
- package/features/GraphQLSchemaBuilder/abstractions.js +6 -0
- package/features/GraphQLSchemaBuilder/abstractions.js.map +1 -0
- package/features/GraphQLSchemaBuilder/feature.d.ts +4 -0
- package/features/GraphQLSchemaBuilder/feature.js +11 -0
- package/features/GraphQLSchemaBuilder/feature.js.map +1 -0
- package/graphql/abstractions.core.d.ts +11 -0
- package/graphql/abstractions.core.js +5 -0
- package/graphql/abstractions.core.js.map +1 -0
- package/graphql/abstractions.d.ts +2 -0
- package/graphql/abstractions.js +2 -0
- package/graphql/abstractions.public.d.ts +18 -0
- package/graphql/abstractions.public.js +5 -0
- package/graphql/abstractions.public.js.map +1 -0
- package/index.d.ts +10 -5
- package/index.js +12 -57
- package/index.js.map +1 -1
- package/interceptConsole.js +31 -39
- package/interceptConsole.js.map +1 -1
- package/package.json +32 -29
- package/plugins/GraphQLSchemaPlugin.d.ts +13 -5
- package/plugins/GraphQLSchemaPlugin.js +23 -29
- package/plugins/GraphQLSchemaPlugin.js.map +1 -1
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +1 -18
- package/processRequestBody.d.ts +4 -5
- package/processRequestBody.js +35 -42
- package/processRequestBody.js.map +1 -1
- package/responses.d.ts +11 -1
- package/responses.js +44 -92
- package/responses.js.map +1 -1
- package/types.d.ts +20 -13
- package/types.js +0 -5
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/resolve.d.ts +21 -0
- package/utils/resolve.js +20 -0
- package/utils/resolve.js.map +1 -0
- package/builtInTypes/index.js.map +0 -1
- package/plugins/index.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -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,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 @@
|
|
|
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,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 @@
|
|
|
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 {
|
|
2
|
-
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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,"
|
|
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"}
|
package/interceptConsole.js
CHANGED
|
@@ -1,43 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 = [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
35
|
+
//# sourceMappingURL=interceptConsole.js.map
|
package/interceptConsole.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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.
|
|
4
|
-
"
|
|
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
|
-
"@
|
|
18
|
-
"@graphql-tools/
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
21
|
-
"@webiny/
|
|
22
|
-
"@webiny/
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
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
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
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": "
|
|
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,
|
|
3
|
-
|
|
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?:
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
(
|
|
18
|
-
|
|
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
|
-
|
|
31
|
-
(0, _defineProperty2.default)(GraphQLSchemaPlugin, "type", "graphql-schema");
|
|
25
|
+
//# sourceMappingURL=GraphQLSchemaPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./GraphQLSchemaPlugin";
|
|
1
|
+
export * from "./GraphQLSchemaPlugin.js";
|
package/plugins/index.js
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
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";
|
package/processRequestBody.d.ts
CHANGED
|
@@ -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
|
|
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>>;
|