Process page only when merging with parent items (#16010)

This commit is contained in:
ian
2022-10-15 01:18:27 +07:00
committed by GitHub
parent 03d65e8363
commit 9edf9f9ce0

View File

@@ -97,7 +97,11 @@ export default async function runAST(
while (hasMore) {
const node = merge({}, nestedNode, {
query: { limit: env.RELATIONAL_BATCH_SIZE, offset: batchCount * env.RELATIONAL_BATCH_SIZE },
query: {
limit: env.RELATIONAL_BATCH_SIZE,
offset: batchCount * env.RELATIONAL_BATCH_SIZE,
page: null,
},
});
nestedItems = (await runAST(node, schema, { knex, nested: true })) as Item[] | null;
@@ -350,6 +354,12 @@ function mergeWithParentItems(
parentItem[nestedNode.fieldKey].push(...itemChildren);
if (nestedNode.query.page && nestedNode.query.page > 1) {
parentItem[nestedNode.fieldKey] = parentItem[nestedNode.fieldKey].slice(
(nestedNode.query.limit ?? 100) * (nestedNode.query.page - 1)
);
}
if (nestedNode.query.offset && nestedNode.query.offset >= 0) {
parentItem[nestedNode.fieldKey] = parentItem[nestedNode.fieldKey].slice(nestedNode.query.offset);
}