Defined type from a basic type should not need a mandatory scalar + MarshalFunc and UnmarshalFunc
- Lingua principale
- Go
- Stelle
- 10.8k
- Fork
- 1.3k
- Merge medio
- 2g 36m
- PR unite (30g)
- 26
Descrizione
### What happened?
In an existing Golang project where we are trying to add `gqlgen`, we have defined some types from basic types (string, int, boolean, float) that are being used in other structs. Currently, we need to write a `scalar` in the GraphQL schema and also do a `MarshalFunc` and `UnmarshalFunc` in order to avoid an error message saying ` is incompatible with `.

### What did you expect?
No error message appear and no need to create a `scalar` with related `MarshalFunc` and `UnmarshalFunc` when `go generate`.
### Minimal graphql.schema and models to reproduce
In a remote package, create some named basic types:
```go
package namedtypes
type (
NamedString string
NamedInt int
NamedInt32 int32
NamedInt64 int64
NamedBool bool
NamedFloat64 float64
)
```
In another package, create a struct using these named basic types (might need to add this package to autobind):
```go
package usenamedtypes
import "github.com/99designs/gqlgen/integration/namedtypes"
type DummyUser struct {
NewString namedtypes.NamedString
NewInt namedtypes.NamedInt
NewInt32 namedtypes.NamedInt32
NewInt64 namedtypes.NamedInt64
NewBool namedtypes.NamedBool
NewFloat64 namedtypes.NamedFloat64
}
```
In the GraphQL schema, create a type for the struct:
```graphql
type DummyUser {
NewString: String!
NewInt: Int!
NewInt32: Int!
NewInt64: Int!
NewBool: Boolean!
NewFloat64: Float!
}
```
Please note that a PR is coming to fix this.
### versions
- `go run github.com/99designs/gqlgen version`? v0.17.22-dev
- `go version`? go1.19.3 darwin/arm64
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.