99designs / 99designs/gqlgen

[Bug Report]subscription returns null if query contains certain field

Open
#1,141 4 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?

```graphql
type Mutation {
post(text: String!): Message!
}
type Subscription {
messageAdded: Message!
}

type Message {
id: ID!
text: String!
testMessage: String!
}
```

``` golang
type Message struct {
ID string `json:"id" gorm:"primary_key:true;type:char(36);column:id"`
Text string `json:"text"`

TestMessage *string `json:"test_message"`
}
```

As schema file shows, post messages will show up in "messageAdded" subscription.

But if subscription queried with `testMessage` field, the result will return `null` as below

Xnip2020-04-10_03-40-34

And if subscription queried without `testMessage` field, the result seems to be normal

![image](https://user-images.githubusercontent.com/22412638/78934573-bddd9d00-7add-11ea-851d-41f8c6eef228.png)

### Minimal graphql.schema and models to reproduce

I made an example project to debug
https://github.com/fredliang44/debug-gqlgen

### versions
- `gqlgen version`?
v0.11.3
- `go version`?
go1.14.1
- dep or go modules?
go mod

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.