You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `Omittable[T]` type provides a more type-safe alternative to maps for distinguishing between unset, null, and actual values. It's a generic wrapper that tracks both the value and whether it was explicitly provided.
98
+
99
+
You can enable omittable fields in two ways:
100
+
101
+
**Option 1: Per-field with directive**
102
+
```graphql
103
+
inputUserChanges {
104
+
name: String@goField(omittable: true)
105
+
email: String@goField(omittable: true)
106
+
}
107
+
```
108
+
109
+
**Option 2: Globallyinconfig**
110
+
```yaml
111
+
# gqlgen.yml
112
+
nullable_input_omittable: true
113
+
```
114
+
115
+
This generates a Go struct using `graphql.Omittable`:
116
+
117
+
```go
118
+
typeUserChangesstruct {
119
+
Name graphql.Omittable[*string] `json:"name,omitempty"`
0 commit comments