Skip to content

Commit ba175a6

Browse files
committed
add claude
1 parent 29738d5 commit ba175a6

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Development Commands
6+
7+
- `npm test` - Run Jest tests with coverage
8+
- `npm run ci` - Run tests in watch mode for development
9+
- `npm run lint` - Run ESLint on src and test directories
10+
- `npm run lint:fix` - Auto-fix ESLint issues
11+
- `npm run dev` - Run development server with examples/index.js (simple example)
12+
- `npm run dev full` - Run development server with examples/full/index.js (full example)
13+
- `npm run deps` - Update dependencies interactively using ncu
14+
- `npm run postdeps` - Automatically run tests after dependency updates
15+
16+
## Project Architecture
17+
18+
This is a **Moleculer mixin** that integrates Apollo GraphQL Server 5 with Moleculer API Gateway. The core architecture consists of:
19+
20+
### Core Components
21+
- **src/service.js** - Main service mixin factory that returns a Moleculer service schema
22+
- **src/ApolloServer.js** - Custom ApolloServer class extending @apollo/server
23+
- **src/gql.js** - GraphQL template literal formatter utility
24+
- **index.js** - Main module exports
25+
26+
### Key Architectural Patterns
27+
28+
**Service Mixin Pattern**: The library exports a factory function `ApolloService(options)` that returns a Moleculer service schema to be mixed into API Gateway services.
29+
30+
**Auto-Schema Generation**: GraphQL schemas are dynamically generated from:
31+
- Service action definitions with `graphql` property containing `query`, `mutation`, or `subscription` fields
32+
- Service-level GraphQL definitions in `settings.graphql`
33+
- Global typeDefs and resolvers passed to the mixin
34+
35+
**Action-to-Resolver Mapping**: Moleculer actions automatically become GraphQL resolvers when they include GraphQL definitions. The system creates resolver functions that call `ctx.call(actionName, params)`.
36+
37+
**DataLoader Integration**: Built-in DataLoader support for batch loading with automatic key mapping and caching via resolver configuration.
38+
39+
**WebSocket Subscriptions**: GraphQL subscriptions are handled through WebSocket connections with PubSub pattern integration.
40+
41+
### Testing Structure
42+
- **test/unit/** - Unit tests for individual components
43+
- **test/integration/** - Integration tests with full service setup
44+
- Jest snapshots for schema generation testing
45+
46+
### Examples Structure
47+
- **examples/simple/** - Basic setup demonstration
48+
- **examples/full/** - Complete setup with multiple services, DataLoader, and complex resolvers
49+
50+
## Important Development Notes
51+
52+
**Schema Regeneration**: The GraphQL schema is automatically regenerated when services change (`$services.changed` event) unless `autoUpdateSchema: false`.
53+
54+
**TypeScript Support**: Full TypeScript definitions in index.d.ts with comprehensive interfaces for all configuration options.
55+
56+
**Node.js Version**: Requires Node.js >= 20.x.x (specified in package.json engines).

0 commit comments

Comments
 (0)