@rytass/wms-module-graphql 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -78,7 +78,7 @@ mkdir my-wms && cd my-wms
78
78
  pnpm init
79
79
  pnpm add @rytass/wms-module-core @rytass/wms-module-graphql @rytass/wms-module-react
80
80
  pnpm add @nestjs/common @nestjs/core @nestjs/graphql @nestjs/typeorm \
81
- @nestjs/apollo @nestjs/config @nestjs/platform-express @apollo/server@^4 \
81
+ @nestjs/apollo@~13.1.0 @nestjs/config @nestjs/platform-express @apollo/server@^4 \
82
82
  typeorm pg reflect-metadata graphql rxjs \
83
83
  class-transformer class-validator \
84
84
  @as-integrations/express5
@@ -191,6 +191,21 @@ What you get from this single `forRootAsync`:
191
191
  - DataLoader N+1 prevention across every resolveField
192
192
  - Default seed rows (DEFAULT location, DEFAULT loaderType, DEFAULT loader) on first boot
193
193
 
194
+ **`forRootAsync` TypeScript signature**:
195
+
196
+ ```ts
197
+ WmsModuleGraphqlModule.forRootAsync(
198
+ options: WmsModuleCoreModuleAsyncOptions,
199
+ gqlOptions: GqlModuleAsyncOptions<ApolloDriverConfig>,
200
+ ): DynamicModule
201
+ ```
202
+
203
+ > Note the **two positional arguments**. A common mistake is to pass a single options object
204
+ > (matching NestJS's typical convention) which produces a misleading
205
+ > `TypeError: Cannot read properties of undefined (reading 'imports')` from inside the lib.
206
+ > The first arg configures the WMS core module (seed defaults, async factory, etc.); the
207
+ > second arg configures the underlying NestJS GraphQL module (driver, autoSchemaFile, plugins).
208
+
194
209
  See [API Reference - wms-module-graphql](./api-reference.md) for the full `forRootAsync` signature.
195
210
 
196
211
  ### 4.3 `.env`
@@ -284,7 +299,7 @@ Tested combinations as of 0.1.2:
284
299
  |----------------------------------|-------------------------|--------------------------------------------------------------------|
285
300
  | NestJS (`@nestjs/*`) | 11.x | 10.x untested; some Express-5-related APIs differ |
286
301
  | `@nestjs/graphql` | 13.x | Required for `@nestjs/apollo@13` |
287
- | `@nestjs/apollo` | 13.x | Pairs with Apollo Server 4 + Express 5 |
302
+ | `@nestjs/apollo` | 13.0.x – 13.1.x | 13.2+ requires @apollo/server@^5 which breaks lib's v4 plugin usage |
288
303
  | `@apollo/server` | 4.x | v5 is breaking; not supported |
289
304
  | `@as-integrations/express5` | 1.x | Required runtime peer |
290
305
  | TypeORM | 0.3.x | 0.2.x not supported (different DataSource API) |
@@ -1072,11 +1087,17 @@ logic. Any field set on `req` by a NestJS guard or Passport strategy (e.g. `req.
1072
1087
  therefore accessible from resolvers as `ctx.req.user`.
1073
1088
 
1074
1089
  > **Why returning `context` from `gqlOptions.useFactory` does not work**: the lib's
1075
- > `forRootAsync` calls `gqlOptions.useFactory(…)` to collect your Apollo options, then
1076
- > unconditionally replaces the `context` key with its own factory that injects DataLoaders
1077
- > (`{ loaders, ...contextArg }`). Any `context` you return from `useFactory` is silently
1078
- > dropped. The resulting GraphQL context is always `{ req, res, loaders }` — there is no
1079
- > `user` key.
1090
+ > internal context factory replaces any `context` key you return from `gqlOptions.useFactory`,
1091
+ > but it spreads the raw `contextArg` (the `{ req, res }` provided by Apollo Server). So:
1092
+ >
1093
+ > | Approach | Works? |
1094
+ > |----------------------------------------------------|--------|
1095
+ > | Return `context: () => ({ user })` from useFactory | ❌ overridden |
1096
+ > | Populate `req.user` via NestJS guard / Passport | ✅ access via `context.req.user` |
1097
+ >
1098
+ > Always populate identity onto `req` (via a guard) and read it as `context.req.user` in
1099
+ > your resolvers. The resulting GraphQL context is `{ req, res, loaders }` — `req.user` IS
1100
+ > accessible as long as a guard or middleware has set it on the request object.
1080
1101
 
1081
1102
  To access the authenticated user in a **custom** resolver, populate `req.user` in a guard
1082
1103
  or middleware and read it from `ctx.req.user`:
@@ -1267,6 +1288,13 @@ function WmsLayout({ children }: { children: ReactNode }): ReactNode {
1267
1288
  }
1268
1289
  ```
1269
1290
 
1291
+ > **Critical constraint**: WMS page components use the `NextPath` enum for all internal
1292
+ > navigation (`router.push(NextPath.MATERIALSMANAGEMENT)` etc.). Enum values are hardcoded
1293
+ > root-level paths (`/materials-management`, `/inventory-list`, etc.). **WMS pages cannot be
1294
+ > mounted under a custom path prefix like `/wms/*`** — internal links will break even though
1295
+ > the pages initially render. If your existing project requires path prefixing, you must mount
1296
+ > WMS at the root of a separate domain or subdomain.
1297
+
1270
1298
  The lib's page components do not require the WMS navigation shell to be present — they only
1271
1299
  require the three providers (§13.7) and an Apollo client (§13.6). You can completely replace
1272
1300
  the navigation chrome with your own.
@@ -1495,6 +1523,40 @@ creating a new monorepo. Key points:
1495
1523
  `@rytass/wms-module-*` package names, ensure they point to `node_modules` (the installed
1496
1524
  package), not local source, to avoid confusion.
1497
1525
 
1526
+ ### 13.13.1 pnpm peer-dep multi-instantiation hazard
1527
+
1528
+ When a pnpm workspace contains apps that resolve `@nestjs/core` (or other peers
1529
+ of `@rytass/wms-module-core`) to different major versions, pnpm creates one
1530
+ **instance** of `@rytass/wms-module-core` per unique peer resolution. Both
1531
+ instances register their TypeORM entity decorators against the same global
1532
+ `getMetadataArgsStorage()`, producing:
1533
+
1534
+ ```
1535
+ TypeError: Cannot read properties of undefined (reading 'ownColumns')
1536
+ at EntityMetadataBuilder.ts:548
1537
+ ```
1538
+
1539
+ **Required workaround**: every workspace app that imports `@rytass/wms-module-core`
1540
+ (directly or transitively via `@rytass/wms-module-graphql`) must resolve to the
1541
+ same `@nestjs/*` major version. Options:
1542
+
1543
+ 1. Upgrade the entire workspace to a single NestJS major (preferred)
1544
+ 2. Force pnpm to deduplicate the WMS module instance:
1545
+
1546
+ ```yaml
1547
+ # pnpm-workspace.yaml
1548
+ overrides:
1549
+ '@rytass/wms-module-core': '0.1.4'
1550
+ ```
1551
+
1552
+ 3. Apply `public-hoist-pattern[]` for `@rytass/wms-module-*` in `.npmrc`
1553
+
1554
+ This is a structural limitation of the pnpm peer-resolution model combined
1555
+ with TypeORM's global metadata storage; the WMS lib cannot deduplicate
1556
+ itself without rewriting TypeORM's entity registry. Yarn 4 and npm 10 do not
1557
+ hit this because their hoisting strategies differ — pnpm with strict mode is
1558
+ the only affected case.
1559
+
1498
1560
  ---
1499
1561
 
1500
1562
  ### 13.14 GraphQL Type Name Conflicts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rytass/wms-module-graphql",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Rytass WMS Module — GraphQL schema, resolvers and DTOs for warehouse management",
5
5
  "keywords": [
6
6
  "rytass",
@@ -46,10 +46,10 @@
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@as-integrations/express5": "^1.0.0",
49
- "@nestjs/apollo": "^13.0.0",
49
+ "@nestjs/apollo": ">=13.0.0 <13.2.0",
50
50
  "@nestjs/common": "^11.0.0",
51
51
  "@nestjs/graphql": "^13.0.0",
52
- "@rytass/wms-module-core": "^0.1.3",
52
+ "@rytass/wms-module-core": "^0.1.4",
53
53
  "graphql": "^16.0.0",
54
54
  "reflect-metadata": "^0.1.13 || ^0.2.0",
55
55
  "rxjs": "^7.8.0"