...
1 package followschema
2
3 import (
4 "fmt"
5 "io"
6 "strconv"
7
8 "github.com/99designs/gqlgen/graphql"
9 )
10
11 type ThirdParty struct {
12 str string
13 }
14
15 func MarshalThirdParty(tp ThirdParty) graphql.Marshaler {
16 return graphql.WriterFunc(func(w io.Writer) {
17 _, err := io.WriteString(w, strconv.Quote(tp.str))
18 if err != nil {
19 panic(err)
20 }
21 })
22 }
23
24 func UnmarshalThirdParty(input interface{}) (ThirdParty, error) {
25 switch input := input.(type) {
26 case string:
27 return ThirdParty{str: input}, nil
28 default:
29 return ThirdParty{}, fmt.Errorf("unknown type for input: %s", input)
30 }
31 }
32
View as plain text