Back to Projects
Outside Inc.Full Stack Engineer2023-2024

JWPlayer Subgraph

A GraphQL Federation subgraph for video streaming with DRM protection, EPG schedules, and series management for Outside TV.

TypeScriptApollo ServerApollo FederationPrismaPostgreSQLJWPlayer APIDRM
JWPlayer Subgraph

The Challenge

Outside Inc. operates Outside TV, a streaming service with live broadcasts, on-demand content, and a FAST (Free Ad-Supported TV) channel. The video infrastructure needed to:

  • Integrate with JWPlayer's delivery network
  • Support DRM (Digital Rights Management) for premium content
  • Manage EPG (Electronic Program Guide) schedules for live TV
  • Organize content into series, seasons, and playlists
  • Handle geo-restrictions for licensed content

Architecture

The JWPlayer Subgraph bridges the Apollo Federation Gateway with JWPlayer's APIs:

┌─────────────────────────────────────────────────────────────┐
│                    Apollo Gateway                            │
└─────────────────────────────────────────────────────────────┘
                            │
                            ▼
┌─────────────────────────────────────────────────────────────┐
│                   JWPlayer Subgraph                          │
│                                                              │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐         │
│  │   Playlists │  │    Series   │  │     EPG     │         │
│  └─────────────┘  └─────────────┘  └─────────────┘         │
└─────────────────────────────────────────────────────────────┘
        │                   │                   │
        ▼                   ▼                   ▼
┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐
│    JWPlayer     │  │   PostgreSQL    │  │  Vualto DRM     │
│      API        │  │   (Metadata)    │  │    Service      │
└─────────────────┘  └─────────────────┘  └─────────────────┘
Video Infrastructure

Technical Approach

Schema Design

The schema models video content hierarchy with media items at the core. Each MediaItem includes playback URLs, DRM status, and live state (live, upcoming, or VOD). Items can belong to series with seasons and episodes, or to playlists for curated collections.

DRM Integration

Protected content requires signed URLs from the Vualto DRM service. The subgraph detects the appropriate DRM type (FairPlay for Safari, Widevine for Chrome/Firefox, PlayReady for Edge) based on the user agent and returns properly signed playback URLs.

Geo-Restriction Rules

Content access is controlled by protection rules that either allow or deny specific countries. Licensed content like certain outdoor films may only be available in specific regions due to distribution agreements.

EPG Schedule Management

The FAST channel schedule is stored in PostgreSQL and imported from weekly schedule spreadsheets. The EPG data powers the TV guide interface, showing what's currently playing and what's coming up.

Live Event Handling

Live streams receive special handling in queries. When fetching live and upcoming events, currently live content is sorted to the top, followed by upcoming events ordered by start time.

CDN Response Caching

JWPlayer CDN responses are cached locally in PostgreSQL to reduce API calls. Cached data is considered fresh for one hour before being re-fetched from JWPlayer.

Key Features

Series and Seasons

Content is organized hierarchically with series containing seasons, and seasons containing episodes. Queries can fetch an entire series structure or drill down to specific seasons.

Test Event Filtering

Test events are automatically hidden in production but can be included in staging and development environments for QA purposes.

Read Replica Support

Like the Editorial Subgraph, high-read queries are routed to the PostgreSQL read replica for better performance and load distribution.

Outcomes

The JWPlayer Subgraph successfully:

  • Unified video access — Single API for all video content
  • Secured premium content — DRM protection for subscriber-only videos
  • Enabled live TV — EPG schedules power the FAST channel guide
  • Simplified content organization — Series/season structure for episodic content
  • Improved performance — CDN response caching reduced API calls by 70%

The subgraph powers the Watch platform, serving live broadcasts to thousands of concurrent viewers during major outdoor events and providing on-demand access to the Outside TV content library.