import { graphql } from "gql.tada"; import { HomeTitleFragment } from "~/types/title/homeTitle"; import { MediaFragment } from "~/types/title/mediaFragment"; export const GetTitleQuery = graphql( ` query GetTitle($id: Int!) { Media(id: $id) { ...Media } } `, [MediaFragment], ); export const GetTitleUserDataQuery = graphql(` query GetTitleUserData($id: Int!) { Media(id: $id) { mediaListEntry { id progress status } } } `); export const SearchQuery = graphql( ` query Search($query: String!, $page: Int!, $limit: Int!) { Page(page: $page, perPage: $limit) { media( search: $query type: ANIME sort: [POPULARITY_DESC, SCORE_DESC] ) { ...HomeTitle } pageInfo { hasNextPage } } } `, [HomeTitleFragment], ); export const GetNextEpisodeAiringAtQuery = graphql(` query GetNextEpisodeAiringAt($id: Int!) { Media(id: $id) { status nextAiringEpisode { episode airingAt } } } `); export const MarkEpisodeAsWatchedMutation = graphql(` mutation MarkEpisodeAsWatched($titleId: Int!, $episodeNumber: Int!) { SaveMediaListEntry( mediaId: $titleId status: CURRENT progress: $episodeNumber ) { user { id name avatar { medium large } statistics { anime { minutesWatched episodesWatched count meanScore } } } } } `); export const MarkTitleAsWatchedMutation = graphql(` mutation MarkTitleAsWatched($titleId: Int!) { SaveMediaListEntry(mediaId: $titleId, status: COMPLETED) { user { id name avatar { medium large } statistics { anime { minutesWatched episodesWatched count meanScore } } } } } `); export const GetUserQuery = graphql(` query GetUser { Viewer { id name } } `); export const GetUserProfileQuery = graphql(` query GetUserProfile { Viewer { id name avatar { medium large } statistics { anime { minutesWatched episodesWatched count meanScore } } } } `); export const GetPopularTitlesQuery = graphql( ` query GetPopularTitles( $page: Int $limit: Int $season: MediaSeason $seasonYear: Int ) { Page(page: $page, perPage: $limit) { media( type: ANIME sort: POPULARITY_DESC season: $season seasonYear: $seasonYear isAdult: false ) { ...HomeTitle } pageInfo { hasNextPage } } } `, [HomeTitleFragment], ); export const GetTrendingTitlesQuery = graphql( ` query GetTrendingTitles($page: Int, $limit: Int) { Page(page: $page, perPage: $limit) { media(type: ANIME, sort: TRENDING_DESC, isAdult: false) { ...HomeTitle } pageInfo { hasNextPage } } } `, [HomeTitleFragment], ); export const GetUpcomingTitlesQuery = graphql( ` query GetUpcomingTitles( $page: Int! $airingAtLowerBound: Int! $airingAtUpperBound: Int! ) { Page(page: $page) { airingSchedules( notYetAired: true sort: TIME airingAt_lesser: $airingAtUpperBound airingAt_greater: $airingAtLowerBound ) { id airingAt timeUntilAiring episode media { ...Media } } pageInfo { hasNextPage } } } `, [MediaFragment], ); export const BrowsePopularQuery = graphql( ` query BrowsePopular( $season: MediaSeason! $seasonYear: Int! $nextSeason: MediaSeason! $nextYear: Int! $limit: Int! ) { trending: Page(page: 1, perPage: $limit) { media(sort: TRENDING_DESC, type: ANIME, isAdult: false) { ...HomeTitle } } season: Page(page: 1, perPage: $limit) { media( season: $season seasonYear: $seasonYear sort: POPULARITY_DESC type: ANIME isAdult: false ) { ...HomeTitle } } nextSeason: Page(page: 1, perPage: $limit) { media( season: $nextSeason seasonYear: $nextYear sort: POPULARITY_DESC type: ANIME isAdult: false ) { ...HomeTitle } } } `, [HomeTitleFragment], ); export const NextSeasonPopularQuery = graphql( ` query NextSeasonPopular( $nextSeason: MediaSeason $nextYear: Int $limit: Int! $page: Int! ) { Page(page: $page, perPage: $limit) { media( season: $nextSeason seasonYear: $nextYear sort: POPULARITY_DESC type: ANIME isAdult: false ) { ...HomeTitle } } } `, [HomeTitleFragment], );