Commit f478f3d
committed
Fix exponential time complexity in AliasArguments with circular type references
**Problem:**
`getAliasesInFields()` traverses ALL possible fields in the type schema, not just fields present in the request data. With circular type references (e.g., PageInput ↔ SectionInput) and a depth limit calculated from request data, this causes exponential traversal.
**Evidence:**
- Mutations taking 11+ seconds instead of milliseconds
- Logging showed 6 million recursive calls before timeout
- Depth reaching 12-13 levels with circular paths
**Solution:**
Only traverse fields that exist in the actual request data. This prevents exponential explosion while preserving full alias functionality.
**Performance:**
- Before: 11+ seconds per mutation
- After: ~150ms per mutation
- Improvement: 98.7% reduction
**Testing:**
- Tested with deeply nested input types (11 levels)
- Tested with circular type references
- Verified alias functionality preserved (deprecated field name mapping)
- Verified legitimate nested types work (e.g., Page->translations array)1 parent 3666481 commit f478f3d
1 file changed
+44
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
63 | 75 | | |
64 | 76 | | |
65 | 77 | | |
| |||
69 | 81 | | |
70 | 82 | | |
71 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
72 | 90 | | |
73 | 91 | | |
74 | 92 | | |
| |||
91 | 109 | | |
92 | 110 | | |
93 | 111 | | |
94 | | - | |
| 112 | + | |
| 113 | + | |
95 | 114 | | |
96 | 115 | | |
97 | 116 | | |
| |||
101 | 120 | | |
102 | 121 | | |
103 | 122 | | |
104 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
105 | 145 | | |
106 | 146 | | |
107 | 147 | | |
| |||
0 commit comments