99designs / 99designs/gqlgen

Subscription use channel of pointer of model, may cause thread-unsafe issue?

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

Description

### What happened?
The generated subscription, like
```go
func (r *subscriptionResolver) StatusUpdated(ctx context.Context, udid string) (<-chan *model.Status, error) {
...
}
```

using type of channel of <- chan *model.Status,

when passing pointer of model.Status to multiple goroutine, I think it may cause thread-unsafe problem.
### What did you expect?
`<-chan *model.Status` to `<- chan model.Status`
```go
func (r *subscriptionResolver) StatusUpdated(ctx context.Context, id string) (<-chan model.Status, error) {
...
}
```

### Minimal graphql.schema and models to reproduce
```
type Subscription {
statusUpdated(id: String!) : Status!
}
```
### versions
- `gqlgen version`?
v0.11.3-dev
- `go version`?
go version go1.14.3 linux/amd64
- dep or go modules?
go modules

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.