@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
|
@@ -22,10 +22,13 @@ const baseArgs = {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const context = {
|
|
25
|
+
data: {
|
|
26
|
+
requestID: 'mockRequestID',
|
|
27
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
28
|
+
},
|
|
25
29
|
logger: createMockLogger(jest.fn),
|
|
26
30
|
restClient: createRestClient(),
|
|
27
31
|
setCacheMetadata: jest.fn(),
|
|
28
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
29
32
|
} as unknown as Context;
|
|
30
33
|
|
|
31
34
|
const info = {} as GraphQLResolveInfo;
|
|
@@ -67,12 +70,12 @@ describe('createResourceResolver', () => {
|
|
|
67
70
|
|
|
68
71
|
expect(restClient.rated).toHaveBeenCalledWith(
|
|
69
72
|
{
|
|
70
|
-
pathTemplateData: { id: context.tmdbGuestSessionId, type: MOVIE },
|
|
73
|
+
pathTemplateData: { id: context.data.tmdbGuestSessionId, type: MOVIE },
|
|
71
74
|
queryParams: {
|
|
72
75
|
page: 1,
|
|
73
76
|
},
|
|
74
77
|
},
|
|
75
|
-
{ requestID:
|
|
78
|
+
{ requestID: 'mockRequestID', tmdbGuestSessionId: 'mockTmdbGuestSessionId' }
|
|
76
79
|
);
|
|
77
80
|
});
|
|
78
81
|
});
|
|
@@ -80,7 +83,7 @@ describe('createResourceResolver', () => {
|
|
|
80
83
|
describe('resolveRated', () => {
|
|
81
84
|
const mockEndpoint = ({ screenType }: { screenType: ScreenType }, page: number, body: Jsonifiable) => {
|
|
82
85
|
mockedFetch.mockGetOnce(
|
|
83
|
-
buildEndpoint(RATED_PATH, { id: context.tmdbGuestSessionId, type: screenType.toLowerCase() }, { page }),
|
|
86
|
+
buildEndpoint(RATED_PATH, { id: context.data.tmdbGuestSessionId, type: screenType.toLowerCase() }, { page }),
|
|
84
87
|
{
|
|
85
88
|
body,
|
|
86
89
|
headers: { 'cache-control': 'public, max-age=6000' },
|
package/src/queries/rated.ts
CHANGED
|
@@ -25,14 +25,14 @@ export const createMakeCursors = (_obj: undefined, args: QueryRatedArgs) => {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export const createResourceResolver: CreateResourceResolver<undefined, QueryRatedArgs, Context, RawRated> =
|
|
28
|
-
(_obj, { screenType }: QueryRatedArgs, {
|
|
28
|
+
(_obj, { screenType }: QueryRatedArgs, { data: ctxData, restClient }: Context) =>
|
|
29
29
|
async ({ page }: { page: number }) => {
|
|
30
30
|
const { data, errors, headers } = await restClient.rated<RawRated>(
|
|
31
31
|
{
|
|
32
|
-
pathTemplateData: { id: tmdbGuestSessionId, type: screenType.toLowerCase() },
|
|
32
|
+
pathTemplateData: { id: ctxData.tmdbGuestSessionId, type: screenType.toLowerCase() },
|
|
33
33
|
queryParams: { page },
|
|
34
34
|
},
|
|
35
|
-
|
|
35
|
+
ctxData
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
if (!data) {
|
|
@@ -15,10 +15,13 @@ describe('resolveReview >', () => {
|
|
|
15
15
|
const id = '58a4ee0ac3a3684ef80000e3';
|
|
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/review.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const resolveReview = buildObjArgsResolver<RawReview, QueryReviewArgs, Ra
|
|
|
8
8
|
REVIEW,
|
|
9
9
|
async (obj, args, ctx, info) => {
|
|
10
10
|
const id = obj ? obj.id : args.id;
|
|
11
|
-
const {
|
|
11
|
+
const { data: ctxData, restClient } = ctx;
|
|
12
12
|
const { fieldName } = info;
|
|
13
13
|
const typedFieldName = snakeCase(fieldName) as keyof RawReview;
|
|
14
14
|
|
|
@@ -23,7 +23,7 @@ export const resolveReview = buildObjArgsResolver<RawReview, QueryReviewArgs, Ra
|
|
|
23
23
|
{
|
|
24
24
|
pathTemplateData: { id },
|
|
25
25
|
},
|
|
26
|
-
|
|
26
|
+
ctxData
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
return {
|
|
@@ -24,10 +24,13 @@ import { createMakeCursors, createResourceResolver, cursorCache, resolveSearch }
|
|
|
24
24
|
const mockedFetch = mockFetch(jest.fn);
|
|
25
25
|
|
|
26
26
|
const context = {
|
|
27
|
+
data: {
|
|
28
|
+
requestID: 'mockRequestID',
|
|
29
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
30
|
+
},
|
|
27
31
|
logger: createMockLogger(jest.fn),
|
|
28
32
|
restClient: createRestClient(),
|
|
29
33
|
setCacheMetadata: jest.fn(),
|
|
30
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
31
34
|
} as unknown as Context;
|
|
32
35
|
|
|
33
36
|
const info = {} as GraphQLResolveInfo;
|
|
@@ -101,7 +104,7 @@ describe('createResourceResolver', () => {
|
|
|
101
104
|
year: 2005,
|
|
102
105
|
},
|
|
103
106
|
},
|
|
104
|
-
{ requestID:
|
|
107
|
+
{ requestID: 'mockRequestID', tmdbGuestSessionId: 'mockTmdbGuestSessionId' }
|
|
105
108
|
);
|
|
106
109
|
});
|
|
107
110
|
});
|
package/src/queries/search.ts
CHANGED
|
@@ -28,7 +28,7 @@ export const createMakeCursors = (_obj: undefined, args: QuerySearchArgs) => {
|
|
|
28
28
|
export const createResourceResolver: CreateResourceResolver<undefined, QuerySearchArgs, Context, RawSearch> = (
|
|
29
29
|
_obj,
|
|
30
30
|
args,
|
|
31
|
-
{
|
|
31
|
+
{ data: ctxData, restClient }
|
|
32
32
|
) => {
|
|
33
33
|
const { searchType, ...rest } = removeConnectionInputOptions(args);
|
|
34
34
|
|
|
@@ -38,7 +38,7 @@ export const createResourceResolver: CreateResourceResolver<undefined, QuerySear
|
|
|
38
38
|
pathTemplateData: { type: (searchType ?? SearchType.Multi).toLowerCase() },
|
|
39
39
|
queryParams: { ...snakeCasePropNames(rest), page },
|
|
40
40
|
},
|
|
41
|
-
|
|
41
|
+
ctxData
|
|
42
42
|
);
|
|
43
43
|
|
|
44
44
|
if (!data) {
|
|
@@ -22,10 +22,13 @@ describe('resolveSeason >', () => {
|
|
|
22
22
|
const id = 1399;
|
|
23
23
|
|
|
24
24
|
const context = {
|
|
25
|
+
data: {
|
|
26
|
+
requestID: 'mockRequestID',
|
|
27
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
28
|
+
},
|
|
25
29
|
logger: createMockLogger(jest.fn),
|
|
26
30
|
restClient: createRestClient(),
|
|
27
31
|
setCacheMetadata: jest.fn(),
|
|
28
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
29
32
|
} as unknown as Context;
|
|
30
33
|
|
|
31
34
|
beforeEach(() => {
|
package/src/queries/season.ts
CHANGED
|
@@ -22,7 +22,7 @@ export const resolveSeason = buildObjArgsResolver<
|
|
|
22
22
|
| (EnrichedRawSeasonWithAppendToResponse & { __headers?: Headers })
|
|
23
23
|
| EnrichedRawSeasonWithAppendToResponse[keyof EnrichedRawSeasonWithAppendToResponse]
|
|
24
24
|
>(SEASON, async (obj, args, ctx, info) => {
|
|
25
|
-
const {
|
|
25
|
+
const { data: ctxData, fragmentDefinitions, restClient } = ctx;
|
|
26
26
|
const { fieldName, fieldNodes } = info;
|
|
27
27
|
const typedFieldName = snakeCase(fieldName) as keyof RawSeason;
|
|
28
28
|
const { id, seasonNumber } = getTvIdSeasonAndEpisode(obj, args);
|
|
@@ -47,7 +47,7 @@ export const resolveSeason = buildObjArgsResolver<
|
|
|
47
47
|
}
|
|
48
48
|
: {}),
|
|
49
49
|
},
|
|
50
|
-
|
|
50
|
+
ctxData
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
const seasonData = {
|
|
@@ -18,10 +18,13 @@ describe('resolveSeasonCredits >', () => {
|
|
|
18
18
|
const seasonId = 1399;
|
|
19
19
|
|
|
20
20
|
const context = {
|
|
21
|
+
data: {
|
|
22
|
+
requestID: 'mockRequestID',
|
|
23
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
24
|
+
},
|
|
21
25
|
logger: createMockLogger(jest.fn),
|
|
22
26
|
restClient: createRestClient(),
|
|
23
27
|
setCacheMetadata: jest.fn(),
|
|
24
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
25
28
|
} as unknown as Context;
|
|
26
29
|
|
|
27
30
|
beforeEach(() => {
|
|
@@ -11,7 +11,7 @@ export const resolveSeasonCredits = buildObjResolver<
|
|
|
11
11
|
EnrichedRawSeason | (EnrichedRawSeasonWithAppendToResponse & { __headers?: Headers }),
|
|
12
12
|
RawSeasonCredits['cast'] | RawSeasonCredits['crew']
|
|
13
13
|
>(SEASON, async (obj, ctx, info) => {
|
|
14
|
-
const {
|
|
14
|
+
const { data: ctxData, restClient } = ctx;
|
|
15
15
|
const { fieldName } = info;
|
|
16
16
|
const typedFieldName = snakeCase(fieldName) as 'cast' | 'crew';
|
|
17
17
|
|
|
@@ -27,7 +27,7 @@ export const resolveSeasonCredits = buildObjResolver<
|
|
|
27
27
|
{
|
|
28
28
|
pathTemplateData: { id: obj.tv_show_id, number: obj.season_number, type: CREDITS },
|
|
29
29
|
},
|
|
30
|
-
|
|
30
|
+
ctxData
|
|
31
31
|
);
|
|
32
32
|
|
|
33
33
|
return {
|
|
@@ -20,10 +20,13 @@ describe('resolveSeasonExternalIds >', () => {
|
|
|
20
20
|
const seasonId = 1399;
|
|
21
21
|
|
|
22
22
|
const context = {
|
|
23
|
+
data: {
|
|
24
|
+
requestID: 'mockRequestID',
|
|
25
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
26
|
+
},
|
|
23
27
|
logger: createMockLogger(jest.fn),
|
|
24
28
|
restClient: createRestClient(),
|
|
25
29
|
setCacheMetadata: jest.fn(),
|
|
26
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
27
30
|
} as unknown as Context;
|
|
28
31
|
|
|
29
32
|
const info = {} as GraphQLResolveInfo;
|
|
@@ -17,7 +17,7 @@ export const resolveSeasonExternalIds = buildObjResolver<
|
|
|
17
17
|
EnrichedRawSeason | (EnrichedRawSeasonWithAppendToResponse & { __headers?: Headers }),
|
|
18
18
|
Except<RawSeasonExternalIds, 'id'>
|
|
19
19
|
>(SEASON, async (obj, ctx) => {
|
|
20
|
-
const {
|
|
20
|
+
const { data: ctxData, restClient } = ctx;
|
|
21
21
|
|
|
22
22
|
if (isEnrichedRawSeasonWithExternalIds(obj)) {
|
|
23
23
|
return {
|
|
@@ -31,7 +31,7 @@ export const resolveSeasonExternalIds = buildObjResolver<
|
|
|
31
31
|
{
|
|
32
32
|
pathTemplateData: { id: obj.tv_show_id, number: obj.season_number, type: snakeCase(EXTERNAL_IDS) },
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
ctxData
|
|
35
35
|
);
|
|
36
36
|
|
|
37
37
|
const { id: movieId, ...rest } = data ?? {};
|
|
@@ -17,10 +17,13 @@ const mockedFetch = mockFetch(jest.fn);
|
|
|
17
17
|
|
|
18
18
|
describe('resolveSeasonPosters >', () => {
|
|
19
19
|
const context = {
|
|
20
|
+
data: {
|
|
21
|
+
requestID: 'mockRequestID',
|
|
22
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
23
|
+
},
|
|
20
24
|
logger: createMockLogger(jest.fn),
|
|
21
25
|
restClient: createRestClient(),
|
|
22
26
|
setCacheMetadata: jest.fn(),
|
|
23
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
24
27
|
} as unknown as Context;
|
|
25
28
|
|
|
26
29
|
const info = {} as GraphQLResolveInfo;
|
|
@@ -10,7 +10,7 @@ export const resolveSeasonPosters = buildObjResolver<
|
|
|
10
10
|
EnrichedRawSeason | (EnrichedRawSeasonWithAppendToResponse & { __headers?: Headers }),
|
|
11
11
|
RawSeasonPosters['posters']
|
|
12
12
|
>(SEASON, async (obj, ctx) => {
|
|
13
|
-
const {
|
|
13
|
+
const { data: ctxData, restClient } = ctx;
|
|
14
14
|
|
|
15
15
|
if (isEnrichedRawSeasonWithPosters(obj)) {
|
|
16
16
|
return {
|
|
@@ -24,7 +24,7 @@ export const resolveSeasonPosters = buildObjResolver<
|
|
|
24
24
|
{
|
|
25
25
|
pathTemplateData: { id: obj.tv_show_id, number: obj.season_number, type: IMAGES },
|
|
26
26
|
},
|
|
27
|
-
|
|
27
|
+
ctxData
|
|
28
28
|
);
|
|
29
29
|
|
|
30
30
|
return {
|
|
@@ -16,10 +16,13 @@ const mockedFetch = mockFetch(jest.fn);
|
|
|
16
16
|
|
|
17
17
|
describe('resolveSeasonTranslations >', () => {
|
|
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 info = {} as GraphQLResolveInfo;
|
|
@@ -14,7 +14,7 @@ export const resolveSeasonTranslations = buildObjResolver<
|
|
|
14
14
|
EnrichedRawSeason | (EnrichedRawSeasonWithAppendToResponse & { __headers?: Headers }),
|
|
15
15
|
RawSeasonTranslations['translations']
|
|
16
16
|
>(SEASON, async (obj, ctx) => {
|
|
17
|
-
const {
|
|
17
|
+
const { data: ctxData, restClient } = ctx;
|
|
18
18
|
|
|
19
19
|
if (isEnrichedRawSeasonWithTranslations(obj)) {
|
|
20
20
|
return {
|
|
@@ -28,7 +28,7 @@ export const resolveSeasonTranslations = buildObjResolver<
|
|
|
28
28
|
{
|
|
29
29
|
pathTemplateData: { id: obj.tv_show_id, number: obj.season_number, type: TRANSLATIONS },
|
|
30
30
|
},
|
|
31
|
-
|
|
31
|
+
ctxData
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
return {
|
|
@@ -17,10 +17,13 @@ const mockedFetch = mockFetch(jest.fn);
|
|
|
17
17
|
|
|
18
18
|
describe('resolveSeasonVideos >', () => {
|
|
19
19
|
const context = {
|
|
20
|
+
data: {
|
|
21
|
+
requestID: 'mockRequestID',
|
|
22
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
23
|
+
},
|
|
20
24
|
logger: createMockLogger(jest.fn),
|
|
21
25
|
restClient: createRestClient(),
|
|
22
26
|
setCacheMetadata: jest.fn(),
|
|
23
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
24
27
|
} as unknown as Context;
|
|
25
28
|
|
|
26
29
|
const info = {} as GraphQLResolveInfo;
|
|
@@ -10,7 +10,7 @@ export const resolveSeasonVideos = buildObjResolver<
|
|
|
10
10
|
EnrichedRawSeason | (EnrichedRawSeasonWithAppendToResponse & { __headers?: Headers }),
|
|
11
11
|
RawSeasonVideos['results']
|
|
12
12
|
>(SEASON, async (obj, ctx) => {
|
|
13
|
-
const {
|
|
13
|
+
const { data: ctxData, restClient } = ctx;
|
|
14
14
|
|
|
15
15
|
if (isEnrichedRawSeasonWithVideos(obj)) {
|
|
16
16
|
return {
|
|
@@ -24,7 +24,7 @@ export const resolveSeasonVideos = buildObjResolver<
|
|
|
24
24
|
{
|
|
25
25
|
pathTemplateData: { id: obj.tv_show_id, number: obj.season_number, type: VIDEOS },
|
|
26
26
|
},
|
|
27
|
-
|
|
27
|
+
ctxData
|
|
28
28
|
);
|
|
29
29
|
|
|
30
30
|
return {
|
|
@@ -24,10 +24,13 @@ const baseArgs = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
const context = {
|
|
27
|
+
data: {
|
|
28
|
+
requestID: 'mockRequestID',
|
|
29
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
30
|
+
},
|
|
27
31
|
logger: createMockLogger(jest.fn),
|
|
28
32
|
restClient: createRestClient(),
|
|
29
33
|
setCacheMetadata: jest.fn(),
|
|
30
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
31
34
|
} as unknown as Context;
|
|
32
35
|
|
|
33
36
|
const info = {} as GraphQLResolveInfo;
|
|
@@ -65,7 +68,7 @@ describe('createResourceResolver', () => {
|
|
|
65
68
|
page: 1,
|
|
66
69
|
},
|
|
67
70
|
},
|
|
68
|
-
{ requestID:
|
|
71
|
+
{ requestID: 'mockRequestID', tmdbGuestSessionId: 'mockTmdbGuestSessionId' }
|
|
69
72
|
);
|
|
70
73
|
});
|
|
71
74
|
});
|
package/src/queries/trending.ts
CHANGED
|
@@ -29,14 +29,14 @@ export const createResourceResolver: CreateResourceResolver<undefined, QueryTren
|
|
|
29
29
|
(_obj, args, ctx) =>
|
|
30
30
|
async ({ page }: { page: number }) => {
|
|
31
31
|
const { mediaType, timeWindow } = args;
|
|
32
|
-
const {
|
|
32
|
+
const { data: ctxData, restClient } = ctx;
|
|
33
33
|
|
|
34
34
|
const { data, errors, headers } = await restClient.trending<RawTrending>(
|
|
35
35
|
{
|
|
36
36
|
pathTemplateData: { subType: timeWindow.toLowerCase(), type: mediaType.toLowerCase() },
|
|
37
37
|
queryParams: { page },
|
|
38
38
|
},
|
|
39
|
-
|
|
39
|
+
ctxData
|
|
40
40
|
);
|
|
41
41
|
|
|
42
42
|
if (!data) {
|
package/src/queries/tv.test.ts
CHANGED
|
@@ -21,10 +21,13 @@ describe('resolveTv >', () => {
|
|
|
21
21
|
const id = 1399;
|
|
22
22
|
|
|
23
23
|
const context = {
|
|
24
|
+
data: {
|
|
25
|
+
requestID: 'mockRequestID',
|
|
26
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
27
|
+
},
|
|
24
28
|
logger: createMockLogger(jest.fn),
|
|
25
29
|
restClient: createRestClient(),
|
|
26
30
|
setCacheMetadata: jest.fn(),
|
|
27
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
28
31
|
} as unknown as Context;
|
|
29
32
|
|
|
30
33
|
beforeEach(() => {
|
package/src/queries/tv.ts
CHANGED
|
@@ -50,7 +50,7 @@ export const resolveTv = buildObjArgsResolver<
|
|
|
50
50
|
QueryTvArgs,
|
|
51
51
|
(RawTvWithAppendToResponse & { __headers?: Headers }) | RawTvWithAppendToResponse[keyof RawTvWithAppendToResponse]
|
|
52
52
|
>(TV, async (obj, args, ctx, info) => {
|
|
53
|
-
const {
|
|
53
|
+
const { data: ctxData, fragmentDefinitions, restClient } = ctx;
|
|
54
54
|
const { fieldName, fieldNodes } = info;
|
|
55
55
|
const typedFieldName = snakeCase(fieldName) as keyof RawTv;
|
|
56
56
|
|
|
@@ -75,7 +75,7 @@ export const resolveTv = buildObjArgsResolver<
|
|
|
75
75
|
}
|
|
76
76
|
: {}),
|
|
77
77
|
},
|
|
78
|
-
|
|
78
|
+
ctxData
|
|
79
79
|
);
|
|
80
80
|
|
|
81
81
|
const tvData = {
|
|
@@ -20,10 +20,13 @@ describe('resolveTvAlternativeTitles >', () => {
|
|
|
20
20
|
const tvId = 1399;
|
|
21
21
|
|
|
22
22
|
const context = {
|
|
23
|
+
data: {
|
|
24
|
+
requestID: 'mockRequestID',
|
|
25
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
26
|
+
},
|
|
23
27
|
logger: createMockLogger(jest.fn),
|
|
24
28
|
restClient: createRestClient(),
|
|
25
29
|
setCacheMetadata: jest.fn(),
|
|
26
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
27
30
|
} as unknown as Context;
|
|
28
31
|
|
|
29
32
|
const info = { fieldName: ALTERNATIVE_TITLES } as GraphQLResolveInfo;
|
|
@@ -12,7 +12,7 @@ export const resolveTvAlternativeTitles = buildObjResolver<
|
|
|
12
12
|
RawTv | (RawTvWithAppendToResponse & { __headers?: Headers }),
|
|
13
13
|
RawTvAlternativeTitles['results']
|
|
14
14
|
>(TV, async (obj, ctx) => {
|
|
15
|
-
const {
|
|
15
|
+
const { data: ctxData, restClient } = ctx;
|
|
16
16
|
|
|
17
17
|
if (isRawTvWithAlternativeTitles(obj)) {
|
|
18
18
|
return {
|
|
@@ -26,7 +26,7 @@ export const resolveTvAlternativeTitles = buildObjResolver<
|
|
|
26
26
|
{
|
|
27
27
|
pathTemplateData: { id: obj.id, type: snakeCase(ALTERNATIVE_TITLES) },
|
|
28
28
|
},
|
|
29
|
-
|
|
29
|
+
ctxData
|
|
30
30
|
);
|
|
31
31
|
|
|
32
32
|
return {
|
|
@@ -20,10 +20,13 @@ describe('resolveTvContentRatings >', () => {
|
|
|
20
20
|
const tvId = 1399;
|
|
21
21
|
|
|
22
22
|
const context = {
|
|
23
|
+
data: {
|
|
24
|
+
requestID: 'mockRequestID',
|
|
25
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
26
|
+
},
|
|
23
27
|
logger: createMockLogger(jest.fn),
|
|
24
28
|
restClient: createRestClient(),
|
|
25
29
|
setCacheMetadata: jest.fn(),
|
|
26
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
27
30
|
} as unknown as Context;
|
|
28
31
|
|
|
29
32
|
const info = {} as GraphQLResolveInfo;
|
|
@@ -11,7 +11,7 @@ export const resolveTvContentRatings = buildObjResolver<
|
|
|
11
11
|
RawTv | (RawTvWithAppendToResponse & { __headers?: Headers }),
|
|
12
12
|
RawTvContentRatings['results']
|
|
13
13
|
>(TV, async (obj, ctx) => {
|
|
14
|
-
const {
|
|
14
|
+
const { data: ctxData, restClient } = ctx;
|
|
15
15
|
|
|
16
16
|
if (isRawTvWithContentRatings(obj)) {
|
|
17
17
|
return {
|
|
@@ -25,7 +25,7 @@ export const resolveTvContentRatings = buildObjResolver<
|
|
|
25
25
|
{
|
|
26
26
|
pathTemplateData: { id: obj.id, type: snakeCase(CONTENT_RATINGS) },
|
|
27
27
|
},
|
|
28
|
-
|
|
28
|
+
ctxData
|
|
29
29
|
);
|
|
30
30
|
|
|
31
31
|
return {
|
|
@@ -19,10 +19,13 @@ describe('resolveTvCredits >', () => {
|
|
|
19
19
|
const tvId = 1399;
|
|
20
20
|
|
|
21
21
|
const context = {
|
|
22
|
+
data: {
|
|
23
|
+
requestID: 'mockRequestID',
|
|
24
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
25
|
+
},
|
|
22
26
|
logger: createMockLogger(jest.fn),
|
|
23
27
|
restClient: createRestClient(),
|
|
24
28
|
setCacheMetadata: jest.fn(),
|
|
25
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
26
29
|
} as unknown as Context;
|
|
27
30
|
|
|
28
31
|
beforeEach(() => {
|
package/src/queries/tvCredits.ts
CHANGED
|
@@ -10,7 +10,7 @@ export const resolveTvCredits = buildObjResolver<
|
|
|
10
10
|
RawTv | (RawTvWithAppendToResponse & { __headers?: Headers }),
|
|
11
11
|
RawTvCredits['cast'] | RawTvCredits['crew']
|
|
12
12
|
>(TV, async (obj, ctx, info) => {
|
|
13
|
-
const {
|
|
13
|
+
const { data: ctxData, restClient } = ctx;
|
|
14
14
|
const { fieldName } = info;
|
|
15
15
|
const typedFieldName = fieldName as 'cast' | 'crew';
|
|
16
16
|
|
|
@@ -26,7 +26,7 @@ export const resolveTvCredits = buildObjResolver<
|
|
|
26
26
|
{
|
|
27
27
|
pathTemplateData: { id: obj.id, type: CREDITS },
|
|
28
28
|
},
|
|
29
|
-
|
|
29
|
+
ctxData
|
|
30
30
|
);
|
|
31
31
|
|
|
32
32
|
return {
|
|
@@ -20,10 +20,13 @@ describe('resolveTvEpisodeGroups >', () => {
|
|
|
20
20
|
const tvId = 1399;
|
|
21
21
|
|
|
22
22
|
const context = {
|
|
23
|
+
data: {
|
|
24
|
+
requestID: 'mockRequestID',
|
|
25
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
26
|
+
},
|
|
23
27
|
logger: createMockLogger(jest.fn),
|
|
24
28
|
restClient: createRestClient(),
|
|
25
29
|
setCacheMetadata: jest.fn(),
|
|
26
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
27
30
|
} as unknown as Context;
|
|
28
31
|
|
|
29
32
|
const info = {} as GraphQLResolveInfo;
|
|
@@ -11,7 +11,7 @@ export const resolveTvEpisodeGroups = buildObjResolver<
|
|
|
11
11
|
RawTv | (RawTvWithAppendToResponse & { __headers?: Headers }),
|
|
12
12
|
RawTvEpisodeGroups['results']
|
|
13
13
|
>(TV, async (obj, ctx) => {
|
|
14
|
-
const {
|
|
14
|
+
const { data: ctxData, restClient } = ctx;
|
|
15
15
|
|
|
16
16
|
if (isRawTvWithEpisodeGroups(obj)) {
|
|
17
17
|
return {
|
|
@@ -25,7 +25,7 @@ export const resolveTvEpisodeGroups = buildObjResolver<
|
|
|
25
25
|
{
|
|
26
26
|
pathTemplateData: { id: obj.id, type: snakeCase(EPISODE_GROUPS) },
|
|
27
27
|
},
|
|
28
|
-
|
|
28
|
+
ctxData
|
|
29
29
|
);
|
|
30
30
|
|
|
31
31
|
return {
|
|
@@ -20,10 +20,13 @@ describe('resolveTvExternalIds >', () => {
|
|
|
20
20
|
const tvId = 1399;
|
|
21
21
|
|
|
22
22
|
const context = {
|
|
23
|
+
data: {
|
|
24
|
+
requestID: 'mockRequestID',
|
|
25
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
26
|
+
},
|
|
23
27
|
logger: createMockLogger(jest.fn),
|
|
24
28
|
restClient: createRestClient(),
|
|
25
29
|
setCacheMetadata: jest.fn(),
|
|
26
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
27
30
|
} as unknown as Context;
|
|
28
31
|
|
|
29
32
|
const info = {} as GraphQLResolveInfo;
|
|
@@ -12,7 +12,7 @@ export const resolveTvExternalIds = buildObjResolver<
|
|
|
12
12
|
RawTv | (RawTvWithAppendToResponse & { __headers?: Headers }),
|
|
13
13
|
Except<RawTvExternalIds, 'id'>
|
|
14
14
|
>(TV, async (obj, ctx) => {
|
|
15
|
-
const {
|
|
15
|
+
const { data: ctxData, restClient } = ctx;
|
|
16
16
|
|
|
17
17
|
if (isRawTvWithExternalIds(obj)) {
|
|
18
18
|
return {
|
|
@@ -26,7 +26,7 @@ export const resolveTvExternalIds = buildObjResolver<
|
|
|
26
26
|
{
|
|
27
27
|
pathTemplateData: { id: obj.id, type: snakeCase(EXTERNAL_IDS) },
|
|
28
28
|
},
|
|
29
|
-
|
|
29
|
+
ctxData
|
|
30
30
|
);
|
|
31
31
|
|
|
32
32
|
const { id: tvId, ...rest } = data ?? {};
|
|
@@ -19,10 +19,13 @@ describe('resolveTvImages >', () => {
|
|
|
19
19
|
const tvId = 1399;
|
|
20
20
|
|
|
21
21
|
const context = {
|
|
22
|
+
data: {
|
|
23
|
+
requestID: 'mockRequestID',
|
|
24
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
25
|
+
},
|
|
22
26
|
logger: createMockLogger(jest.fn),
|
|
23
27
|
restClient: createRestClient(),
|
|
24
28
|
setCacheMetadata: jest.fn(),
|
|
25
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
26
29
|
} as unknown as Context;
|
|
27
30
|
|
|
28
31
|
beforeEach(() => {
|
package/src/queries/tvImages.ts
CHANGED
|
@@ -10,7 +10,7 @@ export const resolveTvImages = buildObjResolver<
|
|
|
10
10
|
RawTv | (RawTvWithAppendToResponse & { __headers?: Headers }),
|
|
11
11
|
RawTvImages['posters'] | RawTvImages['logos'] | RawTvImages['backdrops']
|
|
12
12
|
>(TV, async (obj, ctx, info) => {
|
|
13
|
-
const {
|
|
13
|
+
const { data: ctxData, restClient } = ctx;
|
|
14
14
|
const { fieldName } = info;
|
|
15
15
|
const typedFieldName = fieldName as 'backdrops' | 'logos' | 'posters';
|
|
16
16
|
|
|
@@ -26,7 +26,7 @@ export const resolveTvImages = buildObjResolver<
|
|
|
26
26
|
{
|
|
27
27
|
pathTemplateData: { id: obj.id, type: IMAGES },
|
|
28
28
|
},
|
|
29
|
-
|
|
29
|
+
ctxData
|
|
30
30
|
);
|
|
31
31
|
|
|
32
32
|
return {
|
|
@@ -19,10 +19,13 @@ describe('resolveTvKeywords >', () => {
|
|
|
19
19
|
const tvId = 1399;
|
|
20
20
|
|
|
21
21
|
const context = {
|
|
22
|
+
data: {
|
|
23
|
+
requestID: 'mockRequestID',
|
|
24
|
+
tmdbGuestSessionId: 'mockTmdbGuestSessionId',
|
|
25
|
+
},
|
|
22
26
|
logger: createMockLogger(jest.fn),
|
|
23
27
|
restClient: createRestClient(),
|
|
24
28
|
setCacheMetadata: jest.fn(),
|
|
25
|
-
tmdbGuestSessionId: 'mock-tmdbGuestSessionId',
|
|
26
29
|
} as unknown as Context;
|
|
27
30
|
|
|
28
31
|
const info = {} as GraphQLResolveInfo;
|