Optimize should be skippable - add new lifecycle method
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 625
- Avg merge
- 5h 23m
- Merged PRs (30d)
- 24
Description
Optimize is generally used for optimizing steps (e.g. eliminating them by having ancestors do their work for them, or similar); however it's sometimes also used for sending information up the tree where there is no other appropriate time to do it (i.e. data that can't be sent until the full tree is established - like "do I need to load cursors or not" isn't known until we see whether anyone accessed the cursor fields or not).
Here's an example:
https://github.com/graphile/crystal/blob/b72034ffcd651238c25b268596349af856749682/grafast/grafast/src/steps/load.ts#L189-L193
Saying about the attributes is an optimization (without it, all attributes would be loaded); but saying about the params is _required_ - without it we might not be applying the right filters/etc.
We should add a new lifecycle method that does these essential tree-walking steps before optimize is called. Maybe at the end of plan before or just slightly after tree shaking? (Note: refs should be retained for this.)
Contributor guide
Assessment
This issue has not been assessed yet.