package graph // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.95 import ( "context" "adam-french.co.uk/backend/graph/model" ) // SpotifyListening is the resolver for the spotifyListening field. func (r *queryResolver) SpotifyListening(ctx context.Context) (*model.SpotifyPlaying, error) { // A nil client means the OAuth flow has never been completed. Report that // as null rather than an error so the home page renders without it. if r.Store.SpotifyClient == nil { return nil, nil } playing, err := r.Store.SpotifyClient.PlayerCurrentlyPlaying(ctx) if err != nil { return nil, err } result := &model.SpotifyPlaying{Playing: playing.Playing} if playing.Item != nil { result.Track = mapSpotifyTrack(playing.Item) } return result, nil } // SpotifyRecent is the resolver for the spotifyRecent field. func (r *queryResolver) SpotifyRecent(ctx context.Context) ([]*model.SpotifyRecentItem, error) { if r.Store.SpotifyClient == nil { return []*model.SpotifyRecentItem{}, nil } // Shared one-minute cache, filled by whichever of this resolver and the // REST /spotify/recent endpoint misses it first. played, err := r.Store.RecentlyPlayedTracks(ctx) if err != nil { return nil, err } return mapRecentItems(played), nil }