Skip to content

Commit

Permalink
Revert mstephano #2486 #2508 #2528
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Coffman <steve@khanacademy.org>
  • Loading branch information
StevenACoffman committed Mar 20, 2023
1 parent 05500c9 commit 9dbafba
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 2,504 deletions.
8 changes: 0 additions & 8 deletions _examples/scalars/.gqlgen.yml
Expand Up @@ -18,11 +18,3 @@ models:
model: github.com/99designs/gqlgen/_examples/scalars/model.Banned
DarkMode:
model: github.com/99designs/gqlgen/_examples/scalars/model.Preferences
Bytes:
model: "github.com/99designs/gqlgen/codegen/testserver/singlefile.Bytes"
Runes:
model: "github.com/99designs/gqlgen/_examples/scalars/model.Runes"
DefinedTypeBytes:
model: "github.com/99designs/gqlgen/_examples/scalars/external.Bytes"
DefinedTypeRunes:
model: "github.com/99designs/gqlgen/_examples/scalars/external.Runes"
59 changes: 1 addition & 58 deletions _examples/scalars/external/model.go
@@ -1,60 +1,3 @@
package external

import (
"fmt"
"io"

"github.com/99designs/gqlgen/graphql"
)

type (
ObjectID int
Manufacturer string // remote named string
Count uint8 // remote named uint8
ExternalBytes []byte
ExternalRunes []rune
)

const (
ManufacturerTesla Manufacturer = "TESLA"
ManufacturerHonda Manufacturer = "HONDA"
ManufacturerToyota Manufacturer = "TOYOTA"
)

func MarshalBytes(b ExternalBytes) graphql.Marshaler {
return graphql.WriterFunc(func(w io.Writer) {
_, _ = fmt.Fprintf(w, "%q", string(b))
})
}

func UnmarshalBytes(v interface{}) (ExternalBytes, error) {
switch v := v.(type) {
case string:
return ExternalBytes(v), nil
case *string:
return ExternalBytes(*v), nil
case ExternalBytes:
return v, nil
default:
return nil, fmt.Errorf("%T is not ExternalBytes", v)
}
}

func MarshalRunes(r ExternalRunes) graphql.Marshaler {
return graphql.WriterFunc(func(w io.Writer) {
_, _ = fmt.Fprintf(w, "%q", string(r))
})
}

func UnmarshalRunes(v interface{}) (ExternalRunes, error) {
switch v := v.(type) {
case string:
return ExternalRunes(v), nil
case *string:
return ExternalRunes(*v), nil
case ExternalRunes:
return v, nil
default:
return nil, fmt.Errorf("%T is not ExternalRunes", v)
}
}
type ObjectID int

0 comments on commit 9dbafba

Please sign in to comment.