Skip to content

Commit

Permalink
Return null if invalid enum is encountered
Browse files Browse the repository at this point in the history
  • Loading branch information
hemanthbollamreddi-cb committed Dec 18, 2023
1 parent 7dd971c commit d916f91
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugin/modelgen/models.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@
}

func (e {{ goModelName .Name }}) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(e.String()))
switch e.IsValid() {
case true:
fmt.Fprint(w, strconv.Quote(e.String()))
case false:
graphql.Null.MarshalGQL(w)
}
}

{{- end }}

0 comments on commit d916f91

Please sign in to comment.