From 563fdaba9c9997cdbaa33035478c83860a67a4a9 Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Tue, 17 Nov 2020 11:44:29 -0500 Subject: [PATCH] Fix shared fields in m2a fetch --- api/src/utils/get-ast-from-query.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/utils/get-ast-from-query.ts b/api/src/utils/get-ast-from-query.ts index 205f84e23e..32fbf970cc 100644 --- a/api/src/utils/get-ast-from-query.ts +++ b/api/src/utils/get-ast-from-query.ts @@ -143,8 +143,6 @@ export default async function getASTFromQuery( } } - console.log(relationalStructure); - for (const [relationalField, nestedFields] of Object.entries(relationalStructure)) { const relatedCollection = getRelatedCollection(parentCollection, relationalField); const relation = getRelation(parentCollection, relationalField); @@ -185,7 +183,9 @@ export default async function getASTFromQuery( for (const relatedCollection of allowedCollections) { child.children[relatedCollection] = await parseFields( relatedCollection, - (nestedFields as anyNested)[relatedCollection] || null + Array.isArray(nestedFields) + ? nestedFields + : (nestedFields as anyNested)[relatedCollection] || ['*'] ); child.query[relatedCollection] = {}; child.relatedKey[relatedCollection] = schema[relatedCollection].primary;