99designs / 99designs/gqlgen

Issue with GraphQL subscriptions ! kinda ?

未關閉
#2,415 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Go
星號
10.8k
分支
1.3k
平均合併
2 天 36 分鐘
30 天內合併 PR
26

描述

### What happened?

Hey guys, so i was trying out GraphQL subscriptions and it does kinda work.

So here is the overview. i have ZeroMQ server which streams the data to Golang client and then UI gets the data through GraphQL.

```ZeroMQ Server(Python) --> ZeroMQ Client (Go) --> GraphQL Subscription --> UI ```

![sample](https://user-images.githubusercontent.com/48326585/199944196-5c6f90e5-cb68-4d97-bd7d-76b549495abc.gif)

* Right Window is the socket server running on python
* Left Window is the Go Client.

#### GraphQL Output

Graphql

### What did you expect?

I thought it was going to be fast since the socket response on the go side without GraphQL Subscription is great. Am i missing something with respect to tick can i make it lower i think its 1 min tick on the websocket end.

### Minimal graphql.schema and models to reproduce

```schema.graphql```
```graphql
type Data{
image: String!
temperature: Int!
relhumidity: Int!
}

# create a subscription
type Subscription {
data: Data!
}
```

```models.go and subscription Func()```
```go
func (r *subscriptionResolver) Data(ctx context.Context) (<-chan *model.Data, error) {
subscriber, _ := zmq.NewSocket(zmq.SUB)
defer subscriber.Close()

subscriber.Connect("tcp://localhost:5555")
subscriber.SetSubscribe("")
for {
// read message contents
incoming_data, _ := subscriber.Recv(0)
fmt.Printf("\nRecevied: [%s]", incoming_data)
contents := strings.Fields(incoming_data)
data2, _ := strconv.Atoi(string(contents[1]))
data3, _ := strconv.Atoi(string(contents[2]))

reponse_data := &model.Data{
Image: contents[0],
Temperature: data2,
Relhumidity: data3,
}

// return reponse_data as a channel
ch := make(chan *model.Data)
go func() {
ch <- reponse_data
}()
return ch, nil

}
}

```

### Versions
- `gqlgen version` : `v0.17.20`
- `go version`: `1.19`

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。