github.com/99designs/gqlgen@v0.17.45/codegen/testserver/singlefile/maps.go (about) 1 package singlefile 2 3 import ( 4 "io" 5 "strconv" 6 ) 7 8 type MapNested struct { 9 Value CustomScalar 10 } 11 12 type CustomScalar struct { 13 value int64 14 } 15 16 func (s *CustomScalar) UnmarshalGQL(v interface{}) (err error) { 17 switch v := v.(type) { 18 case string: 19 s.value, err = strconv.ParseInt(v, 10, 64) 20 case int64: 21 s.value = v 22 } 23 return 24 } 25 26 func (s CustomScalar) MarshalGQL(w io.Writer) { 27 _, _ = w.Write([]byte(strconv.Quote(strconv.FormatInt(s.value, 10)))) 28 }