Commit f808084
authored
fix(replaceVariables): preserve sources for fragment variable values (#4389)
The new flow for coercing input literals -- see
#3814 -- introduces a
`replaceVariables()` prior to calling `coerceInputLiteral()` such that
we go:
from `ValueNode` => `ConstValueNode` => coerced value
The main advantages being that:
(1) we can trivially support embedding variables within complex scalars
-- despite this being non-spec defined behavior!
(2) userland implementations of custom scalar `coerceInputLiteral()`
methods do not need to worry about handling variables or fragment
variables.
Prior to this PR, we did not properly handle this in the case of
fragment definition variables/fragment spread arguments.
`replaceVariableValues()` assumes that the uncoerced value is preserved
as source, but instead of grabbing this value from the argument on the
spread, we were incorrectly attempting to retrieve the already stored
value from existing variables.
This was not caught because we previously did not have any actual tests
for this custom unspecified behavior and were using incorrect types and
bespoke builders in our tests for `replaceVariables()`.
This PR:
(a) fixes the bug by storing the argument from the spread
(b) fixes our bespoke builders in `replaceVariables()`
(c) add explicit tests for embedding variables within custom scalars to
protect against future changes.
As a post-script, because within `getFragmentVariableValues()` we now
end up within a `ValueNode` stored on source, to coerce this value, we
can extract a new helper `coerceArgumentValue()` from
`experimentalGetArgumentValues()`, rather than calling it after we are
done for all the values, which has some additional overhead.
This has the side benefit of removing the need for a separate
`experimentalGetArgumentValues()` function altogether. We initially
introduced it to have a more flexible signature for
`getArgumentValues()` that encompasses argument for fragment spreads,
but now this is taken care of using our more directed helper.1 parent 5e62c43 commit f808084
File tree
8 files changed
+337
-138
lines changed- src
- execution
- __tests__
- utilities
- __tests__
8 files changed
+337
-138
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
67 | 79 | | |
68 | 80 | | |
69 | 81 | | |
| |||
151 | 163 | | |
152 | 164 | | |
153 | 165 | | |
| 166 | + | |
154 | 167 | | |
155 | 168 | | |
156 | 169 | | |
| |||
859 | 872 | | |
860 | 873 | | |
861 | 874 | | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
862 | 963 | | |
863 | 964 | | |
864 | 965 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | | - | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
38 | 50 | | |
39 | 51 | | |
40 | 52 | | |
41 | | - | |
| 53 | + | |
42 | 54 | | |
43 | 55 | | |
44 | 56 | | |
| |||
168 | 180 | | |
169 | 181 | | |
170 | 182 | | |
171 | | - | |
| 183 | + | |
172 | 184 | | |
173 | 185 | | |
174 | 186 | | |
| |||
273 | 285 | | |
274 | 286 | | |
275 | 287 | | |
276 | | - | |
| 288 | + | |
277 | 289 | | |
278 | 290 | | |
279 | 291 | | |
| |||
318 | 330 | | |
319 | 331 | | |
320 | 332 | | |
321 | | - | |
| 333 | + | |
322 | 334 | | |
323 | 335 | | |
324 | 336 | | |
| |||
351 | 363 | | |
352 | 364 | | |
353 | 365 | | |
354 | | - | |
| 366 | + | |
355 | 367 | | |
356 | 368 | | |
357 | 369 | | |
| |||
361 | 373 | | |
362 | 374 | | |
363 | 375 | | |
364 | | - | |
| 376 | + | |
| 377 | + | |
365 | 378 | | |
366 | | - | |
367 | 379 | | |
368 | 380 | | |
369 | 381 | | |
| |||
381 | 393 | | |
382 | 394 | | |
383 | 395 | | |
384 | | - | |
| 396 | + | |
| 397 | + | |
385 | 398 | | |
386 | | - | |
387 | 399 | | |
388 | 400 | | |
389 | 401 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
89 | 88 | | |
90 | 89 | | |
91 | 90 | | |
| |||
877 | 876 | | |
878 | 877 | | |
879 | 878 | | |
880 | | - | |
| 879 | + | |
| 880 | + | |
881 | 881 | | |
882 | | - | |
883 | 882 | | |
884 | 883 | | |
885 | 884 | | |
| |||
2298 | 2297 | | |
2299 | 2298 | | |
2300 | 2299 | | |
| 2300 | + | |
2301 | 2301 | | |
2302 | 2302 | | |
2303 | 2303 | | |
| |||
0 commit comments