Skip to content

feat(graphql-transport): add support for subscriptions - #96

Open
KeitoTadashi wants to merge 15 commits into
developfrom
tooling-sdk/add-support-subscriptions
Open

feat(graphql-transport): add support for subscriptions#96
KeitoTadashi wants to merge 15 commits into
developfrom
tooling-sdk/add-support-subscriptions

Conversation

@KeitoTadashi

Copy link
Copy Markdown
Contributor

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.

@KeitoTadashi
KeitoTadashi requested a review from a team as a code owner April 21, 2026 08:12
@KeitoTadashi KeitoTadashi changed the title Tooling sdk/add support subscriptions feat(graphql-transport): add support for subscriptions#10442 Apr 21, 2026
@KeitoTadashi KeitoTadashi changed the title feat(graphql-transport): add support for subscriptions#10442 feat(graphql-transport): add support for subscriptions Apr 21, 2026
Comment thread sdk/graphql-transport/src/transport.ts Outdated
Comment on lines 109 to 112

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can simplify this to:

const endpoint = this.#options.wsUrl
    ? this.#options.wsUrl
    : this.#options.url.replace(/\/?$/, '/subscriptions');

@vercel

vercel Bot commented Apr 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
apps-ui-kit Ready Ready Preview Jun 23, 2026 2:59pm
iota-evm-bridge Ready Ready Preview, Comment Jun 23, 2026 2:59pm
iota-multisig-toolkit Ready Ready Preview, Comment Jun 23, 2026 2:59pm
iota-names Ready Ready Preview, Comment Jun 23, 2026 2:59pm
rebased-explorer Ready Ready Preview, Comment Jun 23, 2026 2:59pm
wallet-dashboard Ready Ready Preview Jun 23, 2026 2:59pm

Request Review

Comment on lines +94 to +95
eventSeq: '', // TODO
txDigest: '', // TODO

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need to add this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.#connectionPromise = null; // was only reachable when
acknowledged=true

Comment thread sdk/graphql-transport/test/transport-subscriptions-e2e.test.ts
Comment on lines +279 to +283
ws.addEventListener('error', () => {
if (!acknowledged) {
clearTimeout(ackTimeout);
reject(new Error('WebSocket connection error'));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support in the ts sdk client for subscriptions

4 participants