// FIXME: Think of a generic way to express "only match fields under this specific child property" (+ direct descendants also?) -- maybe (node, property, parentNode) signature?
thrownewError(`You tried to add extra fields (${extraFieldNames.join(", ")}) in your query, but this is not possible when using collapseBy. See [FIXME: link] for more information, and how to solve this.`);
}elseif(onlyFields.length>0){
// NOTE: This can happen either because the user specified an onlyFields clause, *or* because a previous run of this optimizer did so!
// FIXME: Show alias target instead of field name here?
returnitem.field.name;
}else{
returnunreachable(`Encountered '${fieldType}' node in invalid fields`);
}
});
thrownewError(`You tried to include one or more field in your query (${invalidFieldNames.join(", ")}), that are not used in a collapseBy clause or aggregrate function. See [FIXME: link] for more information.`);
}else{
returnNoChange;
}
}else{
// TODO: Move compute -> alias/withResult conversion out into its own optimizer eventually, as it's a separate responsibility
// FIXME: a ConsumeNode marker, like RemoveNode but it does not invalidate that node's state... may need to actually make it a reference, so that a parent node can decide whether to consume that node. Basically passing a "consume this node" function as a state value, that correctly internally triggers the optimizer infrastructure to change the tree as a result.
// FIXME: Consume the compute nodes, and have an optimizer that removes empty computeMultiple nodes