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.88 import ( "context" "time" "adam-french.co.uk/backend/graph/model" "adam-french.co.uk/backend/services" ) // SteamStatus is the resolver for the steamStatus field. func (r *queryResolver) SteamStatus(ctx context.Context) (*model.SteamStatus, error) { if r.Store.SteamAPIKey == "" { return nil, nil } if r.Store.SteamFresh() { return &model.SteamStatus{ Online: r.Store.SteamOnline, RecentGames: mapSteamGames(r.Store.SteamRecentGames), }, nil } games, err := services.FetchRecentlyPlayedGames(r.Store.SteamAPIKey, r.Store.SteamID) if err != nil { return nil, err } summary, err := services.FetchPlayerSummary(r.Store.SteamAPIKey, r.Store.SteamID) if err != nil { return nil, err } online := false if summary != nil { online = summary.PersonaState > 0 } r.Store.SteamRecentGames = games r.Store.SteamOnline = online r.Store.SteamFetchedAt = time.Now() return &model.SteamStatus{ Online: online, RecentGames: mapSteamGames(games), }, nil }