99designs / 99designs/gqlgen

Support encapsulated model structure with private field.

Open
#2,560 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
10.8k
Forks
1.3k
Avg merge
2d 36m
Merged PRs (30d)
26

Description

When using `autobind` for model, currently gqlgen only supports the model struct with public fields.

From the example: https://github.com/99designs/gqlgen/blob/master/docs/content/getting-started.md

```golang
type Todo struct {
ID string `json:"id"`
Text string `json:"text"`
Done bool `json:"done"`
UserID string `json:"userId"`
User *User `json:"user"`
}
```

But, how about encapsulated model like,

```golang
type Todo struct {
id string
text string
done bool
userID string
user *User
}
```

I want forbid direct access and update of model field to ensure immutability of the model. And, only external function can handle that. In this case, can we support this model for gqlgen too?

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.