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

Detect subscription successfully started #3996

Closed
Amerehei opened this issue Dec 15, 2023 · 1 comment
Closed

Detect subscription successfully started #3996

Amerehei opened this issue Dec 15, 2023 · 1 comment

Comments

@Amerehei
Copy link

Amerehei commented Dec 15, 2023

I think it's not a question, it's a lack of feature which is necessary so please don't close this issue without any reply

I use graphql-ws to subscribe to GraphQL events. I use Observable interface to listen to the events. using error callback we can detect that subscription is failed to start, But there is no way to detect that it's successfully started

next happens when we get an event, But I would like to wrap the Observable with a Promise and await for it to start subscription

And while the promise is not resolved, I want to show a progress bar. I can reject the promise in the error but I couldn't find anyway to resolve it when server returns response to the subscription request

function toObservable(operation) {
  return new Observable((observer) =>
    client.subscribe(operation, {
      next: (data) => observer.next(data),
      error: (err) => observer.error(err),
      complete: () => observer.complete(),
    }),
  );
}

I have also asked this question at
https://stackoverflow.com/questions/77666947/apollo-graphql-detect-subscription-started
and
enisdenjo/graphql-ws#526

@yaacovCR
Copy link
Contributor

This looks like a protocol issue, and there appears to be a workaround available at the linked issue/discussion. Closing for now, feel free to reopen if if there is something to be addressed within this repository.

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

2 participants