Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add role data to staff media query #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ function edgeRemove(obj) {
for (let x = 0; x < obj.length; x++) {
if (obj[x].name) {
obj[x].name = obj[x].name.english || obj[x].name.full;
} else if (obj[x].role && obj[x].node?.id && obj[x].node?.name) {
obj[x].name = obj[x].node.name.english || obj[x].node.name.full;
obj[x].id = obj[x].node.id;
delete obj[x].node;
}

if (obj[x].node) {
Expand Down Expand Up @@ -66,7 +70,7 @@ function formatMedia(media) {

media.externalLinks = edgeRemove(media.externalLinks);
media.characters = edgeRemove(media.characters.nodes);
media.staff = edgeRemove(media.staff.nodes);
media.staff = edgeRemove(media.staff.edges);

if (media.airingSchedule) {
media.airingSchedule = media.airingSchedule.nodes;
Expand Down
4 changes: 2 additions & 2 deletions lib/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Media {
updatedAt coverImage { large:extraLarge medium:large small:medium color }
bannerImage genres synonyms averageScore meanScore favourites
popularity trending tags { id name isMediaSpoiler } relations { nodes { id title { english native romaji userPreferred } type } }
characters { nodes { id name { english: full } } } staff { nodes { id name { english: full } } } studios { nodes { id name isAnimationStudio } }
characters { nodes { id name { english: full } } } staff { edges { role node { id name { english: full } } } } studios { nodes { id name isAnimationStudio } }
isFavourite isAdult isLocked nextAiringEpisode { timeUntilAiring airingAt episode } airingSchedule { nodes { airingAt timeUntilAiring episode } }
trends { nodes { date trending popularity inProgress } } externalLinks { url }
streamingEpisodes { title thumbnail url site } rankings { rank type context year season } mediaListEntry { id status }
Expand Down Expand Up @@ -92,7 +92,7 @@ class Media {
description format status startDate { year month day } endDate { year month day } chapters volumes countryOfOrigin isLicensed updatedAt
coverImage { large:extraLarge medium:large small:medium color } bannerImage genres synonyms averageScore meanScore siteUrl autoCreateForumThread modNotes
popularity trending tags { id name isMediaSpoiler } relations { nodes { id title { english native romaji userPreferred } type } }
characters { nodes { id name { english: full } } } staff { nodes { id name { english: full } } } isFavourite isAdult isLocked
characters { nodes { id name { english: full } } } staff { edges { role node { id name { english: full } } } } isFavourite isAdult isLocked
trends { nodes { date trending popularity inProgress } } externalLinks { url } rankings { rank type context year season }
mediaListEntry { id status } reviews { nodes { id score summary body } }
stats { scoreDistribution { score amount } statusDistribution { status amount } } favourites
Expand Down
6 changes: 5 additions & 1 deletion lib/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@ export declare interface PersonRelation {
name: string
}

export declare interface PersonRoleRelation extends PersonRelation {
role: string
}

export declare interface UserRelation {
id: number,
name: string
Expand Down Expand Up @@ -741,7 +745,7 @@ declare interface MediaEntry {
tags: Tags[],
relations: MediaRelation[],
characters: PersonRelation[],
staff: PersonRelation[],
staff: PersonRoleRelation[],
studios: StudioRelation[],
isFavourite: boolean,
isAdult: boolean,
Expand Down