@webiny/handler-graphql 5.23.1-beta.0 → 5.24.0

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.
@@ -33,7 +33,7 @@ const DEFAULT_HEADERS = _objectSpread({
33
33
  const DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year
34
34
 
35
35
  var _default = (options = {}) => {
36
- let schema;
36
+ let schema = undefined;
37
37
  const debug = (0, _boolean.boolean)(options.debug);
38
38
  return [...(debug ? (0, _debugPlugins.default)() : []), {
39
39
  type: "handler",
package/index.d.ts CHANGED
@@ -1,9 +1,16 @@
1
1
  import { HandlerGraphQLOptions } from "./types";
2
2
  import { Context } from "@webiny/handler/types";
3
3
  import { GraphQLFieldResolver } from "./types";
4
+ /**
5
+ * Can be anything.
6
+ * TODO: Figure out if required at all.
7
+ */
8
+ interface Callable {
9
+ (params: any): any;
10
+ }
4
11
  export * from "./errors";
5
12
  export * from "./responses";
6
13
  declare const _default: (options?: HandlerGraphQLOptions) => import("@webiny/plugins/types").PluginCollection[];
7
14
  export default _default;
8
- export declare const pipe: <TSource = any, TArgs = Record<string, any>, TContext = Context>(...fns: any[]) => (resolver: import("graphql").GraphQLFieldResolver<TSource, TContext, TArgs>) => any;
9
- export declare const compose: <TSource = any, TArgs = Record<string, any>, TContext = Context>(...fns: any[]) => (resolver: import("graphql").GraphQLFieldResolver<TSource, TContext, TArgs>) => any;
15
+ export declare const pipe: <TSource = any, TArgs = Record<string, any>, TContext = Context>(...fns: Callable[]) => (resolver: import("graphql").GraphQLFieldResolver<TSource, TContext, TArgs>) => any;
16
+ export declare const compose: <TSource = any, TArgs = Record<string, any>, TContext = Context>(...fns: Callable[]) => (resolver: import("graphql").GraphQLFieldResolver<TSource, TContext, TArgs>) => any;
@@ -1 +1,5 @@
1
- export declare const interceptConsole: (callback: any) => void;
1
+ interface InterceptConsoleCallable {
2
+ (method: string, args: any[]): void;
3
+ }
4
+ export declare const interceptConsole: (callback: InterceptConsoleCallable) => void;
5
+ export {};
@@ -10,19 +10,23 @@ const skipOriginal = ["table"];
10
10
 
11
11
  const restoreOriginalMethods = () => {
12
12
  for (const method of consoleMethods) {
13
+ // @ts-ignore
13
14
  console[method] = originalMethods[method];
14
15
  }
15
16
  };
16
17
 
17
18
  const interceptConsole = callback => {
19
+ // @ts-ignore
18
20
  if (console["__WEBINY__"] === true) {
19
21
  restoreOriginalMethods();
20
- }
22
+ } // @ts-ignore
23
+
21
24
 
22
25
  console["__WEBINY__"] = true;
23
26
 
24
27
  for (const method of consoleMethods) {
25
- originalMethods[method] = console[method];
28
+ // @ts-ignore
29
+ originalMethods[method] = console[method]; // @ts-ignore
26
30
 
27
31
  console[method] = (...args) => {
28
32
  callback(method, args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/handler-graphql",
3
- "version": "5.23.1-beta.0",
3
+ "version": "5.24.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -16,11 +16,11 @@
16
16
  "dependencies": {
17
17
  "@babel/runtime": "7.16.7",
18
18
  "@graphql-tools/schema": "7.1.5",
19
- "@webiny/error": "5.23.1-beta.0",
20
- "@webiny/handler": "5.23.1-beta.0",
21
- "@webiny/handler-http": "5.23.1-beta.0",
22
- "@webiny/plugins": "5.23.1-beta.0",
23
- "@webiny/utils": "5.23.1-beta.0",
19
+ "@webiny/error": "5.24.0",
20
+ "@webiny/handler": "5.24.0",
21
+ "@webiny/handler-http": "5.24.0",
22
+ "@webiny/plugins": "5.24.0",
23
+ "@webiny/utils": "5.24.0",
24
24
  "boolean": "3.1.4",
25
25
  "graphql": "15.8.0",
26
26
  "graphql-scalars": "1.12.0",
@@ -30,9 +30,9 @@
30
30
  "@babel/cli": "^7.16.0",
31
31
  "@babel/core": "^7.16.0",
32
32
  "@babel/preset-env": "^7.16.4",
33
- "@webiny/cli": "^5.23.1-beta.0",
34
- "@webiny/handler-args": "^5.23.1-beta.0",
35
- "@webiny/project-utils": "^5.23.1-beta.0",
33
+ "@webiny/cli": "^5.24.0",
34
+ "@webiny/handler-args": "^5.24.0",
35
+ "@webiny/project-utils": "^5.24.0",
36
36
  "jest": "^26.6.3",
37
37
  "jest-mock-console": "^1.0.0",
38
38
  "rimraf": "^3.0.2",
@@ -46,5 +46,5 @@
46
46
  "build": "yarn webiny run build",
47
47
  "watch": "yarn webiny run watch"
48
48
  },
49
- "gitHead": "05db67aebc2de3c33ba0622f730157ae14143b95"
49
+ "gitHead": "be0cbfcaa9247c658c44179af7943cc5d6d71bc7"
50
50
  }
@@ -1,3 +1,5 @@
1
+ import { ExecutionResult, GraphQLSchema } from "graphql";
2
+ import { GraphQLRequestBody } from "./types";
1
3
  import { Context } from "@webiny/handler/types";
2
- declare const _default: (requestBody: any, schema: any, context: Context) => Promise<any>;
4
+ declare const _default: (requestBody: GraphQLRequestBody | GraphQLRequestBody[], schema: GraphQLSchema, context: Context) => Promise<ExecutionResult[] | ExecutionResult>;
3
5
  export default _default;
@@ -31,19 +31,17 @@ const processRequestBody = async (body, schema, context) => {
31
31
  };
32
32
 
33
33
  var _default = async (requestBody, schema, context) => {
34
- let result;
35
-
36
- if (Array.isArray(requestBody)) {
37
- result = [];
34
+ if (Array.isArray(requestBody) === true) {
35
+ const result = [];
38
36
 
39
37
  for (let i = 0; i < requestBody.length; i++) {
40
38
  result.push(await processRequestBody(requestBody[i], schema, context));
41
39
  }
42
- } else {
43
- result = await processRequestBody(requestBody, schema, context);
40
+
41
+ return result;
44
42
  }
45
43
 
46
- return result;
44
+ return await processRequestBody(requestBody, schema, context);
47
45
  };
48
46
 
49
47
  exports.default = _default;
package/responses.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- declare type ErrorResponseParams = {
1
+ interface ErrorResponseParams {
2
2
  code?: string;
3
3
  message?: string;
4
4
  data?: any;
5
- };
5
+ }
6
6
  export declare class ErrorResponse {
7
7
  data: any;
8
8
  error: {