Skip to content

Commit 3a458c3

Browse files
committed
Updated RFC doc: explanation on required vs nullable
1 parent 2dc2df2 commit 3a458c3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

rfcs/FragmentArguments.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,28 @@ fragment Bar($x: Int!) on User {
286286
}
287287
```
288288

289+
### Potential Alternative: Default Value indicates _required or not_, and `!` indicates _non-null or nullable_.
290+
291+
If we were writing the language from scratch, I'd advocate for making _all_
292+
argument definitions without a default value to be required, regardless of their
293+
nullability. If you want to make a nullable argument optional, you do so by
294+
adding a `= null` to its definition.
295+
296+
In short, if I define:
297+
298+
```
299+
fragment Bar($x: Int) { number(x: $x) }
300+
```
301+
302+
then `...Bar` would be **invalid**.
303+
304+
However, that's not how operation variables, field arguments, directive
305+
arguments or input object fields work today, no matter how much I might wish it.
306+
For this RFC, I'm making the meaning of "required" and "nullable" for fragment
307+
spread arguments the same as all other inputs, because doing something
308+
_different_ would be more confusing IMO, even if that difference would lead to
309+
unvalidated fewer foot guns.
310+
289311
## Updated Validation: Overlapping Fields Can Be Merged
290312

291313
Previously, fragment spreads didn't have to be considered as unique selections

0 commit comments

Comments
 (0)