@rsdk/graphql 5.8.0-next.6 → 5.8.0-next.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdk/graphql",
3
- "version": "5.8.0-next.6",
3
+ "version": "5.8.0-next.8",
4
4
  "description": "Plugin for graphql",
5
5
  "license": "Apache License 2.0",
6
6
  "publishConfig": {
@@ -29,5 +29,5 @@
29
29
  "reflect-metadata": "^0.1.12 || ^0.2.0",
30
30
  "rxjs": "^7.1.0"
31
31
  },
32
- "gitHead": "317e239c10a0601b489b6a1347f8de88a730e8d8"
32
+ "gitHead": "3a9234e0fd5e335c4d6098159a8d1a237727406a"
33
33
  }
@@ -0,0 +1 @@
1
+ { "type": "graphql", "requestLogging": true, "throwError": false }
@@ -0,0 +1 @@
1
+ { "type": "graphql", "requestLogging": false, "throwError": false }
@@ -0,0 +1 @@
1
+ { "type": "not-graphql", "requestLogging": false, "throwError": false }
@@ -0,0 +1 @@
1
+ { "type": "graphql", "requestLogging": true, "throwError": true }
@@ -0,0 +1,71 @@
1
+ import { InternalException } from '@rsdk/core';
2
+ import type { Observable } from 'rxjs';
3
+ import { firstValueFrom, of, throwError } from 'rxjs';
4
+
5
+ import { GraphqlLoggerInterceptor } from '../../src/graphql-logger.interceptor';
6
+
7
+ interface Input {
8
+ type: string;
9
+ requestLogging: boolean;
10
+ throwError: boolean;
11
+ }
12
+
13
+ export class LoggerMock {
14
+ trace(): void {}
15
+ }
16
+
17
+ export async function fuzz(buffer: Buffer): Promise<any> {
18
+ try {
19
+ const input = parseInput(buffer);
20
+ if (!input) return;
21
+
22
+ const graphqlLoggerInterceptor = new GraphqlLoggerInterceptor(
23
+ new LoggerMock() as any,
24
+ { requestLogging: input.requestLogging } as any,
25
+ );
26
+
27
+ const ctx: any = {
28
+ getType: () => input.type,
29
+ getArgs: () => [{}, { req: {} }, {}],
30
+ getClass: () => LoggerMock,
31
+ getHandler: () => {},
32
+ };
33
+
34
+ const callHandler = {
35
+ handle: (): Observable<any> => {
36
+ if (input.throwError) {
37
+ return throwError(
38
+ () => new InternalException('Something went wrong'),
39
+ );
40
+ }
41
+
42
+ return of({ data: 'some response' });
43
+ },
44
+ } as any;
45
+
46
+ await firstValueFrom(
47
+ await graphqlLoggerInterceptor.intercept(ctx, callHandler as any),
48
+ );
49
+ } catch (error) {
50
+ if (error instanceof InternalException) return;
51
+
52
+ throw error;
53
+ }
54
+
55
+ function parseInput(buffer: Buffer): Input | null {
56
+ let input: any;
57
+
58
+ try {
59
+ input = JSON.parse(buffer.toString());
60
+ } catch {
61
+ return null;
62
+ }
63
+
64
+ if (typeof input !== 'object' || input === null) return null;
65
+ if (typeof input.type !== 'string') return null;
66
+ if (typeof input.requestLogging !== 'boolean') return null;
67
+ if (typeof input.throwError !== 'boolean') return null;
68
+
69
+ return input;
70
+ }
71
+ }
@@ -4,6 +4,7 @@
4
4
  "node_modules",
5
5
  "dist",
6
6
  "test",
7
+ "testFuzz",
7
8
  "**/*.spec.ts",
8
9
  "**/*.test.ts",
9
10
  "**/*.test.e2e.ts",
@@ -0,0 +1,25 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": ".",
5
+ "outDir": "dist",
6
+ "removeComments": true,
7
+ "experimentalDecorators": true,
8
+ "sourceMap": true,
9
+ "noUnusedParameters": false,
10
+ },
11
+ "include": [
12
+ "src/**/*",
13
+ "testFuzz/**/*"
14
+ ],
15
+ "exclude": [
16
+ "node_modules",
17
+ "test",
18
+ "dist",
19
+ "__tests__",
20
+ "**/*spec.ts",
21
+ "**/*.test.ts",
22
+ "**/*.test.e2e.ts",
23
+ "**/*.test.manual-e2e.ts",
24
+ ]
25
+ }