Skip to content

Commit

Permalink
fix a TODO about named boolean under _examples/scalars
Browse files Browse the repository at this point in the history
  • Loading branch information
mstephano committed Dec 24, 2022
1 parent 99c63a0 commit b8eebbd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 47 deletions.
2 changes: 0 additions & 2 deletions _examples/scalars/.gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ models:
model: github.com/99designs/gqlgen/_examples/scalars/model.ID
Tier:
model: github.com/99designs/gqlgen/_examples/scalars/model.Tier
Banned:
model: github.com/99designs/gqlgen/_examples/scalars/model.Banned
DarkMode:
model: github.com/99designs/gqlgen/_examples/scalars/model.Preferences
47 changes: 26 additions & 21 deletions _examples/scalars/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions _examples/scalars/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,6 @@ import (

type Banned bool

func (b Banned) MarshalGQL(w io.Writer) {
if b {
w.Write([]byte("true"))
} else {
w.Write([]byte("false"))
}
}

func (b *Banned) UnmarshalGQL(v interface{}) error {
switch v := v.(type) {
case string:
*b = strings.ToLower(v) == "true"
return nil
case bool:
*b = Banned(v)
return nil
default:
return fmt.Errorf("%T is not a bool", v)
}
}

type User struct {
ID external.ObjectID
Name string
Expand Down
5 changes: 2 additions & 3 deletions _examples/scalars/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type User {
modified: Timestamp
valPrefs: DarkMode
ptrPrefs: DarkMode
isBanned: Banned!
isBanned: Boolean!
primitiveResolver: String!
customResolver: Point!
address: Address
Expand All @@ -27,7 +27,7 @@ type Address {
input SearchArgs {
location: Point
createdAfter: Timestamp
isBanned: Banned # TODO: This can be a Boolean again once multiple backing types are allowed
isBanned: Boolean
}

enum Tier {
Expand All @@ -38,5 +38,4 @@ enum Tier {

scalar Timestamp
scalar Point
scalar Banned
scalar DarkMode

0 comments on commit b8eebbd

Please sign in to comment.