Fix shared fields in m2a fetch

This commit is contained in:
rijkvanzanten
2020-11-17 11:44:29 -05:00
parent 168e96ed03
commit 563fdaba9c

View File

@@ -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;