99designs / 99designs/gqlgen

Use sql.NullString & Co. declaring them in gqlgen.yml config file

Open
#1,662 3 comments 4 reactions 0 assignees View on GitHub
binder question support
Dominant language
Go
Stars
10.8k
Forks
1.3k
Avg merge
2d 36m
Merged PRs (30d)
26

Description

### What happened?

I'm trying to avoid pointers as my structs fields.

But `gqlgen` generates struct like:

```go
type User struct {
ID uint64 `json:"id"`
Nickname string `json:"lastname"`
Img *string `json:"img"`
}
```

with `*string` as you can see.

### What did you expect?

I would like to use something like this in `gqlgen.yml` config file:

```yml
models:
String:
model:
- github.com/99designs/gqlgen/graphql.String
- github.com/99designs/gqlgen/graphql.NullString
# or maybe also:
- database/sql.NullString
```

So to have this instead:

```go
type User struct {
ID uint64 `json:"id"`
Nickname string `json:"lastname"`
Img sql.NullString `json:"img"`
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.