import { paginatorFromVariables } from '../utils' ; import { safeApiCall } from '../utils' ; export function artistResolvers ( spotifyApiClient ) { return { top_tracks ( artist , variables ) { return safeApiCall ( spotifyApiClient , 'getArtistTopTracks' , response => response . body . tracks , artist . id , variables . country || 'US' ) ; } , albums ( artist , variables ) { return paginatorFromVariables ( 'OffsetPaging' , variables ) ( spotifyApiClient , 'getArtistAlbums' , ( response ) => response . body . items , artist . id , variables . album_type ? { album_type : variables . album_type } : { } ) ; } , related_artists ( artist , variables ) { return safeApiCall ( spotifyApiClient , 'getArtistRelatedArtists' , ( response ) => response . body . artists , artist . id ) ; } } ; }