@tmdb-graphql-api/rest-client 0.0.10-unstable.0 → 0.0.10

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@tmdb-graphql-api/rest-client",
3
3
  "description": "The TMDB GraphQL rest client module.",
4
- "version": "0.0.10-unstable.0",
4
+ "version": "0.0.10",
5
5
  "author": "Dylan Aubrey",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/badbatch/themoviedb-graphql-api",
@@ -31,8 +31,9 @@
31
31
  "dependencies": {
32
32
  "@cachemap/core": "^5.2.7",
33
33
  "@graphql-box/core": "^5.4.2",
34
- "getta": "^1.0.6",
35
- "type-fest": "^4.37.0"
34
+ "getta": "^1.0.10",
35
+ "type-fest": "^4.37.0",
36
+ "winston": "^3.17.0"
36
37
  },
37
38
  "peerDependencies": {
38
39
  "@babel/runtime": "<8",
@@ -1,7 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`createRestClient > WHEN the dollygrip rest client is created > THEN it should have the correct properties and methods 1`] = `
4
- J {
4
+ {
5
5
  "_basePath": "https://api.themoviedb.org/3/",
6
6
  "_bodyParser": [Function],
7
7
  "_cache": "mock-cache",
package/src/main.test.ts CHANGED
@@ -15,7 +15,7 @@ describe('createRestClient >', () => {
15
15
  queryParams: { api_key: '12345' },
16
16
  });
17
17
 
18
- expect(restClient).toMatchSnapshot();
18
+ expect({ ...restClient }).toMatchSnapshot();
19
19
  });
20
20
  });
21
21
  });
package/src/main.ts CHANGED
@@ -1,5 +1,10 @@
1
- import { RESOLVER_EXECUTED, RESOLVER_RESOLVED } from '@graphql-box/core';
2
- import { REQUEST_SENT, RESPONSE_RECEIVED, createRestClient as create } from 'getta';
1
+ import {
2
+ REQUEST_FAILED,
3
+ REQUEST_SENT,
4
+ RESPONSE_FROM_CACHE,
5
+ RESPONSE_RECEIVED,
6
+ createRestClient as create,
7
+ } from 'getta';
3
8
  import { performance } from 'node:perf_hooks';
4
9
  import {
5
10
  AUTHENTICATE_PATH,
@@ -32,17 +37,19 @@ import { type CreateRestClientParams, type ShortcutMethodNames } from './types.t
32
37
 
33
38
  const { NODE_ENV } = process.env;
34
39
 
35
- export const createRestClient = ({ cache, debugManager, queryParams }: CreateRestClientParams) =>
40
+ export const createRestClient = ({ cache, logger, queryParams }: CreateRestClientParams) =>
36
41
  create<ShortcutMethodNames>(
37
42
  {
38
43
  basePath: BASE_PATH,
39
44
  cache,
40
45
  fetchTimeout: NODE_ENV === 'development' ? 999_999 : undefined,
41
46
  log: (message, data, logLevel) => {
42
- if (message === REQUEST_SENT) {
43
- debugManager?.log(RESOLVER_EXECUTED, data, logLevel);
44
- } else if (message === RESPONSE_RECEIVED) {
45
- debugManager?.log(RESOLVER_RESOLVED, data, logLevel);
47
+ if (message === REQUEST_SENT || message === RESPONSE_FROM_CACHE || message === RESPONSE_RECEIVED) {
48
+ logger?.info(message, { ...data, logLevel });
49
+ }
50
+
51
+ if (message === REQUEST_FAILED) {
52
+ logger?.error(message, { ...data, logLevel });
46
53
  }
47
54
  },
48
55
  pathTemplateCallback,
package/src/types.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type Core } from '@cachemap/core';
2
- import { type DebugManagerDef } from '@graphql-box/core';
3
2
  import { type JsonObject } from 'type-fest';
3
+ import { type Logger } from 'winston';
4
4
 
5
5
  export type ShortcutMethodNames =
6
6
  | 'authenticate'
@@ -29,7 +29,7 @@ export type ShortcutMethodNames =
29
29
 
30
30
  export interface CreateRestClientParams {
31
31
  cache?: Core;
32
- debugManager?: DebugManagerDef;
32
+ logger?: Logger;
33
33
  // eslint-disable-next-line camelcase
34
34
  queryParams: JsonObject & { api_key: string; language?: string };
35
35
  }