UNPKG

@focus-reactive/graphql-content-layer

Version:

[![npm version](https://badge.fury.io/js/%40focus-reactive%2Fgraphql-content-layer.svg)](https://badge.fury.io/js/%40focus-reactive%2Fgraphql-content-layer) # GitNation GraphQL Content Layer

50 lines (39 loc) 2.41 kB
# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Commands ### Development - `yarn dev` - Watch and compile code continuously - `yarn storybook` - Run Storybook on port 6001 - `yarn tdd` - Run Jest tests in watch mode - `yarn start` - Run dev, storybook, and tdd in parallel - `yarn test` - Run all Jest tests - `yarn test:smoke` - Run smoke tests with open handles detection - `yarn update-schema` - Update GraphQL introspection schema - `yarn prepare` - Build the package using package-prepare - `npm publish` - Transpile and publish to NPM ### Testing Tests are located in the `tests/` directory. To run a specific test file: ```bash yarn test tests/[filename].test.js ``` ## Architecture This package is a GraphQL content layer for fetching and processing conference content from GraphCMS. It: 1. **Fetches data** from GraphCMS using GraphQL queries through multiple fetch modules (`fetch-*.js`) 2. **Processes content** through a post-processing layer that merges talks, Q&A sessions, and populates speaker activities 3. **Exposes content** via the `getContent` async function for consumption 4. **Generates Storybook** for visualizing both CMS and content layers ### Key Components - **Entry point**: `src/index.js` - Creates GraphQL client and orchestrates all content fetching - **Content fetchers**: `src/fetch-*.js` files - Each handles a specific content type (speakers, talks, sponsors, etc.) - **Post-processing**: `src/postprocess.js` - Merges and enriches content relationships - **Configuration**: Requires `CMS_ENDPOINT` and `CMS_TOKEN` environment variables for GraphCMS connection - **Conference settings**: Must be passed to `getContent()` with conference-specific data including `conferenceTitle`, `eventYear`, `tagColors`, and `speakerAvatar` dimensions ### Content Flow 1. Conference settings are passed to `getContent(conferenceSettings)` 2. All fetch modules run in parallel via Promise.all 3. Content pieces are merged with conflict resolution for duplicate keys 4. Post-processing enriches the content (populates speaker talks, merges Q&A sessions) 5. Schedule items are sorted chronologically 6. Final processed content is returned ### GraphQL Schema The GraphQL schema is stored in `schema.graphql` and can be updated using `yarn update-schema`. The schema endpoint is configured in `.graphqlconfig`.