@sylphx/lens-server 2.3.0 → 2.3.2
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.
- package/dist/index.js +12 -2
- package/package.json +1 -1
- package/src/server/create.ts +15 -2
package/dist/index.js
CHANGED
|
@@ -313,8 +313,17 @@ class LensServerImpl {
|
|
|
313
313
|
}
|
|
314
314
|
this.queries = queries;
|
|
315
315
|
this.mutations = mutations;
|
|
316
|
-
this.entities = config.entities ?? {};
|
|
317
316
|
this.resolverMap = config.resolvers ? toResolverMap(config.resolvers) : undefined;
|
|
317
|
+
const entities = { ...config.entities ?? {} };
|
|
318
|
+
if (config.resolvers) {
|
|
319
|
+
for (const resolver of config.resolvers) {
|
|
320
|
+
const entityName = resolver.entity._name;
|
|
321
|
+
if (entityName && !entities[entityName]) {
|
|
322
|
+
entities[entityName] = resolver.entity;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
this.entities = entities;
|
|
318
327
|
this.contextFactory = config.context ?? (() => ({}));
|
|
319
328
|
this.version = config.version ?? "1.0.0";
|
|
320
329
|
this.logger = config.logger ?? noopLogger;
|
|
@@ -450,7 +459,8 @@ class LensServerImpl {
|
|
|
450
459
|
}
|
|
451
460
|
});
|
|
452
461
|
};
|
|
453
|
-
const
|
|
462
|
+
const isArrayOutput = Array.isArray(def._output);
|
|
463
|
+
const emit = createEmit(emitHandler, isArrayOutput);
|
|
454
464
|
const onCleanup = (fn) => {
|
|
455
465
|
cleanups.push(fn);
|
|
456
466
|
return () => {
|
package/package.json
CHANGED
package/src/server/create.ts
CHANGED
|
@@ -136,8 +136,19 @@ class LensServerImpl<
|
|
|
136
136
|
|
|
137
137
|
this.queries = queries as Q;
|
|
138
138
|
this.mutations = mutations as M;
|
|
139
|
-
this.entities = config.entities ?? {};
|
|
140
139
|
this.resolverMap = config.resolvers ? toResolverMap(config.resolvers) : undefined;
|
|
140
|
+
|
|
141
|
+
// Build entities map: explicit config + auto-extracted from resolvers
|
|
142
|
+
const entities: EntitiesMap = { ...(config.entities ?? {}) };
|
|
143
|
+
if (config.resolvers) {
|
|
144
|
+
for (const resolver of config.resolvers) {
|
|
145
|
+
const entityName = resolver.entity._name;
|
|
146
|
+
if (entityName && !entities[entityName]) {
|
|
147
|
+
entities[entityName] = resolver.entity;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
this.entities = entities;
|
|
141
152
|
this.contextFactory = config.context ?? (() => ({}) as TContext);
|
|
142
153
|
this.version = config.version ?? "1.0.0";
|
|
143
154
|
this.logger = config.logger ?? noopLogger;
|
|
@@ -344,7 +355,9 @@ class LensServerImpl<
|
|
|
344
355
|
});
|
|
345
356
|
};
|
|
346
357
|
|
|
347
|
-
|
|
358
|
+
// Detect array output type: [EntityDef] is stored as single-element array
|
|
359
|
+
const isArrayOutput = Array.isArray(def._output);
|
|
360
|
+
const emit = createEmit(emitHandler, isArrayOutput);
|
|
348
361
|
const onCleanup = (fn: () => void) => {
|
|
349
362
|
cleanups.push(fn);
|
|
350
363
|
return () => {
|