Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gqlgenのissue下書き #26

Open
figboy9 opened this issue Mar 25, 2020 · 0 comments
Open

gqlgenのissue下書き #26

figboy9 opened this issue Mar 25, 2020 · 0 comments

Comments

@figboy9
Copy link
Owner

figboy9 commented Mar 25, 2020

What happened?

Can't return an error that occurred in the other goroutine.
For example, redis-pubsub, gRPC client streaming, etc.

What did you expect?

I want to return an error after returning a channel.

Minimal graphql.schema and models to reproduce

type Subscription {
  messageAdded: Message!
}

type Message {
  id: ID!
  body: String!
}
func (r *subscriptionResolver) MessageAdded(ctx context.Context) (<-chan *model.Message, error) {
	ch := make(chan *model.Message)
	go func() {
		// some kind of block processing (e.g.: gRPC client streaming)
		stream, err := gRPCClientStreamRequest(ctx)
		if err != nil {
			log.Println(err) // i want to return this error
		}
		for {
			m, err := stream.Recv()
			if err != nil {
				log.Println(err) // i want to return this error
			}
			ch <- m
		}
	}()
	
	return ch, nil
}

versions

  • gqlgen version: 0.11.3
  • go version: 1.13
  • dep or go modules: go modules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant