@webiny/handler-graphql 0.0.0-unstable.6f45466a1d → 0.0.0-unstable.7be00a75a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ResolverDecoration.js +18 -14
- package/ResolverDecoration.js.map +1 -1
- package/builtInTypes/AnyScalar.js +7 -8
- package/builtInTypes/AnyScalar.js.map +1 -1
- package/builtInTypes/DateScalar.js +12 -18
- package/builtInTypes/DateScalar.js.map +1 -1
- package/builtInTypes/DateTimeScalar.js +12 -18
- package/builtInTypes/DateTimeScalar.js.map +1 -1
- package/builtInTypes/DateTimeZScalar.js +23 -35
- package/builtInTypes/DateTimeZScalar.js.map +1 -1
- package/builtInTypes/IconScalar.js +59 -87
- package/builtInTypes/IconScalar.js.map +1 -1
- package/builtInTypes/JsonScalar.js +2 -1
- package/builtInTypes/JsonScalar.js.map +1 -1
- package/builtInTypes/LongScalar.js +30 -39
- package/builtInTypes/LongScalar.js.map +1 -1
- package/builtInTypes/NumberScalar.js +31 -38
- package/builtInTypes/NumberScalar.js.map +1 -1
- package/builtInTypes/RefInputScalar.js +45 -68
- package/builtInTypes/RefInputScalar.js.map +1 -1
- package/builtInTypes/TimeScalar.js +28 -41
- package/builtInTypes/TimeScalar.js.map +1 -1
- package/builtInTypes/index.js +0 -2
- package/createGraphQLHandler.js +69 -80
- package/createGraphQLHandler.js.map +1 -1
- package/createGraphQLSchema.js +49 -66
- package/createGraphQLSchema.js.map +1 -1
- package/createRequestBody.js +22 -20
- package/createRequestBody.js.map +1 -1
- package/createResolverDecorator.js +2 -3
- package/createResolverDecorator.js.map +1 -1
- package/debugPlugins.js +24 -27
- package/debugPlugins.js.map +1 -1
- package/errors.js +6 -5
- package/errors.js.map +1 -1
- package/exports/api/graphql.js +1 -3
- package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js +52 -59
- package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js.map +1 -1
- package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js +27 -21
- package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js.map +1 -1
- package/features/GraphQLSchemaBuilder/abstractions.js +3 -2
- package/features/GraphQLSchemaBuilder/abstractions.js.map +1 -1
- package/features/GraphQLSchemaBuilder/feature.d.ts +4 -1
- package/features/GraphQLSchemaBuilder/feature.js +6 -5
- package/features/GraphQLSchemaBuilder/feature.js.map +1 -1
- package/graphql/abstractions.core.js +2 -7
- package/graphql/abstractions.core.js.map +1 -1
- package/graphql/abstractions.js +0 -2
- package/graphql/abstractions.public.d.ts +2 -3
- package/graphql/abstractions.public.js +2 -9
- package/graphql/abstractions.public.js.map +1 -1
- package/index.js +2 -3
- package/index.js.map +1 -1
- package/interceptConsole.js +30 -27
- package/interceptConsole.js.map +1 -1
- package/package.json +29 -24
- package/plugins/GraphQLSchemaPlugin.js +20 -21
- package/plugins/GraphQLSchemaPlugin.js.map +1 -1
- package/plugins/index.js +0 -2
- package/processRequestBody.js +33 -36
- package/processRequestBody.js.map +1 -1
- package/responses.d.ts +11 -1
- package/responses.js +48 -55
- package/responses.js.map +1 -1
- package/types.js +0 -3
- package/utils/index.js +0 -2
- package/utils/resolve.js +15 -14
- package/utils/resolve.js.map +1 -1
- package/builtInTypes/index.js.map +0 -1
- package/exports/api/graphql.js.map +0 -1
- package/graphql/abstractions.js.map +0 -1
- package/plugins/index.js.map +0 -1
- package/types.js.map +0 -1
- package/utils/index.js.map +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { GraphQLSchemaComposer } from "./GraphQLSchemaComposer.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const GraphQLSchemaComposerFeature = createFeature({
|
|
4
|
+
name: "GraphQLSchemaComposer",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(GraphQLSchemaComposer);
|
|
7
|
+
}
|
|
8
8
|
});
|
|
9
|
+
export { GraphQLSchemaComposerFeature };
|
|
9
10
|
|
|
10
11
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/GraphQLSchemaBuilder/feature.js","sources":["../../../src/features/GraphQLSchemaBuilder/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GraphQLSchemaComposer } from \"./GraphQLSchemaComposer.js\";\n\nexport const GraphQLSchemaComposerFeature = createFeature({\n name: \"GraphQLSchemaComposer\",\n register(container) {\n container.register(GraphQLSchemaComposer);\n }\n});\n"],"names":["GraphQLSchemaComposerFeature","createFeature","container","GraphQLSchemaComposer"],"mappings":";;AAGO,MAAMA,+BAA+BC,cAAc;IACtD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains abstraction for use by the core Webiny team, or anyone contributing to the webiny-js repository.
|
|
3
|
-
*/
|
|
4
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
export const CoreGraphQLSchemaFactory = createAbstraction("CoreGraphQLSchemaFactory");
|
|
2
|
+
const CoreGraphQLSchemaFactory = createAbstraction("CoreGraphQLSchemaFactory");
|
|
3
|
+
export { CoreGraphQLSchemaFactory };
|
|
9
4
|
|
|
10
5
|
//# sourceMappingURL=abstractions.core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
package/graphql/abstractions.js
CHANGED
|
@@ -5,12 +5,11 @@ export interface IGraphQLSchema {
|
|
|
5
5
|
resolvers?: IResolvers<any>;
|
|
6
6
|
resolverDecorators?: IResolverDecorators;
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
9
|
-
* GraphQLSchemaFactory
|
|
10
|
-
*/
|
|
8
|
+
/** Define custom GraphQL schema extensions. */
|
|
11
9
|
export interface IGraphQLSchemaFactory {
|
|
12
10
|
execute(builder: GraphQLSchemaBuilder.Interface): Promise<GraphQLSchemaBuilder.Interface>;
|
|
13
11
|
}
|
|
12
|
+
/** Define custom GraphQL schema extensions. */
|
|
14
13
|
export declare const GraphQLSchemaFactory: import("@webiny/di").Abstraction<IGraphQLSchemaFactory>;
|
|
15
14
|
export declare namespace GraphQLSchemaFactory {
|
|
16
15
|
type Interface = IGraphQLSchemaFactory;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains abstraction for use by third party developers.
|
|
3
|
-
*/
|
|
4
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* GraphQLSchemaFactory
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export const GraphQLSchemaFactory = createAbstraction("GraphQLSchemaFactory");
|
|
2
|
+
const GraphQLSchemaFactory = createAbstraction("GraphQLSchemaFactory");
|
|
3
|
+
export { GraphQLSchemaFactory };
|
|
11
4
|
|
|
12
5
|
//# sourceMappingURL=abstractions.public.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"graphql/abstractions.public.js","sources":["../../src/graphql/abstractions.public.ts"],"sourcesContent":["/**\n * This file contains abstraction for use by third party developers.\n */\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type {\n Resolvers as IResolvers,\n TypeDefs as ITypeDefs,\n ResolverDecorators as IResolverDecorators\n} from \"~/types.js\";\nimport type { GraphQLSchemaBuilder } from \"~/features/GraphQLSchemaBuilder/abstractions.js\";\n\nexport interface IGraphQLSchema {\n typeDefs?: ITypeDefs;\n resolvers?: IResolvers<any>;\n resolverDecorators?: IResolverDecorators;\n}\n\n/** Define custom GraphQL schema extensions. */\nexport interface IGraphQLSchemaFactory {\n execute(builder: GraphQLSchemaBuilder.Interface): Promise<GraphQLSchemaBuilder.Interface>;\n}\n\n/** Define custom GraphQL schema extensions. */\nexport const GraphQLSchemaFactory =\n createAbstraction<IGraphQLSchemaFactory>(\"GraphQLSchemaFactory\");\n\nexport namespace GraphQLSchemaFactory {\n export type Interface = IGraphQLSchemaFactory;\n export type SchemaBuilder = GraphQLSchemaBuilder.Interface;\n export type Return = Promise<GraphQLSchemaBuilder.Interface>;\n}\n"],"names":["GraphQLSchemaFactory","createAbstraction"],"mappings":";AAuBO,MAAMA,uBACTC,kBAAyC"}
|
package/index.js
CHANGED
|
@@ -6,8 +6,7 @@ export * from "./plugins/index.js";
|
|
|
6
6
|
export * from "./processRequestBody.js";
|
|
7
7
|
export * from "./createResolverDecorator.js";
|
|
8
8
|
export * from "./ResolverDecoration.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
9
|
+
const src = (options = {})=>createGraphQLHandler(options);
|
|
10
|
+
export default src;
|
|
12
11
|
|
|
13
12
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,32 +1,35 @@
|
|
|
1
|
-
const consoleMethods = [
|
|
1
|
+
const consoleMethods = [
|
|
2
|
+
"assert",
|
|
3
|
+
"debug",
|
|
4
|
+
"dir",
|
|
5
|
+
"error",
|
|
6
|
+
"group",
|
|
7
|
+
"groupCollapsed",
|
|
8
|
+
"groupEnd",
|
|
9
|
+
"info",
|
|
10
|
+
"log",
|
|
11
|
+
"table",
|
|
12
|
+
"warn"
|
|
13
|
+
];
|
|
2
14
|
const originalMethods = {};
|
|
3
|
-
const skipOriginal = [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
console[method] = originalMethods[method];
|
|
8
|
-
}
|
|
15
|
+
const skipOriginal = [
|
|
16
|
+
"table"
|
|
17
|
+
];
|
|
18
|
+
const restoreOriginalMethods = ()=>{
|
|
19
|
+
for (const method of consoleMethods)console[method] = originalMethods[method];
|
|
9
20
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// @ts-expect-error
|
|
22
|
-
console[method] = (...args) => {
|
|
23
|
-
callback(method, args);
|
|
24
|
-
if (skipOriginal.includes(method)) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
originalMethods[method](...args);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
21
|
+
const interceptConsole = (callback)=>{
|
|
22
|
+
if (true === console["__WEBINY__"]) restoreOriginalMethods();
|
|
23
|
+
console["__WEBINY__"] = true;
|
|
24
|
+
for (const method of consoleMethods){
|
|
25
|
+
originalMethods[method] = console[method];
|
|
26
|
+
console[method] = (...args)=>{
|
|
27
|
+
callback(method, args);
|
|
28
|
+
if (skipOriginal.includes(method)) return;
|
|
29
|
+
originalMethods[method](...args);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
30
32
|
};
|
|
33
|
+
export { interceptConsole };
|
|
31
34
|
|
|
32
35
|
//# sourceMappingURL=interceptConsole.js.map
|
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,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/handler-graphql",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.7be00a75a9",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
6
9
|
"license": "MIT",
|
|
7
10
|
"repository": {
|
|
8
11
|
"type": "git",
|
|
@@ -15,33 +18,35 @@
|
|
|
15
18
|
"Adrian Smijulj <adrian@webiny.com>"
|
|
16
19
|
],
|
|
17
20
|
"dependencies": {
|
|
18
|
-
"@graphql-tools/merge": "9.1.
|
|
19
|
-
"@graphql-tools/resolvers-composition": "7.0.
|
|
20
|
-
"@graphql-tools/schema": "10.0.
|
|
21
|
-
"@graphql-tools/utils": "11.
|
|
22
|
-
"@webiny/api": "0.0.0-unstable.
|
|
23
|
-
"@webiny/di": "0.
|
|
24
|
-
"@webiny/error": "0.0.0-unstable.
|
|
25
|
-
"@webiny/feature": "0.0.0-unstable.
|
|
26
|
-
"@webiny/handler": "0.0.0-unstable.
|
|
27
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
28
|
-
"@webiny/
|
|
29
|
-
"
|
|
30
|
-
"graphql": "16.
|
|
21
|
+
"@graphql-tools/merge": "9.1.9",
|
|
22
|
+
"@graphql-tools/resolvers-composition": "7.0.31",
|
|
23
|
+
"@graphql-tools/schema": "10.0.33",
|
|
24
|
+
"@graphql-tools/utils": "11.1.0",
|
|
25
|
+
"@webiny/api": "0.0.0-unstable.7be00a75a9",
|
|
26
|
+
"@webiny/di": "0.0.0-unstable.7be00a75a9",
|
|
27
|
+
"@webiny/error": "0.0.0-unstable.7be00a75a9",
|
|
28
|
+
"@webiny/feature": "0.0.0-unstable.7be00a75a9",
|
|
29
|
+
"@webiny/handler": "0.0.0-unstable.7be00a75a9",
|
|
30
|
+
"@webiny/plugins": "0.0.0-unstable.7be00a75a9",
|
|
31
|
+
"@webiny/stdlib": "0.0.0-unstable.7be00a75a9",
|
|
32
|
+
"@webiny/utils": "0.0.0-unstable.7be00a75a9",
|
|
33
|
+
"graphql": "16.14.0",
|
|
31
34
|
"graphql-scalars": "1.25.0",
|
|
32
35
|
"graphql-tag": "2.12.6",
|
|
33
|
-
"zod": "
|
|
36
|
+
"zod": "4.4.3"
|
|
34
37
|
},
|
|
35
38
|
"devDependencies": {
|
|
36
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
37
|
-
"@webiny/handler-aws": "0.0.0-unstable.
|
|
38
|
-
"rimraf": "6.1.
|
|
39
|
-
"typescript": "
|
|
40
|
-
"vitest": "
|
|
39
|
+
"@webiny/build-tools": "0.0.0-unstable.7be00a75a9",
|
|
40
|
+
"@webiny/handler-aws": "0.0.0-unstable.7be00a75a9",
|
|
41
|
+
"rimraf": "6.1.3",
|
|
42
|
+
"typescript": "6.0.3",
|
|
43
|
+
"vitest": "4.1.7"
|
|
41
44
|
},
|
|
42
45
|
"publishConfig": {
|
|
43
|
-
"access": "public"
|
|
44
|
-
"directory": "dist"
|
|
46
|
+
"access": "public"
|
|
45
47
|
},
|
|
46
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "b8aec8a1be3f25c3b428b357fe1e352c7cbff9ae",
|
|
49
|
+
"webiny": {
|
|
50
|
+
"publishFrom": "dist"
|
|
51
|
+
}
|
|
47
52
|
}
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
class GraphQLSchemaPlugin extends Plugin {
|
|
3
|
+
static{
|
|
4
|
+
this.type = "graphql-schema";
|
|
5
|
+
}
|
|
6
|
+
constructor(config){
|
|
7
|
+
super();
|
|
8
|
+
this.config = config;
|
|
9
|
+
}
|
|
10
|
+
get schema() {
|
|
11
|
+
return {
|
|
12
|
+
typeDefs: this.config.typeDefs || "",
|
|
13
|
+
resolvers: this.config.resolvers,
|
|
14
|
+
resolverDecorators: this.config.resolverDecorators
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
isApplicable(context) {
|
|
18
|
+
if (this.config.isApplicable) return this.config.isApplicable(context);
|
|
19
|
+
return true;
|
|
18
20
|
}
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
22
|
+
const createGraphQLSchemaPlugin = (config)=>new GraphQLSchemaPlugin(config);
|
|
23
|
+
export { GraphQLSchemaPlugin, createGraphQLSchemaPlugin };
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=GraphQLSchemaPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/GraphQLSchemaPlugin.js","sources":["../../src/plugins/GraphQLSchemaPlugin.ts"],"sourcesContent":["import type { Context } from \"@webiny/api/types.js\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from \"~/types.js\";\n\nexport interface IGraphQLSchemaPlugin<TContext = Context> extends Plugin {\n schema: GraphQLSchemaDefinition<TContext>;\n isApplicable: (context: TContext) => boolean;\n}\n\nexport interface GraphQLSchemaPluginConfig<TContext> {\n typeDefs?: TypeDefs;\n resolvers?: Resolvers<TContext>;\n resolverDecorators?: ResolverDecorators;\n isApplicable?: (context: TContext) => boolean;\n}\n\nexport class GraphQLSchemaPlugin<TContext = Context>\n extends Plugin\n implements IGraphQLSchemaPlugin<TContext>\n{\n public static override readonly type: string = \"graphql-schema\";\n protected config: GraphQLSchemaPluginConfig<TContext>;\n\n constructor(config: GraphQLSchemaPluginConfig<TContext>) {\n super();\n this.config = config;\n }\n\n get schema(): GraphQLSchemaDefinition<TContext> {\n return {\n typeDefs: this.config.typeDefs || \"\",\n resolvers: this.config.resolvers,\n resolverDecorators: this.config.resolverDecorators\n };\n }\n\n isApplicable(context: TContext): boolean {\n if (this.config.isApplicable) {\n return this.config.isApplicable(context);\n }\n return true;\n }\n}\n\nexport const createGraphQLSchemaPlugin = <T = Context>(config: GraphQLSchemaPluginConfig<T>) => {\n return new GraphQLSchemaPlugin<T>(config);\n};\n"],"names":["GraphQLSchemaPlugin","Plugin","config","context","createGraphQLSchemaPlugin"],"mappings":";AAgBO,MAAMA,4BACDC;;aAGwB,IAAI,GAAW;;IAG/C,YAAYC,MAA2C,CAAE;QACrD,KAAK;QACL,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEA,IAAI,SAA4C;QAC5C,OAAO;YACH,UAAU,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI;YAClC,WAAW,IAAI,CAAC,MAAM,CAAC,SAAS;YAChC,oBAAoB,IAAI,CAAC,MAAM,CAAC,kBAAkB;QACtD;IACJ;IAEA,aAAaC,OAAiB,EAAW;QACrC,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,EACxB,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAACA;QAEpC,OAAO;IACX;AACJ;AAEO,MAAMC,4BAA4B,CAAcF,SAC5C,IAAIF,oBAAuBE"}
|
package/plugins/index.js
CHANGED
package/processRequestBody.js
CHANGED
|
@@ -1,43 +1,40 @@
|
|
|
1
1
|
import { graphql } from "graphql";
|
|
2
|
-
const executeGraphQl = async (body, schema, context)
|
|
3
|
-
|
|
4
|
-
query
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
rootValue: {},
|
|
17
|
-
contextValue: context,
|
|
18
|
-
variableValues: variables,
|
|
19
|
-
operationName
|
|
20
|
-
});
|
|
21
|
-
context.plugins.byType("graphql-after-query").forEach(pl => {
|
|
22
|
-
pl.apply({
|
|
23
|
-
result,
|
|
24
|
-
body,
|
|
25
|
-
schema,
|
|
26
|
-
context
|
|
2
|
+
const executeGraphQl = async (body, schema, context)=>{
|
|
3
|
+
const { query, variables, operationName } = body;
|
|
4
|
+
context.plugins.byType("graphql-before-query").forEach((pl)=>pl.apply({
|
|
5
|
+
body,
|
|
6
|
+
schema,
|
|
7
|
+
context
|
|
8
|
+
}));
|
|
9
|
+
const result = await graphql({
|
|
10
|
+
schema,
|
|
11
|
+
source: query,
|
|
12
|
+
rootValue: {},
|
|
13
|
+
contextValue: context,
|
|
14
|
+
variableValues: variables,
|
|
15
|
+
operationName
|
|
27
16
|
});
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
context.plugins.byType("graphql-after-query").forEach((pl)=>{
|
|
18
|
+
pl.apply({
|
|
19
|
+
result,
|
|
20
|
+
body,
|
|
21
|
+
schema,
|
|
22
|
+
context
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
return result;
|
|
30
26
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
const processRequestBody = async (requestBody, schema, context)=>{
|
|
28
|
+
if (Array.isArray(requestBody)) {
|
|
29
|
+
const results = [];
|
|
30
|
+
for (const body of requestBody){
|
|
31
|
+
const result = await executeGraphQl(body, schema, context);
|
|
32
|
+
results.push(result);
|
|
33
|
+
}
|
|
34
|
+
return results;
|
|
37
35
|
}
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
return await executeGraphQl(requestBody, schema, context);
|
|
36
|
+
return await executeGraphQl(requestBody, schema, context);
|
|
41
37
|
};
|
|
38
|
+
export { processRequestBody };
|
|
42
39
|
|
|
43
40
|
//# sourceMappingURL=processRequestBody.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"processRequestBody.js","sources":["../src/processRequestBody.ts"],"sourcesContent":["import type { ExecutionResult, GraphQLSchema } from \"graphql\";\nimport { graphql } from \"graphql\";\nimport type {\n GraphQLAfterQueryPlugin,\n GraphQLBeforeQueryPlugin,\n GraphQLRequestBody\n} from \"~/types.js\";\nimport type { Context } from \"@webiny/api/types.js\";\n\nconst executeGraphQl = async <TData = Record<string, any>, TExtensions = Record<string, any>>(\n body: GraphQLRequestBody,\n schema: GraphQLSchema,\n context: Context\n): Promise<ExecutionResult<TData, TExtensions>> => {\n const { query, variables, operationName } = body;\n\n context.plugins\n .byType<GraphQLBeforeQueryPlugin>(\"graphql-before-query\")\n .forEach(pl => pl.apply({ body, schema, context }));\n\n const result = await graphql({\n schema,\n source: query,\n rootValue: {},\n contextValue: context,\n variableValues: variables,\n operationName\n });\n\n context.plugins.byType<GraphQLAfterQueryPlugin>(\"graphql-after-query\").forEach(pl => {\n pl.apply({ result, body, schema, context });\n });\n\n return result as ExecutionResult<TData, TExtensions>;\n};\n\nexport const processRequestBody = async <\n TData = Record<string, any>,\n TExtensions = Record<string, any>\n>(\n requestBody: GraphQLRequestBody | GraphQLRequestBody[],\n schema: GraphQLSchema,\n context: Context\n): Promise<ExecutionResult<TData, TExtensions>[] | ExecutionResult<TData, TExtensions>> => {\n if (Array.isArray(requestBody)) {\n const results: ExecutionResult<TData, TExtensions>[] = [];\n for (const body of requestBody) {\n const result = await executeGraphQl<TData, TExtensions>(body, schema, context);\n results.push(result);\n }\n return results;\n }\n return await executeGraphQl<TData, TExtensions>(requestBody, schema, context);\n};\n"],"names":["executeGraphQl","body","schema","context","query","variables","operationName","pl","result","graphql","processRequestBody","requestBody","Array","results"],"mappings":";AASA,MAAMA,iBAAiB,OACnBC,MACAC,QACAC;IAEA,MAAM,EAAEC,KAAK,EAAEC,SAAS,EAAEC,aAAa,EAAE,GAAGL;IAE5CE,QAAQ,OAAO,CACV,MAAM,CAA2B,wBACjC,OAAO,CAACI,CAAAA,KAAMA,GAAG,KAAK,CAAC;YAAEN;YAAMC;YAAQC;QAAQ;IAEpD,MAAMK,SAAS,MAAMC,QAAQ;QACzBP;QACA,QAAQE;QACR,WAAW,CAAC;QACZ,cAAcD;QACd,gBAAgBE;QAChBC;IACJ;IAEAH,QAAQ,OAAO,CAAC,MAAM,CAA0B,uBAAuB,OAAO,CAACI,CAAAA;QAC3EA,GAAG,KAAK,CAAC;YAAEC;YAAQP;YAAMC;YAAQC;QAAQ;IAC7C;IAEA,OAAOK;AACX;AAEO,MAAME,qBAAqB,OAI9BC,aACAT,QACAC;IAEA,IAAIS,MAAM,OAAO,CAACD,cAAc;QAC5B,MAAME,UAAiD,EAAE;QACzD,KAAK,MAAMZ,QAAQU,YAAa;YAC5B,MAAMH,SAAS,MAAMR,eAAmCC,MAAMC,QAAQC;YACtEU,QAAQ,IAAI,CAACL;QACjB;QACA,OAAOK;IACX;IACA,OAAO,MAAMb,eAAmCW,aAAaT,QAAQC;AACzE"}
|
package/responses.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
export interface IMeta {
|
|
2
|
+
hasMoreItems: boolean;
|
|
3
|
+
totalCount: number;
|
|
4
|
+
cursor?: string | null;
|
|
5
|
+
}
|
|
1
6
|
export interface ErrorResponseParams {
|
|
2
7
|
message: string;
|
|
3
8
|
code?: string;
|
|
4
9
|
data?: any;
|
|
5
10
|
stack?: string | null;
|
|
6
11
|
}
|
|
12
|
+
/** GraphQL error response helper. */
|
|
7
13
|
export declare class ErrorResponse {
|
|
8
14
|
readonly data: null;
|
|
9
15
|
readonly error: {
|
|
@@ -14,9 +20,11 @@ export declare class ErrorResponse {
|
|
|
14
20
|
};
|
|
15
21
|
constructor(params: ErrorResponseParams);
|
|
16
22
|
}
|
|
23
|
+
/** GraphQL not-found response helper. */
|
|
17
24
|
export declare class NotFoundResponse extends ErrorResponse {
|
|
18
25
|
constructor(message: string);
|
|
19
26
|
}
|
|
27
|
+
/** GraphQL list error response helper. */
|
|
20
28
|
export declare class ListErrorResponse {
|
|
21
29
|
readonly data: null;
|
|
22
30
|
readonly meta: null;
|
|
@@ -28,12 +36,14 @@ export declare class ListErrorResponse {
|
|
|
28
36
|
};
|
|
29
37
|
constructor(params: ErrorResponseParams);
|
|
30
38
|
}
|
|
39
|
+
/** GraphQL response helper. */
|
|
31
40
|
export declare class Response<T = any> {
|
|
32
41
|
readonly data: T;
|
|
33
42
|
readonly error: null;
|
|
34
43
|
constructor(data: T);
|
|
35
44
|
}
|
|
36
|
-
|
|
45
|
+
/** GraphQL list response helper. */
|
|
46
|
+
export declare class ListResponse<T, M = IMeta> {
|
|
37
47
|
readonly data: Array<T>;
|
|
38
48
|
readonly meta: M;
|
|
39
49
|
readonly error: null;
|
package/responses.js
CHANGED
|
@@ -1,66 +1,59 @@
|
|
|
1
1
|
const defaultParams = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
code: "",
|
|
3
|
+
message: "",
|
|
4
|
+
data: null,
|
|
5
|
+
stack: null
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
class ErrorResponse {
|
|
8
|
+
constructor(params){
|
|
9
|
+
this.data = null;
|
|
10
|
+
const debug = "true" === process.env.DEBUG;
|
|
11
|
+
let stack = defaultParams.stack;
|
|
12
|
+
if (debug && params.stack) stack = params.stack;
|
|
13
|
+
this.error = {
|
|
14
|
+
code: params.code || defaultParams.code,
|
|
15
|
+
message: params.message || defaultParams.message,
|
|
16
|
+
data: params.data || defaultParams.data,
|
|
17
|
+
stack: stack
|
|
18
|
+
};
|
|
16
19
|
}
|
|
17
|
-
this.error = {
|
|
18
|
-
code: params.code || defaultParams.code,
|
|
19
|
-
message: params.message || defaultParams.message,
|
|
20
|
-
data: params.data || defaultParams.data,
|
|
21
|
-
stack: stack
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
20
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
class NotFoundResponse extends ErrorResponse {
|
|
22
|
+
constructor(message){
|
|
23
|
+
super({
|
|
24
|
+
code: "NOT_FOUND",
|
|
25
|
+
message
|
|
26
|
+
});
|
|
27
|
+
}
|
|
32
28
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
class ListErrorResponse {
|
|
30
|
+
constructor(params){
|
|
31
|
+
this.meta = null;
|
|
32
|
+
this.data = null;
|
|
33
|
+
const debug = "true" === process.env.DEBUG;
|
|
34
|
+
let stack = defaultParams.stack;
|
|
35
|
+
if (debug && params.stack) stack = params.stack;
|
|
36
|
+
this.error = {
|
|
37
|
+
code: params.code || defaultParams.code,
|
|
38
|
+
message: params.message || defaultParams.message,
|
|
39
|
+
data: params.data || defaultParams.data,
|
|
40
|
+
stack: stack
|
|
41
|
+
};
|
|
43
42
|
}
|
|
44
|
-
this.error = {
|
|
45
|
-
code: params.code || defaultParams.code,
|
|
46
|
-
message: params.message || defaultParams.message,
|
|
47
|
-
data: params.data || defaultParams.data,
|
|
48
|
-
stack: stack
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
43
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
class Response {
|
|
45
|
+
constructor(data){
|
|
46
|
+
this.data = data;
|
|
47
|
+
this.error = null;
|
|
48
|
+
}
|
|
57
49
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
class ListResponse {
|
|
51
|
+
constructor(data, meta){
|
|
52
|
+
this.data = Array.isArray(data) ? data : [];
|
|
53
|
+
this.meta = meta || {};
|
|
54
|
+
this.error = null;
|
|
55
|
+
}
|
|
64
56
|
}
|
|
57
|
+
export { ErrorResponse, ListErrorResponse, ListResponse, NotFoundResponse, Response };
|
|
65
58
|
|
|
66
59
|
//# sourceMappingURL=responses.js.map
|