How to make sure my graphql subscription api is working?

How to make sure my graphql subscription api is working?


0

This is my subscription resolver in golang:

func (r *subscriptionResolver) CreateChatWithBot(ctx context.Context, req model.CreateChatWithBotRequest) (<-chan *model.CreateChatWithBotResults, error) {
    ch := make(chan *model.CreateChatWithBotResults)

    testString := []string{"This", "part", "is", "under", "construction", "...", " Be", "patient", "please!"}
    go func() {
        defer close(ch)
        for _, v := range testString {    
            select {
            case <-ctx.Done():
                return

            case ch <- &model.CreateChatWithBotResults{Response: pointer.Pointer(v)}:
            }
        }
    }()
    return ch, nil
}

When I use this API in postman, I only get the first word("This"). What could be the problem here?

{
    "data": {
        "createChatWithBot": {
            "response": "This"
        }
    }
}

I used gqlgen official document.


Load 5 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *