@webiny/handler-graphql 0.0.0-unstable.9f53ea597d → 0.0.0-unstable.a4f3e4ea8b
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.
|
@@ -8,10 +8,11 @@ class GraphQLSchemaBuilder {
|
|
|
8
8
|
const pathParts = path.split(".");
|
|
9
9
|
const graphqlResolver = (parent, args, context, info)=>{
|
|
10
10
|
const resolvedDeps = dependencies.map((dep)=>{
|
|
11
|
-
const [abstraction] = Array.isArray(dep) ? dep : [
|
|
12
|
-
dep
|
|
11
|
+
const [abstraction, options] = Array.isArray(dep) ? dep : [
|
|
12
|
+
dep,
|
|
13
|
+
void 0
|
|
13
14
|
];
|
|
14
|
-
return context.container.resolve(abstraction);
|
|
15
|
+
return options?.multiple ? context.container.resolveAll(abstraction) : context.container.resolve(abstraction);
|
|
15
16
|
});
|
|
16
17
|
const actualResolver = resolver(...resolvedDeps);
|
|
17
18
|
return actualResolver({
|
|
@@ -1 +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;
|
|
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 /*\n * `Dependency` allows `[abstraction, { multiple: true }]`, same as anywhere else in\n * the container. This used to destructure the tuple, throw the options away and\n * always single-resolve, so a resolver asking for every implementation of an\n * abstraction received one object and failed on `.map`.\n */\n const [abstraction, options] = Array.isArray(dep) ? dep : [dep, undefined];\n\n return options?.multiple\n ? context.container.resolveAll(abstraction)\n : 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","options","Array","undefined","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;gBAOnC,MAAM,CAACC,aAAaC,QAAQ,GAAGC,MAAM,OAAO,CAACH,OAAOA,MAAM;oBAACA;oBAAKI;iBAAU;gBAE1E,OAAOF,SAAS,WACVL,QAAQ,SAAS,CAAC,UAAU,CAACI,eAC7BJ,QAAQ,SAAS,CAAC,OAAO,CAACI;YACpC;YAEA,MAAMI,iBAAiBb,YAAYO;YAEnC,OAAOM,eAAe;gBAAEV;gBAAQC;gBAAMC;gBAASC;YAAK;QACxD;QAEA,IAAI,CAAC,iBAAiB,CAACL,WAAWC;QAElC,OAAO,IAAI;IACf;IAKA,qBAAqBJ,IAAY,EAAEgB,SAA4B,EAAQ;QACnE,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAChB,KAAK,EAC9B,IAAI,CAAC,kBAAkB,CAACA,KAAK,GAAG,EAAE;QAEtC,IAAI,CAAC,kBAAkB,CAACA,KAAK,CAAC,IAAI,CAACgB;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,kBAAkBb,SAAmB,EAAED,QAAa,EAAQ;QAChE,IAAIe,UAAe,IAAI,CAAC,SAAS;QAEjC,IAAK,IAAIC,IAAI,GAAGA,IAAIf,UAAU,MAAM,GAAG,GAAGe,IAAK;YAC3C,MAAMC,OAAOhB,SAAS,CAACe,EAAE;YACzB,IAAI,CAACD,OAAO,CAACE,KAAK,EACdF,OAAO,CAACE,KAAK,GAAG,CAAC;YAErBF,UAAUA,OAAO,CAACE,KAAK;QAC3B;QAEA,MAAMC,WAAWjB,SAAS,CAACA,UAAU,MAAM,GAAG,EAAE;QAChDc,OAAO,CAACG,SAAS,GAAGlB;IACxB;;aAvEiB,aAAa,GAAa,EAAE;aAC5B,SAAS,GAAmB,CAAC;aAC7B,kBAAkB,GAAuB,CAAC;;AAsE/D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/handler-graphql",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.a4f3e4ea8b",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -22,22 +22,22 @@
|
|
|
22
22
|
"@graphql-tools/resolvers-composition": "7.0.35",
|
|
23
23
|
"@graphql-tools/schema": "10.0.38",
|
|
24
24
|
"@graphql-tools/utils": "11.2.2",
|
|
25
|
-
"@webiny/api": "0.0.0-unstable.
|
|
25
|
+
"@webiny/api": "0.0.0-unstable.a4f3e4ea8b",
|
|
26
26
|
"@webiny/di": "1.0.2",
|
|
27
|
-
"@webiny/error": "0.0.0-unstable.
|
|
28
|
-
"@webiny/feature": "0.0.0-unstable.
|
|
29
|
-
"@webiny/handler": "0.0.0-unstable.
|
|
30
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
27
|
+
"@webiny/error": "0.0.0-unstable.a4f3e4ea8b",
|
|
28
|
+
"@webiny/feature": "0.0.0-unstable.a4f3e4ea8b",
|
|
29
|
+
"@webiny/handler": "0.0.0-unstable.a4f3e4ea8b",
|
|
30
|
+
"@webiny/plugins": "0.0.0-unstable.a4f3e4ea8b",
|
|
31
31
|
"@webiny/stdlib": "0.0.12",
|
|
32
|
-
"@webiny/utils": "0.0.0-unstable.
|
|
32
|
+
"@webiny/utils": "0.0.0-unstable.a4f3e4ea8b",
|
|
33
33
|
"graphql": "16.14.2",
|
|
34
34
|
"graphql-scalars": "1.25.0",
|
|
35
35
|
"graphql-tag": "2.12.7",
|
|
36
36
|
"zod": "4.4.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
40
|
-
"@webiny/handler-aws": "0.0.0-unstable.
|
|
39
|
+
"@webiny/build-tools": "0.0.0-unstable.a4f3e4ea8b",
|
|
40
|
+
"@webiny/handler-aws": "0.0.0-unstable.a4f3e4ea8b",
|
|
41
41
|
"rimraf": "6.1.3",
|
|
42
42
|
"typescript": "7.0.2",
|
|
43
43
|
"vitest": "4.1.10"
|