nullability says whether a field's value can be null, or for input fields, whether the field is required.
(t *ast.Type, input bool)
| 183 | // nullability says whether a field's value can be null, or for input fields, |
| 184 | // whether the field is required. |
| 185 | func nullability(t *ast.Type, input bool) string { |
| 186 | if input { |
| 187 | if t.NonNull { |
| 188 | return "Required." |
| 189 | } |
| 190 | return "Optional." |
| 191 | } |
| 192 | s := "Can be null." |
| 193 | if t.NonNull { |
| 194 | s = "Never null." |
| 195 | } |
| 196 | if t.Elem != nil { |
| 197 | if t.Elem.NonNull { |
| 198 | s += " Items are never null." |
| 199 | } else { |
| 200 | s += " Items can be null." |
| 201 | } |
| 202 | } |
| 203 | return s |
| 204 | } |
| 205 | |
| 206 | func kindLabel(k ast.DefinitionKind) string { |
| 207 | switch k { |