Skip to content

Commit 960cda3

Browse files
authored
Merge pull request #126 from moleculerjs/next
Major update: Apollo Server 5 migration with breaking changes
2 parents f25fe16 + 11d477d commit 960cda3

39 files changed

+13096
-20063
lines changed

.codeclimate.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,19 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
# node-version: [10.x, 12.x, 14.x, 15.x]
13-
node-version: [10.x, 12.x, 14.x, 16.x, 18.x]
12+
node-version: [20.x, 22.x, 24.x]
1413
fail-fast: false
1514

1615
steps:
17-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1817

1918
- name: Use Node.js ${{ matrix.node-version }}
20-
uses: actions/setup-node@v1
19+
uses: actions/setup-node@v4
2120
with:
2221
node-version: ${{ matrix.node-version }}
2322

2423
- name: Cache node modules
25-
uses: actions/cache@v2
24+
uses: actions/cache@v4
2625
env:
2726
cache-name: cache-node-modules
2827
with:

.github/workflows/typecheck.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: TypeScript Type Check
2+
3+
on:
4+
push: {}
5+
pull_request: {}
6+
7+
jobs:
8+
typecheck:
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
matrix:
13+
node-version: [20.x, 22.x, 24.x]
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
cache: 'npm'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Typecheck
29+
run: npm run typecheck
30+
31+
- name: Test TS
32+
run: npm run test:ts

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ examples/
77
typings
88
test/
99
CHANGELOG.md
10+
prettier.config.js
11+
eslint.config.js

.prettierrc.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
{
8+
"name": "Attach",
9+
"port": 9229,
10+
"request": "attach",
11+
"skipFiles": [
12+
"<node_internals>/**"
13+
],
14+
"type": "node"
15+
},
716
{
817
"type": "node",
918
"request": "launch",
1019
"name": "Launch demo",
1120
"program": "${workspaceRoot}\\examples\\index.js",
1221
"cwd": "${workspaceRoot}",
1322
"args": [
14-
"full"
23+
"simple"
1524
]
1625
},
1726
{

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
<a name="0.4.0"></a>
2+
# 0.4.0 (2025-09-25)
3+
4+
## Breaking Changes
5+
- **Apollo Server 5**: Upgraded from Apollo Server 2 to Apollo Server 5
6+
- **Node.js Requirements**: Now requires Node.js >= 20.x.x (updated from >= 10.x)
7+
- **File Upload Removal**: Removed GraphQL file upload support because [Apollo Server 3+ no longer supports it](https://www.apollographql.com/docs/apollo-server/v3/migration#file-uploads).
8+
- **Healthcheck Removal**: Built-in healthcheck endpoint removed because [Apollo Server 4+ no longer supports it](https://www.apollographql.com/docs/apollo-server/migration-from-v3#health-checks).
9+
- **WebSocket Subscriptions**: Rewritten subscription function from `graphql-subscriptions` to `graphql-ws`.
10+
- **Move from GraphQL Playground to Apollo Sandbox**: Apollo Server 3+ removes the GraphQL Playground. [It supports Apollo Sandbox.](https://www.apollographql.com/docs/apollo-server/v3/migration#graphql-playground)
11+
12+
## Major Updates
13+
- **Modern Tooling**: Migrated from legacy ESLint config to flat config format
14+
- **GitHub Actions**: Updated CI workflow to use latest GitHub Actions (v4) and test on Node.js 20.x, 22.x, 24.x
15+
- **Dependencies**: Updated all dependencies to latest compatible versions
16+
- **Configuration**: Replaced `.eslintrc.js` and `.prettierrc.js` with modern `eslint.config.js` and `prettier.config.js`
17+
- **Async Methods**: Made `makeExecutableSchema` and `generateGraphQLSchema` methods async for better async/await support
18+
- **Preparation**: Improved GraphQL schema preparation with promise-based mechanism to prevent multiple concurrent preparations
19+
20+
## Removed Features
21+
- Removed file upload examples and documentation
22+
- Removed legacy Apollo Server 2/3 configuration options
23+
24+
## Documentation
25+
- Updated README.md to reflect Apollo Server 5 compatibility
26+
- Improved examples and removed outdated features
27+
28+
## Typescript types
29+
- Improved Typescript d.ts file
30+
- Exported helper interfaces `ApolloServiceSettings`, `ApolloServiceMethods`, `ApolloServiceLocalVars` to support Moleculer 0.15 Service generics.
31+
- Augmented Moleculer `ActionSchema` with graphql property.
32+
- Typescript CI tests.
33+
34+
--------------------------------------------------
135
<a name="0.3.8"></a>
236
# 0.3.8 (2023-04-23)
337

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).

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 MoleculerJS
3+
Copyright (c) 2025 MoleculerJS
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)