Skip to content

Commit

Permalink
fix #2485 Defined type from a basic type should not need scalar (#2486)
Browse files Browse the repository at this point in the history
* fix #2485 remote named basics should not need scalar

* following review

* better way to compare basic type
  • Loading branch information
mstephano authored Jan 13, 2023
1 parent 43c9a1d commit 867b61a
Show file tree
Hide file tree
Showing 15 changed files with 1,056 additions and 31 deletions.
11 changes: 10 additions & 1 deletion _examples/scalars/external/model.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
package external

type ObjectID int
type (
ObjectID int
Manufacturer string // remote named string
)

const (
ManufacturerTesla Manufacturer = "TESLA"
ManufacturerHonda Manufacturer = "HONDA"
ManufacturerToyota Manufacturer = "TOYOTA"
)
225 changes: 225 additions & 0 deletions _examples/scalars/generated.go

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

27 changes: 17 additions & 10 deletions _examples/scalars/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import (
"github.com/99designs/gqlgen/graphql"
)

type Banned bool
type (
Banned bool
LoginBanned bool
QueryBanned = bool
)

func (b Banned) MarshalGQL(w io.Writer) {
if b {
Expand All @@ -36,15 +40,18 @@ func (b *Banned) UnmarshalGQL(v interface{}) error {
}

type User struct {
ID external.ObjectID
Name string
Created time.Time // direct binding to builtin types with external Marshal/Unmarshal methods
Modified *time.Time // direct binding to builtin types with external Marshal/Unmarshal methods
ValPrefs Prefs // external un/marshal that act on pointers
PtrPrefs *Prefs
IsBanned Banned
Address Address
Tier Tier
ID external.ObjectID
Name string
Created time.Time // direct binding to builtin types with external Marshal/Unmarshal methods
Modified *time.Time // direct binding to builtin types with external Marshal/Unmarshal methods
ValPrefs Prefs // external un/marshal that act on pointers
PtrPrefs *Prefs
IsBanned Banned
IsLoginBanned LoginBanned
IsQueryBanned QueryBanned
Address Address
Tier Tier
CarManufacturer external.Manufacturer
}

// Point is serialized as a simple array, eg [1, 2]
Expand Down
Loading

0 comments on commit 867b61a

Please sign in to comment.