Slices Teal Relay Demo#
A teal.fm timeline built with React, Relay, and Tailwind CSS. Displays music plays from the Slices GraphQL API.
Live Demo: https://slices-teal-relay.bigmoves.deno.net/
Features#
- Real-time music scrobble feed
- User profiles with listening history
- Album artwork from MusicBrainz
- Infinite scroll pagination
- Dark mode UI inspired by Last.fm
- Powered by Relay for efficient GraphQL data management
Tech Stack#
- React - UI framework
- Relay - GraphQL client with automatic cache management
- React Router - Client-side routing
- Tailwind CSS - Styling
- Vite - Build tool
- TypeScript - Type safety
Prerequisites#
- Node.js 18+ or Deno
- npm or pnpm
Getting Started#
-
Install dependencies
npm install -
Fetch the GraphQL schema
npm run schema:prod -
Generate Relay types
npx relay-compiler -
Start the development server
npm run devThe app will be available at
http://localhost:5173
Development#
Updating the GraphQL Schema#
The project connects to the Slices API. To update the schema:
npm run schema:prod
npx relay-compiler
Project Structure#
src/
├── App.tsx # Main feed component
├── Profile.tsx # User profile page
├── TrackItem.tsx # Individual track card component
├── LoadingFallback.tsx # Loading skeleton
├── useAlbumArt.ts # Hook to fetch album art from MusicBrainz
└── __generated__/ # Relay-generated TypeScript types
Working with Relay#
This project uses Relay's modern API with:
useLazyLoadQuery- Load data on component mountusePaginationFragment- Infinite scroll pagination with automatic cache updatesuseFragment- Fragment composition for data colocation@connectiondirective - Automatic list merging for pagination
After modifying any GraphQL queries or fragments, run:
npx relay-compiler
Environment#
The app connects to:
- Production API:
https://api.slices.network/graphql - Slice:
at://did:plc:n2sgrmrxjell7f5oa5ruwlyl/network.slices.slice/3m5d5dfs3oy26
Scripts#
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run lint- Run ESLintnpm run schema:prod- Fetch GraphQL schema from production API
Features in Detail#
Album Artwork#
The app fetches album artwork from MusicBrainz using the releaseMbId field.
The fetch happens asynchronously per track and displays when available.
Infinite Scroll#
Both the main feed and profile pages use Relay's usePaginationFragment for
efficient infinite scrolling with automatic cache management.
Routing#
/- Main feed/tracks- Top tracks/albums- Top albums/profile/:handle- User profile page
License#
MIT