and then in .gqlgen.yml point to the name without the Marshal|Unmarshal in front:

models:YesNo:model:github.com/me/mypkg.YesNo

Custom scalars for types you don’t control

Sometimes you cant add methods to a type because its in another repo, part of the standard
library (eg string or time.Time). To do this we can build an external marshaler:

packagemypkgimport("fmt""io""strings""github.com/99designs/gqlgen/graphql")funcMarshalMyCustomBooleanScalar(bbool)graphql.Marshaler{returngraphql.WriterFunc(func(wio.Writer){ifb{w.Write([]byte("true"))}else{w.Write([]byte("false"))}})}funcUnmarshalMyCustomBooleanScalar(vinterface{})(bool,error){switchv:=v.(type){casestring:return"true"==strings.ToLower(v),nilcaseint:returnv!=0,nilcasebool:returnv,nildefault:returnfalse,fmt.Errorf("%T is not a bool",v)}}

and then in .gqlgen.yml point to the name without the Marshal|Unmarshal in front: