feat(graphql-transport): add support for subscriptions - #96
Open
KeitoTadashi wants to merge 15 commits into
Open
feat(graphql-transport): add support for subscriptions#96KeitoTadashi wants to merge 15 commits into
KeitoTadashi wants to merge 15 commits into
Conversation
brancoder
requested changes
Apr 23, 2026
Comment on lines
109
to
112
Contributor
There was a problem hiding this comment.
we can simplify this to:
const endpoint = this.#options.wsUrl
? this.#options.wsUrl
: this.#options.url.replace(/\/?$/, '/subscriptions');
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Comment on lines
+94
to
+95
| eventSeq: '', // TODO | ||
| txDigest: '', // TODO |
Contributor
There was a problem hiding this comment.
Do we still need to add this?
Contributor
Author
There was a problem hiding this comment.
No, as i said before, the GraphQL Event type in the schema does not expose txDigest or eventSeq fields.
Comment on lines
+262
to
+276
| ws.addEventListener('close', () => { | ||
| if (!acknowledged) { | ||
| clearTimeout(ackTimeout); | ||
| reject(new Error('WebSocket closed before connection was acknowledged')); | ||
| return; | ||
| } | ||
|
|
||
| this.#connectionPromise = null; | ||
| this.#disconnects++; | ||
|
|
||
| if (this.#disconnects <= this.#options.maxReconnects) { | ||
| setTimeout(() => { | ||
| this.#reconnect(); | ||
| }, this.#options.reconnectTimeout); | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| ws.addEventListener('close', () => { | |
| if (!acknowledged) { | |
| clearTimeout(ackTimeout); | |
| reject(new Error('WebSocket closed before connection was acknowledged')); | |
| return; | |
| } | |
| this.#connectionPromise = null; | |
| this.#disconnects++; | |
| if (this.#disconnects <= this.#options.maxReconnects) { | |
| setTimeout(() => { | |
| this.#reconnect(); | |
| }, this.#options.reconnectTimeout); | |
| } | |
| this.#connectionPromise = null; | |
| if (!acknowledged) { | |
| clearTimeout(ackTimeout); | |
| reject(new Error('WebSocket closed before connection was acknowledged')); | |
| return; | |
| } | |
| this.#disconnects++; | |
| if (this.#disconnects <= this.#options.maxReconnects) { | |
| setTimeout(() => { | |
| this.#reconnect(); | |
| }, this.#options.reconnectTimeout); | |
| } |
Contributor
There was a problem hiding this comment.
this.#connectionPromise = null; // was only reachable when
acknowledged=true
Comment on lines
+279
to
+283
| ws.addEventListener('error', () => { | ||
| if (!acknowledged) { | ||
| clearTimeout(ackTimeout); | ||
| reject(new Error('WebSocket connection error')); | ||
| } |
Contributor
There was a problem hiding this comment.
Should we do something with connections if acknowledged? Like pass onError to current subscriptions.
Suggested change
| ws.addEventListener('error', () => { | |
| if (!acknowledged) { | |
| clearTimeout(ackTimeout); | |
| reject(new Error('WebSocket connection error')); | |
| } | |
| ws.addEventListener('error', () => { | |
| if (!acknowledged) { | |
| clearTimeout(ackTimeout); | |
| reject(new Error('WebSocket connection error')); | |
| } else { | |
| const errors = [{ message: 'WebSocket connection error' }]; | |
| for (const subscription of this.#subscriptions.values()) { | |
| subscription.onError(errors); | |
| } | |
| } |
Comment on lines
+153
to
+155
| this.#subscriptions.set(id, subscription); | ||
|
|
||
| await subscription.subscribe(this, id); |
Contributor
There was a problem hiding this comment.
shouldn't we cover case if subscription failed?
Suggested change
| this.#subscriptions.set(id, subscription); | |
| await subscription.subscribe(this, id); | |
| this.#subscriptions.set(id, subscription); | |
| try { | |
| await subscription.subscribe(this, id); | |
| } catch (e) { | |
| this.#subscriptions.delete(id); | |
| throw e; | |
| } |
panteleymonchuk
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of change
Please write a summary of your changes and why you made them.
Links to any relevant issues
fixes #44
How the change has been tested
Describe the tests that you ran to verify your changes.
Make sure to provide instructions for the maintainer as well as any relevant configurations.