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

Implement transaction subscriptions #782

Closed
luizstacio opened this issue Feb 13, 2023 · 1 comment · Fixed by #1256, #1374 or #1495
Closed

Implement transaction subscriptions #782

luizstacio opened this issue Feb 13, 2023 · 1 comment · Fixed by #1256, #1374 or #1495
Assignees
Labels
feat Issue is a feature

Comments

@luizstacio
Copy link
Member

Currently, the fuel-core implements a solution to improve transaction status monitoring via GraphQL Subscriptions. This new approach enables us to improve the current "expanding backoff" approach on TransactionReponse.waitFor..., where we query transactions on a timely basis before the status change to use subscriptions and avoid multiples request.

Note: We could use two strategies, expanding backoff and subscribe, to work on config bases giving the option to developers to pass wich strategy to be used. The default should be subscribe.

@Dhaiwat10
Copy link
Member

@luizstacio are you aware of any ways to get our GraphQL codegen to generate a method that would let me subscribe to this subscription. I added this code to operations.graphql:

subscription statusChange($id: TransactionId!) {
  statusChange(id: $id) {
    __typename
  }
}

And this is the function it generated in operations.ts, which returns a Promise that would resolves as soon as the status changes. This won't work like a subscription.

statusChange(
      variables: GqlStatusChangeSubscriptionVariables,
      requestHeaders?: Dom.RequestInit['headers']
    ): Promise<GqlStatusChangeSubscription> {
      return withWrapper(
        (wrappedRequestHeaders) =>
          client.request<GqlStatusChangeSubscription>(StatusChangeDocument, variables, {
            ...requestHeaders,
            ...wrappedRequestHeaders,
          }),
        'statusChange',
        'subscription'
      );
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Issue is a feature
Projects
None yet
4 participants