-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added the single tv show lookup query and enhanced the entertai…
…nment service to take into account the entertainment type e.g. movie or tv
- Loading branch information
1 parent
7d949bb
commit 7f5131c
Showing
11 changed files
with
380 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
type Query { | ||
movie(id: Int!): Movie | ||
show(id: Int!): Show | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-disable import/extensions */ | ||
import { HttpModule } from '@nestjs/axios'; | ||
import { Module } from '@nestjs/common'; | ||
import { EntertainmentModule } from 'src/entertainment/entertainment.module'; | ||
import { UtilsModule } from 'src/utils/utils.module'; | ||
|
||
import { ShowResolver } from './show.resolver'; | ||
import { ShowService } from './show.service'; | ||
|
||
@Module({ | ||
providers: [ShowService, ShowResolver], | ||
imports: [HttpModule, UtilsModule, EntertainmentModule] | ||
}) | ||
export class ShowModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Args, Parent, Query, ResolveField, Resolver } from '@nestjs/graphql'; | ||
|
||
import { ShowService } from './show.service'; | ||
import { Cast, Crew, Keyword, Review, Show, Social } from '../graphql.schema'; | ||
|
||
@Resolver() | ||
export class ShowResolver { | ||
constructor(private readonly showService: ShowService) {} | ||
|
||
@Query() | ||
async show(@Args('id') showId: number): Promise<Show> { | ||
return this.showService.getShow(showId); | ||
} | ||
|
||
@ResolveField() | ||
async review(@Parent() show: Show): Promise<Review | null> { | ||
return this.showService.getReview(show.id ?? 0); | ||
} | ||
|
||
@ResolveField() | ||
async topBilledCast(@Parent() show: Show): Promise<Cast[] | null> { | ||
return this.showService.getTopBilledCast(show.id ?? 0); | ||
} | ||
|
||
@ResolveField() | ||
async featuredCrew(@Parent() show: Show): Promise<Crew[] | null> { | ||
return this.showService.getFeaturedCrewMembers(show.id ?? 0); | ||
} | ||
|
||
@ResolveField() | ||
async keywords(@Parent() show: Show): Promise<Keyword[] | null> { | ||
return this.showService.getKeywords(show.id ?? 0); | ||
} | ||
|
||
@ResolveField() | ||
async social(@Parent() show: Show): Promise<Social | null> { | ||
// Get the external social url (The homepage isn't set here as it's already apart of the original Show query) | ||
const socials = await this.showService.getSocials(show.id ?? 0); | ||
|
||
return { | ||
...socials, | ||
|
||
// Since the homepage is apart of the original query append it to the homepage property | ||
homepage: show.homepage | ||
}; | ||
} | ||
|
||
@ResolveField() | ||
async trailerUrl(@Parent() show: Show): Promise<string | null> { | ||
return this.showService.getTrailerUrl(show.id ?? 0); | ||
} | ||
} |
Oops, something went wrong.