Skip to content

Commit ec9b4ee

Browse files
committed
improve docs
1 parent 3148b27 commit ec9b4ee

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Writerside/topics/schema.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ type Organisation {
140140
</tr>
141141
</table>
142142

143+
> All interfaces, empty or not must be sealed for KSP to be able to traverse the possible implementations.
144+
{style="note"}
145+
143146
## Enums
144147

145148
Kotlin enums are mapped to GraphQL enums:
@@ -246,6 +249,38 @@ type Organisation {
246249
</tr>
247250
</table>
248251

252+
Use `Optional<>` anf `@GraphQLDefault` to further control your input values.
253+
254+
Note that because nullability vs optionality are so closely related in GraphQL, not all combination are allowed:
255+
256+
```
257+
type Query {
258+
// A non-null argument
259+
fun fieldA(arg: Int) = 0
260+
261+
// Disallowed: argument type is nullable and doesn't have a default value: it must also be optional.
262+
//fun fieldB(arg: Int?) = 0
263+
264+
// An nullable argument, the client may omit it in which case the function body must handle `Absent`.
265+
fun fieldC(arg: Optional<Int?>) = 0
266+
267+
// Disallowed: argument type is not nullable and cannot be optional
268+
//fun fieldD(arg: Optional<Int>) = 0
269+
270+
// An non-null argument, if the client omits it, the default value will be used.
271+
fun fieldE(@GraphQLDefault("10") arg: Int) = 0
272+
273+
// An nullable argument, if the client omits it, the default value will be used.
274+
fun fieldF(@GraphQLDefault("10") arg: Int?) = 0
275+
276+
// Disallowed: there is a default value and the argument type cannot be optional
277+
//fun fieldG(@GraphQLDefault("10") arg: Optional<Int?>) = 0
278+
279+
// Disallowed: there is a default value and the argument type cannot be optional
280+
//fun fieldH(@GraphQLDefault("10") arg: Optional<Int>) = 0
281+
}
282+
```
283+
249284
Kotlin parameters may be of class type in which case the class is generated as a GraphQL input object:
250285

251286
<table>

0 commit comments

Comments
 (0)