@tmdb-graphql-api/resolvers 0.1.2-unstable.1 → 0.1.2-unstable.3
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/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/production.analysis.txt +364 -364
- package/dist/types/cjs/helpers/buildArgsResolver.d.cts +1 -1
- package/dist/types/cjs/helpers/buildArgsResolver.d.cts.map +1 -1
- package/dist/types/cjs/helpers/buildNoObjArgsResolver.d.cts.map +1 -1
- package/dist/types/cjs/helpers/buildObjArgsResolver.d.cts.map +1 -1
- package/dist/types/cjs/helpers/buildObjResolver.d.cts.map +1 -1
- package/dist/types/cjs/queries/configuration.d.cts.map +1 -1
- package/dist/types/cjs/queries/movieAlternativeTitles.d.cts.map +1 -1
- package/dist/types/cjs/queries/movieReviews.d.cts.map +1 -1
- package/dist/types/cjs/types.d.cts +6 -5
- package/dist/types/cjs/types.d.cts.map +1 -1
- package/dist/types/esm/helpers/buildArgsResolver.d.ts +1 -1
- package/dist/types/esm/helpers/buildArgsResolver.d.ts.map +1 -1
- package/dist/types/esm/helpers/buildNoObjArgsResolver.d.ts.map +1 -1
- package/dist/types/esm/helpers/buildObjArgsResolver.d.ts.map +1 -1
- package/dist/types/esm/helpers/buildObjResolver.d.ts.map +1 -1
- package/dist/types/esm/queries/configuration.d.ts.map +1 -1
- package/dist/types/esm/queries/movieAlternativeTitles.d.ts.map +1 -1
- package/dist/types/esm/queries/movieReviews.d.ts.map +1 -1
- package/dist/types/esm/types.d.ts +6 -5
- package/dist/types/esm/types.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/helpers/buildArgsResolver.ts +17 -14
- package/src/helpers/buildNoObjArgsResolver.ts +10 -8
- package/src/helpers/buildObjArgsResolver.ts +11 -9
- package/src/helpers/buildObjResolver.ts +12 -9
- package/src/queries/certifications.test.ts +4 -1
- package/src/queries/certifications.ts +2 -2
- package/src/queries/collection.test.ts +4 -1
- package/src/queries/collection.ts +2 -2
- package/src/queries/collectionImages.test.ts +4 -1
- package/src/queries/collectionImages.ts +2 -2
- package/src/queries/collectionTranslations.test.ts +4 -1
- package/src/queries/collectionTranslations.ts +2 -2
- package/src/queries/company.test.ts +4 -1
- package/src/queries/company.ts +2 -2
- package/src/queries/companyAlternativeNames.test.ts +4 -1
- package/src/queries/companyAlternativeNames.ts +2 -2
- package/src/queries/companyLogos.test.ts +4 -1
- package/src/queries/companyLogos.ts +2 -2
- package/src/queries/configuration.test.ts +4 -1
- package/src/queries/configuration.ts +2 -6
- package/src/queries/configurationCountries.test.ts +4 -1
- package/src/queries/configurationCountries.ts +2 -2
- package/src/queries/configurationJobs.test.ts +4 -1
- package/src/queries/configurationJobs.ts +2 -2
- package/src/queries/configurationLanguages.test.ts +4 -1
- package/src/queries/configurationLanguages.ts +2 -2
- package/src/queries/configurationPrimaryTranslations.test.ts +4 -1
- package/src/queries/configurationPrimaryTranslations.ts +2 -2
- package/src/queries/configurationTimezones.test.ts +4 -1
- package/src/queries/configurationTimezones.ts +2 -2
- package/src/queries/credit.test.ts +4 -1
- package/src/queries/credit.ts +2 -2
- package/src/queries/discoverMovies.test.ts +9 -3
- package/src/queries/discoverMovies.ts +2 -2
- package/src/queries/discoverTv.test.ts +9 -3
- package/src/queries/discoverTv.ts +2 -2
- package/src/queries/episode.test.ts +4 -1
- package/src/queries/episode.ts +2 -2
- package/src/queries/episodeCredits.test.ts +4 -1
- package/src/queries/episodeCredits.ts +2 -2
- package/src/queries/episodeExternalIds.test.ts +4 -1
- package/src/queries/episodeExternalIds.ts +2 -2
- package/src/queries/episodeStills.test.ts +4 -1
- package/src/queries/episodeStills.ts +2 -2
- package/src/queries/episodeTranslations.test.ts +4 -1
- package/src/queries/episodeTranslations.ts +2 -2
- package/src/queries/episodeVideos.test.ts +4 -1
- package/src/queries/episodeVideos.ts +2 -2
- package/src/queries/find.test.ts +4 -1
- package/src/queries/find.ts +2 -2
- package/src/queries/genres.test.ts +4 -1
- package/src/queries/genres.ts +2 -2
- package/src/queries/keyword.test.ts +4 -1
- package/src/queries/keyword.ts +2 -2
- package/src/queries/movie.test.ts +4 -1
- package/src/queries/movie.ts +2 -2
- package/src/queries/movieAlternativeTitles.test.ts +4 -1
- package/src/queries/movieAlternativeTitles.ts +3 -2
- package/src/queries/movieCredits.test.ts +4 -1
- package/src/queries/movieCredits.ts +2 -2
- package/src/queries/movieExternalIds.test.ts +4 -1
- package/src/queries/movieExternalIds.ts +2 -2
- package/src/queries/movieImages.test.ts +4 -1
- package/src/queries/movieImages.ts +2 -2
- package/src/queries/movieKeywords.test.ts +4 -1
- package/src/queries/movieKeywords.ts +2 -2
- package/src/queries/movieRecommendations.test.ts +5 -2
- package/src/queries/movieRecommendations.ts +2 -2
- package/src/queries/movieReleaseDates.test.ts +4 -1
- package/src/queries/movieReleaseDates.ts +2 -2
- package/src/queries/movieReviews.test.ts +9 -4
- package/src/queries/movieReviews.ts +3 -2
- package/src/queries/movieSimilarMovies.test.ts +5 -2
- package/src/queries/movieSimilarMovies.ts +2 -2
- package/src/queries/movieTranslations.test.ts +4 -1
- package/src/queries/movieTranslations.ts +2 -2
- package/src/queries/movieVideos.test.ts +4 -1
- package/src/queries/movieVideos.ts +2 -2
- package/src/queries/movieWatchProviders.test.ts +4 -1
- package/src/queries/movieWatchProviders.ts +2 -2
- package/src/queries/network.test.ts +4 -1
- package/src/queries/network.ts +2 -2
- package/src/queries/networkAlternativeNames.test.ts +4 -1
- package/src/queries/networkAlternativeNames.ts +2 -2
- package/src/queries/networkLogos.test.ts +4 -1
- package/src/queries/networkLogos.ts +2 -2
- package/src/queries/person.test.ts +4 -1
- package/src/queries/person.ts +2 -2
- package/src/queries/personCombinedCredits.test.ts +4 -1
- package/src/queries/personCombinedCredits.ts +2 -2
- package/src/queries/personExternalIds.test.ts +4 -1
- package/src/queries/personExternalIds.ts +2 -2
- package/src/queries/personMovieCredits.test.ts +4 -1
- package/src/queries/personMovieCredits.ts +2 -2
- package/src/queries/personProfiles.test.ts +4 -1
- package/src/queries/personProfiles.ts +2 -2
- package/src/queries/personTranslations.test.ts +4 -1
- package/src/queries/personTranslations.ts +2 -2
- package/src/queries/personTvCredits.test.ts +4 -1
- package/src/queries/personTvCredits.ts +2 -2
- package/src/queries/rated.test.ts +7 -4
- package/src/queries/rated.ts +3 -3
- package/src/queries/review.test.ts +4 -1
- package/src/queries/review.ts +2 -2
- package/src/queries/search.test.ts +5 -2
- package/src/queries/search.ts +2 -2
- package/src/queries/season.test.ts +4 -1
- package/src/queries/season.ts +2 -2
- package/src/queries/seasonCredits.test.ts +4 -1
- package/src/queries/seasonCredits.ts +2 -2
- package/src/queries/seasonExternalIds.test.ts +4 -1
- package/src/queries/seasonExternalIds.ts +2 -2
- package/src/queries/seasonPosters.test.ts +4 -1
- package/src/queries/seasonPosters.ts +2 -2
- package/src/queries/seasonTranslations.test.ts +4 -1
- package/src/queries/seasonTranslations.ts +2 -2
- package/src/queries/seasonVideos.test.ts +4 -1
- package/src/queries/seasonVideos.ts +2 -2
- package/src/queries/trending.test.ts +5 -2
- package/src/queries/trending.ts +2 -2
- package/src/queries/tv.test.ts +4 -1
- package/src/queries/tv.ts +2 -2
- package/src/queries/tvAlternativeTitles.test.ts +4 -1
- package/src/queries/tvAlternativeTitles.ts +2 -2
- package/src/queries/tvContentRatings.test.ts +4 -1
- package/src/queries/tvContentRatings.ts +2 -2
- package/src/queries/tvCredits.test.ts +4 -1
- package/src/queries/tvCredits.ts +2 -2
- package/src/queries/tvEpisodeGroups.test.ts +4 -1
- package/src/queries/tvEpisodeGroups.ts +2 -2
- package/src/queries/tvExternalIds.test.ts +4 -1
- package/src/queries/tvExternalIds.ts +2 -2
- package/src/queries/tvImages.test.ts +4 -1
- package/src/queries/tvImages.ts +2 -2
- package/src/queries/tvKeywords.test.ts +4 -1
- package/src/queries/tvKeywords.ts +2 -2
- package/src/queries/tvRecommendations.test.ts +5 -2
- package/src/queries/tvRecommendations.ts +2 -2
- package/src/queries/tvReviews.test.ts +5 -2
- package/src/queries/tvReviews.ts +2 -2
- package/src/queries/tvSimilarTvShows.test.ts +5 -2
- package/src/queries/tvSimilarTvShows.ts +2 -2
- package/src/queries/tvTranslations.test.ts +4 -1
- package/src/queries/tvTranslations.ts +2 -2
- package/src/queries/tvVideos.test.ts +4 -1
- package/src/queries/tvVideos.ts +2 -2
- package/src/queries/tvWatchProviders.test.ts +4 -1
- package/src/queries/tvWatchProviders.ts +2 -2
- package/src/types.ts +4 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmdb-graphql-api/resolvers",
|
|
3
3
|
"description": "The TMDB GraphQL resolvers module.",
|
|
4
|
-
"version": "0.1.2-unstable.
|
|
4
|
+
"version": "0.1.2-unstable.3",
|
|
5
5
|
"author": "Dylan Aubrey",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/badbatch/themoviedb-graphql-api",
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
"@cachemap/core": "^5.2.7",
|
|
33
33
|
"@cachemap/map": "^5.0.9",
|
|
34
34
|
"@cachemap/reaper": "^5.1.3",
|
|
35
|
-
"@graphql-box/connection-resolver": "^5.4.
|
|
36
|
-
"@graphql-box/core": "^5.4.
|
|
37
|
-
"cacheability": "^4.0.
|
|
35
|
+
"@graphql-box/connection-resolver": "^5.4.8",
|
|
36
|
+
"@graphql-box/core": "^5.4.4",
|
|
37
|
+
"cacheability": "^4.0.27",
|
|
38
38
|
"getta": "^1.0.10",
|
|
39
39
|
"js-base64": "^3.6.0",
|
|
40
40
|
"query-string": "^8.1.0",
|
|
41
41
|
"type-fest": "^4.37.0",
|
|
42
42
|
"winston": "^3.17.0",
|
|
43
|
-
"@tmdb-graphql-api/rest-client": "0.0.11-unstable.
|
|
44
|
-
"@tmdb-graphql-api/schema": "0.1.1-unstable.
|
|
43
|
+
"@tmdb-graphql-api/rest-client": "0.0.11-unstable.3",
|
|
44
|
+
"@tmdb-graphql-api/schema": "0.1.1-unstable.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@babel/runtime": "<8",
|
|
@@ -51,14 +51,14 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@babel/runtime": "^7.23.2",
|
|
54
|
-
"@graphql-box/helpers": "^5.4.
|
|
54
|
+
"@graphql-box/helpers": "^5.4.3",
|
|
55
55
|
"@jest/globals": "^29.7.0",
|
|
56
56
|
"@types/lodash-es": "^4.14.191",
|
|
57
57
|
"core-js": "^3.33.1",
|
|
58
|
-
"cts-types": "^0.0.
|
|
58
|
+
"cts-types": "^0.0.8",
|
|
59
59
|
"del-cli": "^5.1.0",
|
|
60
|
-
"fetch-mocked": "^0.0.
|
|
61
|
-
"graphql": "^16.
|
|
60
|
+
"fetch-mocked": "^0.0.27",
|
|
61
|
+
"graphql": "^16.10.0",
|
|
62
62
|
"lodash-es": "^4.17.21",
|
|
63
63
|
"@tmdb-graphql-api/test-utils": "0.1.0"
|
|
64
64
|
},
|
|
@@ -3,7 +3,7 @@ import { type Context } from '../types.ts';
|
|
|
3
3
|
|
|
4
4
|
export const buildArgsResolver =
|
|
5
5
|
<Args extends object, Data>(
|
|
6
|
-
|
|
6
|
+
fieldName: string,
|
|
7
7
|
callback: (
|
|
8
8
|
args: Args,
|
|
9
9
|
ctx: Context,
|
|
@@ -11,27 +11,30 @@ export const buildArgsResolver =
|
|
|
11
11
|
) => Promise<{ data?: Data; errors?: Error[]; headers: Headers; source?: string }>
|
|
12
12
|
) =>
|
|
13
13
|
async (_obj: undefined, args: Args, ctx: Context, info: GraphQLResolveInfo) => {
|
|
14
|
-
const { logger,
|
|
14
|
+
const { logger, setCacheMetadata } = ctx;
|
|
15
15
|
const { fieldNodes } = info;
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
const newCtx = {
|
|
18
|
+
...ctx,
|
|
19
|
+
data: {
|
|
20
|
+
...ctx.data,
|
|
21
|
+
args,
|
|
22
|
+
fieldPath: fieldName,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
24
25
|
|
|
25
|
-
childLogger.
|
|
26
|
-
|
|
26
|
+
const childLogger = logger.child(newCtx.data);
|
|
27
|
+
|
|
28
|
+
childLogger.info(`Resolving ${fieldName}`);
|
|
29
|
+
const { data, errors, headers, source = 'api' } = await callback(args, newCtx, info);
|
|
27
30
|
|
|
28
31
|
if (errors?.length) {
|
|
29
|
-
const message = `Failed to resolve ${
|
|
32
|
+
const message = `Failed to resolve ${fieldName}`;
|
|
30
33
|
childLogger.error(message, { errors });
|
|
31
34
|
throw new GraphQLError(message, { nodes: fieldNodes, originalError: errors[0] });
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
childLogger.info(`Successfully resolved ${
|
|
35
|
-
setCacheMetadata(
|
|
37
|
+
childLogger.info(`Successfully resolved ${fieldName} from ${source}`);
|
|
38
|
+
setCacheMetadata(fieldName, headers);
|
|
36
39
|
return data;
|
|
37
40
|
};
|
|
@@ -10,19 +10,21 @@ export const buildNoObjArgsResolver =
|
|
|
10
10
|
) => Promise<{ data?: Data; errors?: Error[]; headers: Headers; source?: string }>
|
|
11
11
|
) =>
|
|
12
12
|
async (obj: Obj | undefined, _args: undefined, ctx: Context, info: GraphQLResolveInfo) => {
|
|
13
|
-
const { logger,
|
|
13
|
+
const { logger, setCacheMetadata } = ctx;
|
|
14
14
|
const { fieldName, fieldNodes } = info;
|
|
15
15
|
const fieldPath = obj ? `${parentFieldName}.${fieldName}` : parentFieldName;
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
const newCtx = {
|
|
18
|
+
...ctx,
|
|
19
|
+
data: {
|
|
20
|
+
...ctx.data,
|
|
21
|
+
fieldPath,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
23
24
|
|
|
25
|
+
const childLogger = logger.child(newCtx.data);
|
|
24
26
|
childLogger.info(`Resolving ${fieldPath}`);
|
|
25
|
-
const { data, errors, headers } = await callback(
|
|
27
|
+
const { data, errors, headers } = await callback(newCtx, info);
|
|
26
28
|
|
|
27
29
|
if (errors?.length) {
|
|
28
30
|
const message = `Failed to resolve ${fieldPath}`;
|
|
@@ -12,20 +12,22 @@ export const buildObjArgsResolver =
|
|
|
12
12
|
) => Promise<{ data?: Data; errors?: Error[]; headers?: Headers; source?: string }>
|
|
13
13
|
) =>
|
|
14
14
|
async (obj: Obj | undefined, args: Args, ctx: Context, info: GraphQLResolveInfo) => {
|
|
15
|
-
const { logger,
|
|
15
|
+
const { logger, setCacheMetadata } = ctx;
|
|
16
16
|
const { fieldName, fieldNodes } = info;
|
|
17
17
|
const fieldPath = obj ? `${parentFieldName}.${fieldName}` : parentFieldName;
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
const newCtx = {
|
|
20
|
+
...ctx,
|
|
21
|
+
data: {
|
|
22
|
+
...ctx.data,
|
|
23
|
+
args,
|
|
24
|
+
fieldPath,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
26
27
|
|
|
28
|
+
const childLogger = logger.child(newCtx.data);
|
|
27
29
|
childLogger.info(`Resolving ${fieldPath}`);
|
|
28
|
-
const { data, errors, headers, source = 'api' } = await callback(obj, args,
|
|
30
|
+
const { data, errors, headers, source = 'api' } = await callback(obj, args, newCtx, info);
|
|
29
31
|
|
|
30
32
|
if (errors?.length) {
|
|
31
33
|
const message = `Failed to resolve ${fieldPath}`;
|
|
@@ -11,17 +11,20 @@ export const buildObjResolver =
|
|
|
11
11
|
) => Promise<{ data?: Data; errors?: Error[]; headers?: Headers; source?: string }>
|
|
12
12
|
) =>
|
|
13
13
|
async (obj: Obj | undefined, _args: undefined, ctx: Context, info: GraphQLResolveInfo) => {
|
|
14
|
-
const { logger,
|
|
14
|
+
const { logger, setCacheMetadata } = ctx;
|
|
15
15
|
const { fieldName, fieldNodes } = info;
|
|
16
16
|
const fieldPath = `${parentFieldName}.${fieldName}`;
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
const newCtx = {
|
|
19
|
+
...ctx,
|
|
20
|
+
data: {
|
|
21
|
+
...ctx.data,
|
|
22
|
+
fieldPath,
|
|
23
|
+
parentFieldId: obj?.id,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const childLogger = logger.child(newCtx.data);
|
|
25
28
|
|
|
26
29
|
if (!obj) {
|
|
27
30
|
const message = `Required ${parentFieldName} node missing`;
|
|
@@ -30,7 +33,7 @@ export const buildObjResolver =
|
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
childLogger.info(`Resolving ${fieldPath}`);
|
|
33
|
-
const { data, errors, headers, source = 'api' } = await callback(obj,
|
|
36
|
+
const { data, errors, headers, source = 'api' } = await callback(obj, newCtx, info);
|
|
34
37
|
|
|
35
38
|
if (errors?.length) {
|
|
36
39
|
const message = `Failed to resolve ${fieldPath}`;
|
|
@@ -15,10 +15,13 @@ const mockedFetch = mockFetch(jest.fn);
|
|
|
15
15
|
|
|
16
16
|
describe('resolveCertifications >', () => {
|
|
17
17
|
const context = {
|
|
18
|
+
data: {
|
|
19
|
+
requestID: 'mockRequestID',
|
|
20
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
21
|
+
},
|
|
18
22
|
logger: createMockLogger(jest.fn),
|
|
19
23
|
restClient: createRestClient(),
|
|
20
24
|
setCacheMetadata: jest.fn(),
|
|
21
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
22
25
|
} as unknown as Context;
|
|
23
26
|
|
|
24
27
|
const info = {} as GraphQLResolveInfo;
|
|
@@ -7,13 +7,13 @@ export const resolveCertifications = buildArgsResolver<QueryCertificationsArgs,
|
|
|
7
7
|
CERTIFICATIONS,
|
|
8
8
|
async (args, ctx) => {
|
|
9
9
|
const { screenType } = args;
|
|
10
|
-
const {
|
|
10
|
+
const { data: ctxData, restClient } = ctx;
|
|
11
11
|
|
|
12
12
|
const { data, errors } = await restClient.certifications<RawCertifications>(
|
|
13
13
|
{
|
|
14
14
|
pathTemplateData: { type: screenType.toLowerCase() },
|
|
15
15
|
},
|
|
16
|
-
|
|
16
|
+
ctxData
|
|
17
17
|
);
|
|
18
18
|
|
|
19
19
|
return {
|
|
@@ -15,10 +15,13 @@ describe('resolveCollection >', () => {
|
|
|
15
15
|
const id = 10;
|
|
16
16
|
|
|
17
17
|
const context = {
|
|
18
|
+
data: {
|
|
19
|
+
requestID: 'mockRequestID',
|
|
20
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
21
|
+
},
|
|
18
22
|
logger: createMockLogger(jest.fn),
|
|
19
23
|
restClient: createRestClient(),
|
|
20
24
|
setCacheMetadata: jest.fn(),
|
|
21
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
22
25
|
} as unknown as Context;
|
|
23
26
|
|
|
24
27
|
const info = {} as GraphQLResolveInfo;
|
|
@@ -10,7 +10,7 @@ export const resolveCollection = buildObjArgsResolver<
|
|
|
10
10
|
RawCollection | RawCollection[keyof RawCollection]
|
|
11
11
|
>(COLLECTION, async (obj, args, ctx, info) => {
|
|
12
12
|
const id = obj?.id ?? args.id;
|
|
13
|
-
const {
|
|
13
|
+
const { data: ctxData, restClient } = ctx;
|
|
14
14
|
const { fieldName } = info;
|
|
15
15
|
const typedFieldName = snakeCase(fieldName) as keyof RawCollection;
|
|
16
16
|
|
|
@@ -25,7 +25,7 @@ export const resolveCollection = buildObjArgsResolver<
|
|
|
25
25
|
{
|
|
26
26
|
pathTemplateData: { id },
|
|
27
27
|
},
|
|
28
|
-
|
|
28
|
+
ctxData
|
|
29
29
|
);
|
|
30
30
|
|
|
31
31
|
return {
|
|
@@ -15,10 +15,13 @@ const mockedFetch = mockFetch(jest.fn);
|
|
|
15
15
|
|
|
16
16
|
describe('resolveCollectionImages >', () => {
|
|
17
17
|
const context = {
|
|
18
|
+
data: {
|
|
19
|
+
requestID: 'mockRequestID',
|
|
20
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
21
|
+
},
|
|
18
22
|
logger: createMockLogger(jest.fn),
|
|
19
23
|
restClient: createRestClient(),
|
|
20
24
|
setCacheMetadata: jest.fn(),
|
|
21
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
22
25
|
} as unknown as Context;
|
|
23
26
|
|
|
24
27
|
beforeEach(() => {
|
|
@@ -6,14 +6,14 @@ export const resolveCollectionImages = buildObjResolver<
|
|
|
6
6
|
RawCollection,
|
|
7
7
|
RawCollectionImages['backdrops'] | RawCollectionImages['posters']
|
|
8
8
|
>(COLLECTION, async (obj, ctx, info) => {
|
|
9
|
-
const {
|
|
9
|
+
const { data: ctxData, restClient } = ctx;
|
|
10
10
|
const { fieldName } = info;
|
|
11
11
|
|
|
12
12
|
const { data, errors, headers } = await restClient.collection<RawCollectionImages>(
|
|
13
13
|
{
|
|
14
14
|
pathTemplateData: { id: obj.id, type: IMAGES },
|
|
15
15
|
},
|
|
16
|
-
|
|
16
|
+
ctxData
|
|
17
17
|
);
|
|
18
18
|
|
|
19
19
|
const typedFieldName = fieldName as 'backdrops' | 'posters';
|
|
@@ -15,10 +15,13 @@ const mockedFetch = mockFetch(jest.fn);
|
|
|
15
15
|
|
|
16
16
|
describe('resolveCollectionTranslations >', () => {
|
|
17
17
|
const context = {
|
|
18
|
+
data: {
|
|
19
|
+
requestID: 'mockRequestID',
|
|
20
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
21
|
+
},
|
|
18
22
|
logger: createMockLogger(jest.fn),
|
|
19
23
|
restClient: createRestClient(),
|
|
20
24
|
setCacheMetadata: jest.fn(),
|
|
21
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
22
25
|
} as unknown as Context;
|
|
23
26
|
|
|
24
27
|
const resolveInfo = buildResolveInfoArgument(
|
|
@@ -5,13 +5,13 @@ import { type RawCollection, type RawCollectionTranslations } from '../types.ts'
|
|
|
5
5
|
export const resolveCollectionTranslations = buildObjResolver<RawCollection, RawCollectionTranslations['translations']>(
|
|
6
6
|
COLLECTION,
|
|
7
7
|
async (obj, ctx) => {
|
|
8
|
-
const {
|
|
8
|
+
const { data: ctxData, restClient } = ctx;
|
|
9
9
|
|
|
10
10
|
const { data, errors, headers } = await restClient.collection<RawCollectionTranslations>(
|
|
11
11
|
{
|
|
12
12
|
pathTemplateData: { id: obj.id, type: TRANSLATIONS },
|
|
13
13
|
},
|
|
14
|
-
|
|
14
|
+
ctxData
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
return {
|
|
@@ -15,10 +15,13 @@ describe('resolveCompany >', () => {
|
|
|
15
15
|
const id = 2;
|
|
16
16
|
|
|
17
17
|
const context = {
|
|
18
|
+
data: {
|
|
19
|
+
requestID: 'mockRequestID',
|
|
20
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
21
|
+
},
|
|
18
22
|
logger: createMockLogger(jest.fn),
|
|
19
23
|
restClient: createRestClient(),
|
|
20
24
|
setCacheMetadata: jest.fn(),
|
|
21
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
22
25
|
} as unknown as Context;
|
|
23
26
|
|
|
24
27
|
const info = {} as GraphQLResolveInfo;
|
package/src/queries/company.ts
CHANGED
|
@@ -10,7 +10,7 @@ export const resolveCompany = buildObjArgsResolver<
|
|
|
10
10
|
RawCompany | RawCompany[keyof RawCompany]
|
|
11
11
|
>(COMPANY, async (obj, args, ctx, info) => {
|
|
12
12
|
const id = obj?.id ?? args.id;
|
|
13
|
-
const {
|
|
13
|
+
const { data: ctxData, restClient } = ctx;
|
|
14
14
|
const { fieldName } = info;
|
|
15
15
|
const typedFieldName = snakeCase(fieldName) as keyof RawCompany;
|
|
16
16
|
|
|
@@ -25,7 +25,7 @@ export const resolveCompany = buildObjArgsResolver<
|
|
|
25
25
|
{
|
|
26
26
|
pathTemplateData: { id },
|
|
27
27
|
},
|
|
28
|
-
|
|
28
|
+
ctxData
|
|
29
29
|
);
|
|
30
30
|
|
|
31
31
|
return {
|
|
@@ -16,10 +16,13 @@ const mockedFetch = mockFetch(jest.fn);
|
|
|
16
16
|
|
|
17
17
|
describe('resolveCompanyAlternativeNames >', () => {
|
|
18
18
|
const context = {
|
|
19
|
+
data: {
|
|
20
|
+
requestID: 'mockRequestID',
|
|
21
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
22
|
+
},
|
|
19
23
|
logger: createMockLogger(jest.fn),
|
|
20
24
|
restClient: createRestClient(),
|
|
21
25
|
setCacheMetadata: jest.fn(),
|
|
22
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
23
26
|
} as unknown as Context;
|
|
24
27
|
|
|
25
28
|
const apiFieldName = snakeCase(ALTERNATIVE_NAMES);
|
|
@@ -6,13 +6,13 @@ import { type RawCollection, type RawCompanyAlternativeNames } from '../types.ts
|
|
|
6
6
|
export const resolveCompanyAlternativeNames = buildObjResolver<RawCollection, RawCompanyAlternativeNames['results']>(
|
|
7
7
|
COMPANY,
|
|
8
8
|
async (obj, ctx) => {
|
|
9
|
-
const {
|
|
9
|
+
const { data: ctxData, restClient } = ctx;
|
|
10
10
|
|
|
11
11
|
const { data, errors, headers } = await restClient.company<RawCompanyAlternativeNames>(
|
|
12
12
|
{
|
|
13
13
|
pathTemplateData: { id: obj.id, type: snakeCase(ALTERNATIVE_NAMES) },
|
|
14
14
|
},
|
|
15
|
-
|
|
15
|
+
ctxData
|
|
16
16
|
);
|
|
17
17
|
|
|
18
18
|
return {
|
|
@@ -15,10 +15,13 @@ const mockedFetch = mockFetch(jest.fn);
|
|
|
15
15
|
|
|
16
16
|
describe('resolveCompanyImages >', () => {
|
|
17
17
|
const context = {
|
|
18
|
+
data: {
|
|
19
|
+
requestID: 'mockRequestID',
|
|
20
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
21
|
+
},
|
|
18
22
|
logger: createMockLogger(jest.fn),
|
|
19
23
|
restClient: createRestClient(),
|
|
20
24
|
setCacheMetadata: jest.fn(),
|
|
21
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
22
25
|
} as unknown as Context;
|
|
23
26
|
|
|
24
27
|
const resolveInfo = buildResolveInfoArgument(
|
|
@@ -3,13 +3,13 @@ import { buildObjResolver } from '../helpers/buildObjResolver.ts';
|
|
|
3
3
|
import type { RawCompany, RawCompanyLogos } from '../types.ts';
|
|
4
4
|
|
|
5
5
|
export const resolveCompanyLogos = buildObjResolver<RawCompany, RawCompanyLogos['logos']>(COMPANY, async (obj, ctx) => {
|
|
6
|
-
const {
|
|
6
|
+
const { data: ctxData, restClient } = ctx;
|
|
7
7
|
|
|
8
8
|
const { data, errors, headers } = await restClient.company<RawCompanyLogos>(
|
|
9
9
|
{
|
|
10
10
|
pathTemplateData: { id: obj.id, type: IMAGES },
|
|
11
11
|
},
|
|
12
|
-
|
|
12
|
+
ctxData
|
|
13
13
|
);
|
|
14
14
|
|
|
15
15
|
return {
|
|
@@ -13,10 +13,13 @@ const mockedFetch = mockFetch(jest.fn);
|
|
|
13
13
|
|
|
14
14
|
describe('resolveConfiguration >', () => {
|
|
15
15
|
const context = {
|
|
16
|
+
data: {
|
|
17
|
+
requestID: 'mockRequestID',
|
|
18
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
19
|
+
},
|
|
16
20
|
logger: createMockLogger(jest.fn),
|
|
17
21
|
restClient: createRestClient(),
|
|
18
22
|
setCacheMetadata: jest.fn(),
|
|
19
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
20
23
|
} as unknown as Context;
|
|
21
24
|
|
|
22
25
|
const info = {} as GraphQLResolveInfo;
|
|
@@ -3,12 +3,8 @@ import { buildNoObjArgsResolver } from '../helpers/buildNoObjArgsResolver.ts';
|
|
|
3
3
|
import { type RawConfiguration } from '../types.ts';
|
|
4
4
|
|
|
5
5
|
export const resolveConfiguration = buildNoObjArgsResolver<undefined, RawConfiguration>(CONFIGURATION, async ctx => {
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
const { data, errors, headers } = await restClient.configuration<RawConfiguration>(undefined, {
|
|
9
|
-
requestID,
|
|
10
|
-
tmdbGuestSessionId,
|
|
11
|
-
});
|
|
6
|
+
const { data: ctxData, restClient } = ctx;
|
|
7
|
+
const { data, errors, headers } = await restClient.configuration<RawConfiguration>(undefined, ctxData);
|
|
12
8
|
|
|
13
9
|
return {
|
|
14
10
|
data,
|
|
@@ -15,10 +15,13 @@ const mockedFetch = mockFetch(jest.fn);
|
|
|
15
15
|
|
|
16
16
|
describe('resolveConfigurationCountries >', () => {
|
|
17
17
|
const context = {
|
|
18
|
+
data: {
|
|
19
|
+
requestID: 'mockRequestID',
|
|
20
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
21
|
+
},
|
|
18
22
|
logger: createMockLogger(jest.fn),
|
|
19
23
|
restClient: createRestClient(),
|
|
20
24
|
setCacheMetadata: jest.fn(),
|
|
21
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
22
25
|
} as unknown as Context;
|
|
23
26
|
|
|
24
27
|
const resolveInfo = buildResolveInfoArgument(
|
|
@@ -5,13 +5,13 @@ import { type RawConfiguration, type RawConfigurationCountries } from '../types.
|
|
|
5
5
|
export const resolveConfigurationCountries = buildNoObjArgsResolver<RawConfiguration, RawConfigurationCountries>(
|
|
6
6
|
CONFIGURATION,
|
|
7
7
|
async ctx => {
|
|
8
|
-
const {
|
|
8
|
+
const { data: ctxData, restClient } = ctx;
|
|
9
9
|
|
|
10
10
|
const { data, errors, headers } = await restClient.configuration<RawConfigurationCountries>(
|
|
11
11
|
{
|
|
12
12
|
pathTemplateData: { type: COUNTRIES },
|
|
13
13
|
},
|
|
14
|
-
|
|
14
|
+
ctxData
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
return {
|
|
@@ -15,10 +15,13 @@ const mockedFetch = mockFetch(jest.fn);
|
|
|
15
15
|
|
|
16
16
|
describe('resolveConfigurationJobs >', () => {
|
|
17
17
|
const context = {
|
|
18
|
+
data: {
|
|
19
|
+
requestID: 'mockRequestID',
|
|
20
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
21
|
+
},
|
|
18
22
|
logger: createMockLogger(jest.fn),
|
|
19
23
|
restClient: createRestClient(),
|
|
20
24
|
setCacheMetadata: jest.fn(),
|
|
21
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
22
25
|
} as unknown as Context;
|
|
23
26
|
|
|
24
27
|
const resolveInfo = buildResolveInfoArgument(
|
|
@@ -5,13 +5,13 @@ import { type RawConfiguration, type RawConfigurationJobs } from '../types.ts';
|
|
|
5
5
|
export const resolveConfigurationJobs = buildNoObjArgsResolver<RawConfiguration, RawConfigurationJobs>(
|
|
6
6
|
CONFIGURATION,
|
|
7
7
|
async ctx => {
|
|
8
|
-
const {
|
|
8
|
+
const { data: ctxData, restClient } = ctx;
|
|
9
9
|
|
|
10
10
|
const { data, errors, headers } = await restClient.configuration<RawConfigurationJobs>(
|
|
11
11
|
{
|
|
12
12
|
pathTemplateData: { type: JOBS },
|
|
13
13
|
},
|
|
14
|
-
|
|
14
|
+
ctxData
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
return {
|
|
@@ -15,10 +15,13 @@ const mockedFetch = mockFetch(jest.fn);
|
|
|
15
15
|
|
|
16
16
|
describe('resolveConfigurationLanguages >', () => {
|
|
17
17
|
const context = {
|
|
18
|
+
data: {
|
|
19
|
+
requestID: 'mockRequestID',
|
|
20
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
21
|
+
},
|
|
18
22
|
logger: createMockLogger(jest.fn),
|
|
19
23
|
restClient: createRestClient(),
|
|
20
24
|
setCacheMetadata: jest.fn(),
|
|
21
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
22
25
|
} as unknown as Context;
|
|
23
26
|
|
|
24
27
|
const resolveInfo = buildResolveInfoArgument(
|
|
@@ -5,13 +5,13 @@ import { type RawConfiguration, type RawConfigurationLanguages } from '../types.
|
|
|
5
5
|
export const resolveConfigurationLanguages = buildNoObjArgsResolver<RawConfiguration, RawConfigurationLanguages>(
|
|
6
6
|
CONFIGURATION,
|
|
7
7
|
async ctx => {
|
|
8
|
-
const {
|
|
8
|
+
const { data: ctxData, restClient } = ctx;
|
|
9
9
|
|
|
10
10
|
const { data, errors, headers } = await restClient.configuration<RawConfigurationLanguages>(
|
|
11
11
|
{
|
|
12
12
|
pathTemplateData: { type: LANGUAGES },
|
|
13
13
|
},
|
|
14
|
-
|
|
14
|
+
ctxData
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
return {
|
|
@@ -16,10 +16,13 @@ const mockedFetch = mockFetch(jest.fn);
|
|
|
16
16
|
|
|
17
17
|
describe('resolveConfigurationPrimaryTranslations >', () => {
|
|
18
18
|
const context = {
|
|
19
|
+
data: {
|
|
20
|
+
requestID: 'mockRequestID',
|
|
21
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
22
|
+
},
|
|
19
23
|
logger: createMockLogger(jest.fn),
|
|
20
24
|
restClient: createRestClient(),
|
|
21
25
|
setCacheMetadata: jest.fn(),
|
|
22
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
23
26
|
} as unknown as Context;
|
|
24
27
|
|
|
25
28
|
const resolveInfo = buildResolveInfoArgument(
|
|
@@ -7,13 +7,13 @@ export const resolveConfigurationPrimaryTranslations = buildNoObjArgsResolver<
|
|
|
7
7
|
RawConfiguration,
|
|
8
8
|
RawConfigurationPrimaryTranslations
|
|
9
9
|
>(CONFIGURATION, async ctx => {
|
|
10
|
-
const {
|
|
10
|
+
const { data: ctxData, restClient } = ctx;
|
|
11
11
|
|
|
12
12
|
const { data, errors, headers } = await restClient.configuration<RawConfigurationPrimaryTranslations>(
|
|
13
13
|
{
|
|
14
14
|
pathTemplateData: { type: snakeCase(PRIMARY_TRANSLATIONS) },
|
|
15
15
|
},
|
|
16
|
-
|
|
16
|
+
ctxData
|
|
17
17
|
);
|
|
18
18
|
|
|
19
19
|
return {
|
|
@@ -15,10 +15,13 @@ const mockedFetch = mockFetch(jest.fn);
|
|
|
15
15
|
|
|
16
16
|
describe('resolveConfigurationTimezones >', () => {
|
|
17
17
|
const context = {
|
|
18
|
+
data: {
|
|
19
|
+
requestID: 'mockRequestID',
|
|
20
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
21
|
+
},
|
|
18
22
|
logger: createMockLogger(jest.fn),
|
|
19
23
|
restClient: createRestClient(),
|
|
20
24
|
setCacheMetadata: jest.fn(),
|
|
21
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
22
25
|
} as unknown as Context;
|
|
23
26
|
|
|
24
27
|
const resolveInfo = buildResolveInfoArgument(
|
|
@@ -5,13 +5,13 @@ import { type RawConfiguration, type RawConfigurationTimezones } from '../types.
|
|
|
5
5
|
export const resolveConfigurationTimezones = buildNoObjArgsResolver<RawConfiguration, RawConfigurationTimezones>(
|
|
6
6
|
CONFIGURATION,
|
|
7
7
|
async ctx => {
|
|
8
|
-
const {
|
|
8
|
+
const { data: ctxData, restClient } = ctx;
|
|
9
9
|
|
|
10
10
|
const { data, errors, headers } = await restClient.configuration<RawConfigurationTimezones>(
|
|
11
11
|
{
|
|
12
12
|
pathTemplateData: { type: TIMEZONES },
|
|
13
13
|
},
|
|
14
|
-
|
|
14
|
+
ctxData
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
return {
|
|
@@ -15,10 +15,13 @@ describe('resolveCredit >', () => {
|
|
|
15
15
|
const id = 2;
|
|
16
16
|
|
|
17
17
|
const context = {
|
|
18
|
+
data: {
|
|
19
|
+
requestID: 'mockRequestID',
|
|
20
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
21
|
+
},
|
|
18
22
|
logger: createMockLogger(jest.fn),
|
|
19
23
|
restClient: createRestClient(),
|
|
20
24
|
setCacheMetadata: jest.fn(),
|
|
21
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
22
25
|
} as unknown as Context;
|
|
23
26
|
|
|
24
27
|
const info = {} as GraphQLResolveInfo;
|