Skip to content

Spotify/Anchor GraphQL endpoints#220

Draft
mre wants to merge 2 commits intomainfrom
spotify-graphql
Draft

Spotify/Anchor GraphQL endpoints#220
mre wants to merge 2 commits intomainfrom
spotify-graphql

Conversation

@mre
Copy link
Copy Markdown
Member

@mre mre commented Mar 16, 2026

The spotify_graphql pipeline (openpodcast/pipelines#118) is a GraphQL-based
replacement for both the old spotify/ and anchor/ pipelines, which both
use broken REST connectors.

mre added 2 commits March 5, 2026 00:02
The new spotify_graphql pipeline (openpodcast/pipelines#118) sends 14
endpoint names that the existing SpotifyConnector does not recognise,
causing every request to fail with HTTP 400 "Unknown endpoint in meta".

This commit wires up all 14 endpoints end-to-end.

New endpoints accepted
----------------------
Show-level (no episode in meta):
showSpotifyStats, showDemographicsStats, showAudienceDiscovery,
showGeoStats, showPlatformStats, showImpressionsTrend,
showImpressionsSources, showTopEpisodes

Episode-level (episode URI in meta):
episodeMetadata (GraphQL shape), episodePerformanceAllTime,
episodeStreamsAndDownloads, episodePlaysDaily,
episodeConsumptionAllTime, episodeAudienceSizeAllTime

Storage strategy
----------------
All 14 new endpoints share a single storeGraphQLRaw() method
(SpotifyRepository) which inserts into the new spotifyGraphQLRaw table
(migration 19). The raw GraphQL response blob is stored as JSON with
account_id, show_uri, episode_uri (nullable), endpoint name, and
retrieved_at. This keeps the connector side simple while the nested
GraphQL shapes get normalised in a follow-up.

The existing episodeMetadata handler is unchanged for the old flat
payload shape. It detects the new GraphQL shape by the presence of the
episodeByUri key and routes to storeGraphQLRaw instead.

All old endpoint names (metadata, detailedStreams, listeners, aggregate,
followers, performance, impressions_*) are completely untouched.

Changed files
-------------
src/api/connectors/SpotifyConnector.ts — 14 new else-if branches
src/db/SpotifyRepository.ts            — storeGraphQLRaw() method
src/types/provider/spotify.ts          — SpotifyGraphQLPayload types
src/types/connector.ts                 — retrieved + version fields
db_schema/migrations/19_spotify_graphql_raw.sql — new table
src/schema/spotify/<14 new .json>      — permissive JSON schemas
fixtures/spotifyGraphql<14 new .json>  — real sample data from Leaders
Talk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant