@lenne.tech/nest-server 10.8.3 → 10.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nest-server",
3
- "version": "10.8.3",
3
+ "version": "10.8.4",
4
4
  "description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
5
5
  "keywords": [
6
6
  "node",
@@ -332,6 +332,21 @@ export function getPopulateOptions(info: GraphQLResolveInfo, dotSeparatedSelect?
332
332
  return result;
333
333
  }
334
334
 
335
+ /**
336
+ * Get next field nodes
337
+ */
338
+ export function getNextFieldNodes(nodes: readonly SelectionNode[]): FieldNode[] {
339
+ const result = [];
340
+ for (const node of nodes as FieldNode[]) {
341
+ if (node.name?.value) {
342
+ result.push(node);
343
+ } else if (node.selectionSet?.selections) {
344
+ result.push(...getNextFieldNodes(node.selectionSet.selections));
345
+ }
346
+ }
347
+ return result;
348
+ }
349
+
335
350
  /**
336
351
  * Get populate options from selections
337
352
  */
@@ -342,10 +357,19 @@ export function getPopulatOptionsFromSelections(selectionNodes: readonly Selecti
342
357
  return populateOptions;
343
358
  }
344
359
 
360
+ const nodes: FieldNode[] = [];
345
361
  for (const node of selectionNodes as FieldNode[]) {
362
+ if (node.name?.value) {
363
+ nodes.push(node);
364
+ } else if (node.selectionSet?.selections) {
365
+ nodes.push(...getNextFieldNodes(node.selectionSet.selections));
366
+ }
367
+ }
368
+
369
+ for (const node of nodes) {
346
370
  // Set main path
347
371
  const option: PopulateOptions = {
348
- path: node.name.value,
372
+ path: node.name?.value || '',
349
373
  };
350
374
 
351
375
  // Check for subfields