All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 3m36s
Move Query/Mutation field declarations from the monolithic schema.graphql into each domain's .graphql file using extend type, so gqlgen places resolvers in the matching *.resolvers.go files. Extract helper functions into *_helpers.go files to prevent gqlgen from commenting them out. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package graph
|
|
|
|
import (
|
|
"adam-french.co.uk/backend/graph/model"
|
|
"github.com/zmb3/spotify/v2"
|
|
)
|
|
|
|
func mapSpotifyImages(images []spotify.Image) []*model.SpotifyImage {
|
|
result := make([]*model.SpotifyImage, len(images))
|
|
for i, img := range images {
|
|
result[i] = &model.SpotifyImage{URL: img.URL}
|
|
}
|
|
return result
|
|
}
|
|
|
|
func mapSpotifyTrack(track *spotify.FullTrack) *model.SpotifyTrack {
|
|
artists := make([]*model.SpotifyArtist, len(track.Artists))
|
|
for i, a := range track.Artists {
|
|
artists[i] = &model.SpotifyArtist{Name: a.Name}
|
|
}
|
|
return &model.SpotifyTrack{
|
|
Name: track.Name,
|
|
Artists: artists,
|
|
Album: &model.SpotifyAlbum{
|
|
Name: track.Album.Name,
|
|
Images: mapSpotifyImages(track.Album.Images),
|
|
},
|
|
}
|
|
}
|
|
|
|
func mapRecentItems(items []spotify.RecentlyPlayedItem) []*model.SpotifyRecentItem {
|
|
result := make([]*model.SpotifyRecentItem, len(items))
|
|
for i, item := range items {
|
|
artists := make([]*model.SpotifyArtist, len(item.Track.Artists))
|
|
for j, a := range item.Track.Artists {
|
|
artists[j] = &model.SpotifyArtist{Name: a.Name}
|
|
}
|
|
result[i] = &model.SpotifyRecentItem{
|
|
PlayedAt: item.PlayedAt,
|
|
Track: &model.SpotifyTrack{
|
|
Name: item.Track.Name,
|
|
Artists: artists,
|
|
Album: &model.SpotifyAlbum{
|
|
Name: item.Track.Album.Name,
|
|
Images: mapSpotifyImages(item.Track.Album.Images),
|
|
},
|
|
},
|
|
}
|
|
}
|
|
return result
|
|
}
|