diff --git a/_examples/scalars/.gqlgen.yml b/_examples/scalars/.gqlgen.yml index 5dd5adfe53e..7980904575d 100644 --- a/_examples/scalars/.gqlgen.yml +++ b/_examples/scalars/.gqlgen.yml @@ -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" diff --git a/_examples/scalars/external/model.go b/_examples/scalars/external/model.go index db108a569e4..58046d786e2 100644 --- a/_examples/scalars/external/model.go +++ b/_examples/scalars/external/model.go @@ -1,18 +1,9 @@ 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 + ObjectID int + Manufacturer string // remote named string + Count uint32 // remote named uint32 ) const ( @@ -20,41 +11,3 @@ const ( 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) - } -} diff --git a/_examples/scalars/generated.go b/_examples/scalars/generated.go index dccfb2790ff..efd17113d1b 100644 --- a/_examples/scalars/generated.go +++ b/_examples/scalars/generated.go @@ -15,7 +15,6 @@ import ( "github.com/99designs/gqlgen/_examples/scalars/external" "github.com/99designs/gqlgen/_examples/scalars/model" - "github.com/99designs/gqlgen/codegen/testserver/singlefile" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" gqlparser "github.com/vektah/gqlparser/v2" @@ -74,11 +73,6 @@ type ComplexityRoot struct { Name func(childComplexity int) int PrimitiveResolver func(childComplexity int) int PtrPrefs func(childComplexity int) int - RemoteBytes func(childComplexity int) int - RemoteRunes func(childComplexity int) int - SomeBytes func(childComplexity int) int - SomeOtherBytes func(childComplexity int) int - SomeRunes func(childComplexity int) int Tier func(childComplexity int) int ValPrefs func(childComplexity int) int Weddings func(childComplexity int) int @@ -258,41 +252,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.PtrPrefs(childComplexity), true - case "User.remoteBytes": - if e.complexity.User.RemoteBytes == nil { - break - } - - return e.complexity.User.RemoteBytes(childComplexity), true - - case "User.remoteRunes": - if e.complexity.User.RemoteRunes == nil { - break - } - - return e.complexity.User.RemoteRunes(childComplexity), true - - case "User.someBytes": - if e.complexity.User.SomeBytes == nil { - break - } - - return e.complexity.User.SomeBytes(childComplexity), true - - case "User.someOtherBytes": - if e.complexity.User.SomeOtherBytes == nil { - break - } - - return e.complexity.User.SomeOtherBytes(childComplexity), true - - case "User.someRunes": - if e.complexity.User.SomeRunes == nil { - break - } - - return e.complexity.User.SomeRunes(childComplexity), true - case "User.tier": if e.complexity.User.Tier == nil { break @@ -649,16 +608,6 @@ func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field g return ec.fieldContext_User_cars(ctx, field) case "weddings": return ec.fieldContext_User_weddings(ctx, field) - case "someBytes": - return ec.fieldContext_User_someBytes(ctx, field) - case "someOtherBytes": - return ec.fieldContext_User_someOtherBytes(ctx, field) - case "someRunes": - return ec.fieldContext_User_someRunes(ctx, field) - case "remoteBytes": - return ec.fieldContext_User_remoteBytes(ctx, field) - case "remoteRunes": - return ec.fieldContext_User_remoteRunes(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -750,16 +699,6 @@ func (ec *executionContext) fieldContext_Query_search(ctx context.Context, field return ec.fieldContext_User_cars(ctx, field) case "weddings": return ec.fieldContext_User_weddings(ctx, field) - case "someBytes": - return ec.fieldContext_User_someBytes(ctx, field) - case "someOtherBytes": - return ec.fieldContext_User_someOtherBytes(ctx, field) - case "someRunes": - return ec.fieldContext_User_someRunes(ctx, field) - case "remoteBytes": - return ec.fieldContext_User_remoteBytes(ctx, field) - case "remoteRunes": - return ec.fieldContext_User_remoteRunes(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -851,16 +790,6 @@ func (ec *executionContext) fieldContext_Query_userByTier(ctx context.Context, f return ec.fieldContext_User_cars(ctx, field) case "weddings": return ec.fieldContext_User_weddings(ctx, field) - case "someBytes": - return ec.fieldContext_User_someBytes(ctx, field) - case "someOtherBytes": - return ec.fieldContext_User_someOtherBytes(ctx, field) - case "someRunes": - return ec.fieldContext_User_someRunes(ctx, field) - case "remoteBytes": - return ec.fieldContext_User_remoteBytes(ctx, field) - case "remoteRunes": - return ec.fieldContext_User_remoteRunes(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, @@ -1744,226 +1673,6 @@ func (ec *executionContext) fieldContext_User_weddings(ctx context.Context, fiel return fc, nil } -func (ec *executionContext) _User_someBytes(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_someBytes(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SomeBytes, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]byte) - fc.Result = res - return ec.marshalNBytes2ᚕbyte(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_User_someBytes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "User", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _User_someOtherBytes(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_someOtherBytes(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SomeOtherBytes, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]byte) - fc.Result = res - return ec.marshalNBytes2ᚕbyte(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_User_someOtherBytes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "User", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _User_someRunes(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_someRunes(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SomeRunes, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]rune) - fc.Result = res - return ec.marshalNRunes2ᚕrune(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_User_someRunes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "User", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Runes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _User_remoteBytes(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_remoteBytes(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.RemoteBytes, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(external.ExternalBytes) - fc.Result = res - return ec.marshalNDefinedTypeBytes2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐExternalBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_User_remoteBytes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "User", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type DefinedTypeBytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _User_remoteRunes(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_remoteRunes(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.RemoteRunes, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(external.ExternalRunes) - fc.Result = res - return ec.marshalNDefinedTypeRunes2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐExternalRunes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_User_remoteRunes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "User", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type DefinedTypeRunes does not have child fields") - }, - } - return fc, nil -} - func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Directive_name(ctx, field) if err != nil { @@ -4063,41 +3772,6 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj out.Values[i] = ec._User_weddings(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "someBytes": - - out.Values[i] = ec._User_someBytes(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "someOtherBytes": - - out.Values[i] = ec._User_someOtherBytes(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "someRunes": - - out.Values[i] = ec._User_someRunes(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "remoteBytes": - - out.Values[i] = ec._User_remoteBytes(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "remoteRunes": - - out.Values[i] = ec._User_remoteRunes(ctx, field, obj) - if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } @@ -4470,27 +4144,6 @@ func (ec *executionContext) marshalNBoolean2githubᚗcomᚋ99designsᚋgqlgenᚋ return res } -func (ec *executionContext) unmarshalNBytes2ᚕbyte(ctx context.Context, v interface{}) ([]byte, error) { - res, err := singlefile.UnmarshalBytes(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNBytes2ᚕbyte(ctx context.Context, sel ast.SelectionSet, v []byte) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - res := singlefile.MarshalBytes(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - func (ec *executionContext) unmarshalNDarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx context.Context, v interface{}) (*model.Prefs, error) { res, err := model.UnmarshalPreferences(v) return res, graphql.ErrorOnPath(ctx, err) @@ -4512,48 +4165,6 @@ func (ec *executionContext) marshalNDarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlge return res } -func (ec *executionContext) unmarshalNDefinedTypeBytes2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐExternalBytes(ctx context.Context, v interface{}) (external.ExternalBytes, error) { - res, err := external.UnmarshalBytes(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNDefinedTypeBytes2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐExternalBytes(ctx context.Context, sel ast.SelectionSet, v external.ExternalBytes) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - res := external.MarshalBytes(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalNDefinedTypeRunes2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐExternalRunes(ctx context.Context, v interface{}) (external.ExternalRunes, error) { - res, err := external.UnmarshalRunes(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNDefinedTypeRunes2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐExternalRunes(ctx context.Context, sel ast.SelectionSet, v external.ExternalRunes) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - res := external.MarshalRunes(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - func (ec *executionContext) unmarshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐObjectID(ctx context.Context, v interface{}) (external.ObjectID, error) { res, err := model.UnmarshalID(v) return res, graphql.ErrorOnPath(ctx, err) @@ -4640,27 +4251,6 @@ func (ec *executionContext) marshalNPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgen return v } -func (ec *executionContext) unmarshalNRunes2ᚕrune(ctx context.Context, v interface{}) ([]rune, error) { - res, err := model.UnmarshalRunes(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNRunes2ᚕrune(ctx context.Context, sel ast.SelectionSet, v []rune) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - res := model.MarshalRunes(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - func (ec *executionContext) unmarshalNString2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐManufacturer(ctx context.Context, v interface{}) (external.Manufacturer, error) { res, err := graphql.UnmarshalString(v) return external.Manufacturer(res), graphql.ErrorOnPath(ctx, err) diff --git a/_examples/scalars/model/model.go b/_examples/scalars/model/model.go index 245f9358bf9..12a871a6972 100644 --- a/_examples/scalars/model/model.go +++ b/_examples/scalars/model/model.go @@ -56,11 +56,6 @@ type User struct { Children uint Cars external.Count Weddings Sum - SomeBytes []byte - SomeOtherBytes []byte - SomeRunes []rune - RemoteBytes external.ExternalBytes - RemoteRunes external.ExternalRunes } // Point is serialized as a simple array, eg [1, 2] @@ -209,22 +204,3 @@ func UnmarshalPreferences(v interface{}) (*Prefs, error) { } return &Prefs{DarkMode: tmp}, nil } - -func MarshalRunes(r []rune) graphql.Marshaler { - return graphql.WriterFunc(func(w io.Writer) { - _, _ = fmt.Fprintf(w, "%q", string(r)) - }) -} - -func UnmarshalRunes(v interface{}) ([]rune, error) { - switch v := v.(type) { - case string: - return []rune(v), nil - case *string: - return []rune(*v), nil - case []rune: - return v, nil - default: - return nil, fmt.Errorf("%T is not []rune", v) - } -} diff --git a/_examples/scalars/resolvers.go b/_examples/scalars/resolvers.go index 52d1e21a198..5f533bb4af5 100644 --- a/_examples/scalars/resolvers.go +++ b/_examples/scalars/resolvers.go @@ -40,11 +40,6 @@ func (r *queryResolver) User(ctx context.Context, id external.ObjectID) (*model. Children: 3, Cars: 5, Weddings: 2, - SomeBytes: []byte("abcdef"), - SomeOtherBytes: []byte{97, 98, 99, 100, 101, 102}, - SomeRunes: []rune{'H', 'e', 'l', 'l', 'o', ' ', '世', '界'}, - RemoteBytes: external.ExternalBytes("fedcba"), - RemoteRunes: external.ExternalRunes{'界', '世', ' ', 'H', 'e', 'l', 'l', 'o'}, }, nil } diff --git a/_examples/scalars/scalar_test.go b/_examples/scalars/scalar_test.go index de98e9fdb75..9255e68a4d3 100644 --- a/_examples/scalars/scalar_test.go +++ b/_examples/scalars/scalar_test.go @@ -25,11 +25,6 @@ type RawUser struct { Children int Cars int Weddings int - SomeBytes string - SomeOtherBytes string - SomeRunes string - RemoteBytes string - RemoteRunes string } func TestScalars(t *testing.T) { @@ -95,18 +90,6 @@ func TestScalars(t *testing.T) { require.Equal(t, 2, resp.User.Weddings) }) - t.Run("basic aliases byte and rune", func(t *testing.T) { - var resp struct{ User RawUser } - - err := c.Post(`{ user(id:"=1=") { someBytes someOtherBytes someRunes remoteBytes remoteRunes } }`, &resp) - require.NoError(t, err) - require.Equal(t, "abcdef", resp.User.SomeBytes) - require.Equal(t, "abcdef", resp.User.SomeOtherBytes) - require.Equal(t, "Hello 世界", resp.User.SomeRunes) - require.Equal(t, "fedcba", resp.User.RemoteBytes) - require.Equal(t, "界世 Hello", resp.User.RemoteRunes) - }) - t.Run("custom error messages", func(t *testing.T) { var resp struct{ Search []RawUser } diff --git a/_examples/scalars/schema.graphql b/_examples/scalars/schema.graphql index b7d875c4cb6..a3b3a490bee 100644 --- a/_examples/scalars/schema.graphql +++ b/_examples/scalars/schema.graphql @@ -22,11 +22,6 @@ type User { children: Int! cars: Int! weddings: Int! - someBytes: Bytes! - someOtherBytes: Bytes! - someRunes: Runes! - remoteBytes: DefinedTypeBytes! - remoteRunes: DefinedTypeRunes! } type Address { @@ -50,7 +45,3 @@ scalar Timestamp scalar Point scalar Banned scalar DarkMode -scalar Bytes -scalar Runes -scalar DefinedTypeBytes -scalar DefinedTypeRunes diff --git a/integration/testomitempty.graphql b/integration/testomitempty.graphql index 1b73851f4ea..e943c8e0910 100644 --- a/integration/testomitempty.graphql +++ b/integration/testomitempty.graphql @@ -22,7 +22,7 @@ type DefinedTypeFromBasics { # for example, value of 5.76 comes out as 5.760000228881836, anyone knows how to fix this? newFloat32: Float32! - # uint64 needs a scalar because it is bigger than int64 + # uint64 need a scalar because it is bigger than int64 newUint64: Uint64! } diff --git a/internal/code/compare.go b/internal/code/compare.go index 8ff95ddce05..d6174acbeb1 100644 --- a/internal/code/compare.go +++ b/internal/code/compare.go @@ -40,7 +40,7 @@ func CompatibleTypes(expected types.Type, actual types.Type) error { case *types.Basic: if actualBasic, ok := actual.(*types.Basic); ok { - if actualBasic.Kind() != expected.Kind() && similarBasicKind(actualBasic.Kind()) != expected.Kind() { + if similarBasicKind(actualBasic.Kind()) != expected.Kind() { return fmt.Errorf("basic kind differs, %s != %s", expected.Name(), actualBasic.Name()) } @@ -168,7 +168,7 @@ func similarBasicKind(kind types.BasicKind) types.BasicKind { switch kind { case types.Int8, types.Int16: return types.Int64 - case types.Uint, types.Uint8, types.Uint16, types.Uint32: // exclude Uint64: it still needs scalar with custom marshalling/unmarshalling because it is bigger than int64 + case types.Uint, types.Uint8, types.Uint16, types.Uint32: // exclude Uint64: it still needs scalar with custom marshalling/unmarshalling because it is bigger then int64 return types.Int64 default: return kind