Commit 004f68e
authored
feat: compute static costs (#1359)
First release of essential features for the static cost analysis on
fields, lists.
All parameters of "cost" and "listSize" directives are supported, except
for "sizedFields":
* "cost" and "listSize" directives on fields of various types
* variables passed as values to argumets
* interfaces and unions, lists
## Notes
Planning visitor collects information for the costCalculator via
EnterField and LeaveField hooks.
Calculator builds a tree of nodes, each node corresponding to the
requested field.
After the planning is done, a callee could get a ref to the calculator
and request cost calculation.
Cost calculation walks the previously built tree and using variables
provided with operation,
estimates the static cost.
It builds on top of IBM spec for @cost and @listsize directive with a
few changes:
* It uses Int! for weights instead of stringified floats.
* When weight is specified for the type and a field returns the list of
that type,
this weight (along with children's costs) is multiplied too.
A few things on the TBD list:
* Support of SizedFields of @listsize
* Weights on fields of InputObjects with recursion
* Weights on arguments of directives
Fixes ENG-87321 parent 29798be commit 004f68e
File tree
14 files changed
+2244
-99
lines changed- execution
- engine
- graphql
- v2/pkg
- ast
- engine
- plan
- resolve
14 files changed
+2244
-99
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | 41 | | |
48 | 42 | | |
49 | 43 | | |
| |||
194 | 188 | | |
195 | 189 | | |
196 | 190 | | |
197 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
198 | 195 | | |
199 | 196 | | |
200 | 197 | | |
| |||
210 | 207 | | |
211 | 208 | | |
212 | 209 | | |
213 | | - | |
| 210 | + | |
214 | 211 | | |
215 | 212 | | |
216 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
| 239 | + | |
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
| 253 | + | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
| 265 | + | |
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| |||
0 commit comments