-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: GraphQL subscriptions #1374
Conversation
Coverage report
Show new covered files 🐣
Test suite run success1483 tests passing in 259 suites. Report generated by 🧪jest coverage report action from 2f6f236 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
@nedsalk Why not adapt TransactionResponse
class to make it possible to use the subscription submitAndAwait
instead of just submit
mutation when submitting a Transaction?
fuels-ts/packages/providers/src/provider.ts
Lines 540 to 544 in 1690004
const { | |
submit: { id: transactionId }, | |
} = await this.operations.submit({ encodedTransaction }); | |
const response = new TransactionResponse(transactionId, this); |
The If you were thinking about modifying the |
We can have it as a secondary option, like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a minor observation, and there's the sendTransactionAndAwait
thing.
Co-authored-by: Anderson Arboleya <[email protected]>
This PR is just to introduce the subscription mechanism and verify that it works on |
@nedsalk I thought it'd be easy; maybe I got something wrong. Could you please elaborate on the rationale in a new issue and link it here? |
Thank you. |
Sorry @nedsalk I don't follow, can you help me by giving more context here? My initial thought was to modify the Maybe I am missing something here. UPDATE: And maybe make the I've asked this to bring the |
* chore: updating code owners (#1496) * docs: purge hardcoded snippets on 'using typegen' page (#1403) * chore: remove method that's same as base method (#1445) * chore: implement RC workflow (#1497) * Revert "feat: add `Predicate.getTransferTxId` helper (#1467)" * chore: fix rc release string replace (#1529) * docs: Update some hyperlinks to reference the new documentation hub (#1520) * chore: improve rc release message (#1559) * feat: GraphQL subscriptions (#1374) * chore: pin `graphql-request` to `v5` (#1567) * chore: upgrade `tsx` (#1574) * feat: migrate from Jest to Vitest (#1310) * chore: fix temp test workflow (#1579) * chore: update required node engine in `create-fuels` (#1582) * chore: add node version test matrix (#1575) * chore: fix broken rc message (#1580) * chore: update nodejs to v20 (#1544) * feat: accepting addresses as `string` (#1583) * chore: properly format the PR coverage report comment (#1586) * fix: flaky test (#1590) * docs: update `deposit-and-withdraw` page (#1591) * feat: retry mechanism (#1474) * feat: replaced `semver` dependency with custom implementation (#1594) * feat: replace `elliptic` with `@noble/curves` (#1601) * chore: fix CI failing due to missing tag in test (#1614) * feat: improve ABI Coders `decode` validation (#1426) * fix: do not generate a coverage diff without coverage artifact (#1629) * chore: pinpoint vitest to 1.0.4 (#1637) * chore: remove `ethers` dependency from `utils` (#1640) * fix: `getOperation` for `Transfer Asset` (#1619) * fix: remove external font dependencies (#1642) * fix: generate RC PR comment on `pull_request` event only (#1648) * fix: fix failing `rc` comment (#1657) * chore: add missing test group (#1658) * feat: implement browser compatibility testing (#1630) * chore: fix string replace in `rc` ci (#1659) * chore: adding extra reporters (#1661) * chore: manually trigger `rc` CI (#1660) * feat: use `submitAndAwait` graphql endpoint (#1615) * fix: flaky retry test (#1654) * feat: create a wallet without a provider (#1566) * chore!: Share single chainConfig and review node-related utilities (#1602) * chore: use new temporary coverage artifact (#1676) * fix: internalizing `findBinPath` utility (#1679)
This PR introduces GraphQL subscriptions without a dependency on any external library by using the Streams API and async generators. The native
EventSource
unfortunately couldn't cut it because it's limited only to GET requests. Alternatives toEventSource
like eventsource, SSE.js, fetch-event-source have their own problems (only GET, slow/non-existant maintenance, missing typescript declarations, lack of nodejs support...), so I opted to just use the native APIs. The core logic is infuel-graphql-subscriber.ts
and fits in less than 100 lines of code.Also, for documentation purposes, we already tried graphql-sse and reverted it.
closes #301 #782 #1293.