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

feat: implement GraphQL subscriptions support #1256

Merged
merged 64 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
ba88350
checkpoint
nedsalk Aug 17, 2023
d397211
checkpoint save
nedsalk Aug 21, 2023
6efb354
Merge remote-tracking branch 'origin/master' into ns/feat/subscribe-t…
nedsalk Aug 22, 2023
0eb5c90
Merge remote-tracking branch 'origin/master' into ns/feat/subscribe-t…
nedsalk Aug 28, 2023
560777d
feat: got subscriptions to work
nedsalk Aug 30, 2023
b49b12b
Merge remote-tracking branch 'origin/master' into ns/feat/subscribe-t…
nedsalk Aug 30, 2023
9bb7517
feat: got subscriptions working in .waitForResult()
nedsalk Aug 30, 2023
ebb7566
Merge remote-tracking branch 'origin/master' into ns/feat/subscribe-t…
nedsalk Aug 30, 2023
aad8a3d
checkpoint: timeouts
nedsalk Aug 31, 2023
af26fa7
checkpoint
nedsalk Sep 1, 2023
a69916a
Merge remote-tracking branch 'origin/master' into ns/feat/subscribe-t…
nedsalk Sep 11, 2023
f32fedf
test: when subscription gets node error
nedsalk Sep 13, 2023
88794ef
Merge remote-tracking branch 'origin/master' into ns/feat/subscribe-t…
nedsalk Sep 13, 2023
a5ec769
chore: formatter changed from double to single-tick
nedsalk Sep 13, 2023
da7f7d2
fix: reverted unnecessary change
nedsalk Sep 13, 2023
a218c57
chore: removed specified typescript version to use the global one
nedsalk Sep 13, 2023
bb7fc28
fix: reverted change to file after testing
nedsalk Sep 13, 2023
5fa9206
refactor: renamed type
nedsalk Sep 13, 2023
a7f842d
refactor: removed unused fields and vars
nedsalk Sep 13, 2023
8f3c734
chore: reasoning behind error throwing in onMessage
nedsalk Sep 13, 2023
a1c03be
test: beter test for custom fetch fn
nedsalk Sep 13, 2023
5f2c39a
Merge remote-tracking branch 'origin/master' into ns/feat/subscribe-t…
nedsalk Sep 14, 2023
4fd4df3
fix: updated nextjs ts version
nedsalk Sep 14, 2023
212712f
test: removed redundant test
nedsalk Sep 14, 2023
9158bdb
Merge remote-tracking branch 'origin/master' into ns/feat/subscribe-t…
nedsalk Sep 14, 2023
a2c48e8
fix: set TS package from major to minor
nedsalk Sep 14, 2023
b3d7481
fix: typo
nedsalk Sep 14, 2023
b192660
Merge branch 'master' into ns/feat/subscribe-to-transaction-status-ch…
nedsalk Sep 14, 2023
c23a9ad
fix: pnpm install changed pnpm-lock.yaml
nedsalk Sep 14, 2023
6c66aec
chore: changeset
nedsalk Sep 14, 2023
0203b37
refactor: moved subscription client generation to method
nedsalk Sep 14, 2023
50d021e
refactor: separate into method
nedsalk Sep 14, 2023
0d542d4
feat: changed default timeout to undefined
nedsalk Sep 14, 2023
c1c4c56
refactor: make method static
nedsalk Sep 14, 2023
a80d64c
refactor: use options directly if default fetch
nedsalk Sep 14, 2023
01a5ea4
refactor: stop setting url while creating operations
nedsalk Sep 14, 2023
7e416d4
test: refactored failing test to not mock graphql client
nedsalk Sep 14, 2023
b0c6f5a
test: fix test assumptions
nedsalk Sep 14, 2023
245e051
docs: make prettier
nedsalk Sep 14, 2023
87f084a
refactor: set event to always be 'next' because if there are errors t…
nedsalk Sep 14, 2023
3c614db
feat: changed generic error to FuelError
nedsalk Sep 14, 2023
0caf97e
fix: using cross-fetch instead of node-fetch
nedsalk Sep 15, 2023
9a81ccb
chore: reverted version of nextjs TS as it wasnt causing issue
nedsalk Sep 15, 2023
b8febcc
fix: linting
nedsalk Sep 15, 2023
320944e
Merge branch 'master' into ns/feat/subscribe-to-transaction-status-ch…
nedsalk Sep 18, 2023
54fd463
fix: named library in comment explanation
nedsalk Sep 18, 2023
f2b280f
Merge branch 'master' into ns/feat/subscribe-to-transaction-status-ch…
nedsalk Sep 20, 2023
3c4f7ae
fix: post-merge fixes
nedsalk Sep 20, 2023
ca8809a
refactor: [in progress] only operations.graphql, without subscription…
nedsalk Sep 20, 2023
8abe425
refactor: use only operations.graphql, no subscriptions.graphql
nedsalk Sep 21, 2023
4570917
Merge remote-tracking branch 'origin/master' into ns/feat/subscribe-t…
nedsalk Sep 21, 2023
77f068e
chore: removed cross-fetch because we're using node's fetch
nedsalk Sep 21, 2023
f6c26a7
refactor: only change query to string when subscription
nedsalk Sep 21, 2023
2e6ab4b
test: update node to fix tests caused by node's fetch bugs
nedsalk Sep 21, 2023
d94106b
build: updated both ci and package.json node and pnpm versions to match
nedsalk Sep 21, 2023
ac26e70
chore: remove unused cross-fetch
nedsalk Sep 21, 2023
54ef0f2
chore: update pnpm version
nedsalk Sep 21, 2023
97151d9
test: try fix test failing in CI`
nedsalk Sep 21, 2023
607e88e
Merge branch 'master' into ns/feat/subscribe-to-transaction-status-ch…
nedsalk Sep 21, 2023
c140478
fix: abi-main-method-missing was already defined
nedsalk Sep 22, 2023
467a03f
fix: formatting
nedsalk Sep 22, 2023
b5ea463
Merge branch 'master' into ns/feat/subscribe-to-transaction-status-ch…
nedsalk Sep 22, 2023
ffe75af
Merge branch 'master' into ns/feat/subscribe-to-transaction-status-ch…
nedsalk Sep 22, 2023
247d38d
Merge branch 'master' into ns/feat/subscribe-to-transaction-status-ch…
nedsalk Sep 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/twelve-apes-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/providers": minor
---

Added subscriptions to graphql node
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ module.exports = {
// Disable error on devDependencies importing since this isn't a TS library
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
'no-await-in-loop': 0,
'no-restricted-syntax': [
'off',
{
selector: 'ForOfStatement',
nedsalk marked this conversation as resolved.
Show resolved Hide resolved
},
],
'prefer-destructuring': 0,
'no-bitwise': 0,
'no-underscore-dangle': 'off',
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/ci-setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "CI setup"
inputs:
node-version:
description: "Node version"
default: 18.14.1
default: 18.18.0
nedsalk marked this conversation as resolved.
Show resolved Hide resolved
pnpm-version:
description: "PNPM version"
default: 8.6.1
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.14.1
18.18.0
11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"author": "Fuel Labs <contact@fuel.sh> (https://fuel.network/)",
"private": true,
"engines": {
"node": ">= 18.14.1",
"pnpm": ">= 8.1.1"
"node": ">= 18.18.0",
"pnpm": ">= 8.6.1"
nedsalk marked this conversation as resolved.
Show resolved Hide resolved
},
"packageManager": "pnpm@8.1.1",
"packageManager": "pnpm@8.6.1",
"scripts": {
"dev": "nodemon --config nodemon.config.json -x 'turbo run build --filter=!fuel-gauge'",
"build": "turbo run build",
Expand Down Expand Up @@ -87,10 +87,5 @@
"tsx": "^3.12.7",
"turbo": "^1.8.8",
"typescript": "~5.1.6"
},
"pnpm": {
"overrides": {
"cross-fetch": "4.0.0"
}
}
}
5 changes: 4 additions & 1 deletion packages/errors/src/error-codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export enum ErrorCode {
TYPE_NOT_FOUND = 'type-not-found',
TYPE_NOT_SUPPORTED = 'type-not-supported',
INVALID_DECODE_VALUE = 'invalid-decode-value',
JSON_ABI_ERROR = 'abi-main-method-missing',
JSON_ABI_ERROR = 'json-abi-error',
TYPE_ID_NOT_FOUND = 'type-id-not-found',
BIN_FILE_NOT_FOUND = 'bin-file-not-found',
CODER_NOT_FOUND = 'coder-not-found',
Expand Down Expand Up @@ -84,6 +84,9 @@ export enum ErrorCode {
SCRIPT_REVERTED = 'script-reverted',
SCRIPT_RETURN_INVALID_TYPE = 'script-return-invalid-type',

// general
FUEL_NODE_ERROR = 'fuel-node-error',

// coder
// ...
}
12 changes: 9 additions & 3 deletions packages/providers/codegen.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
{
"$schema": "https://www.graphql-code-generator.com/config.schema.json",
"schema": "./fuel-core-schema.graphql",
"documents": "./src/operations.graphql",
"generates": {
"./src/__generated__/operations.ts": {
"documents": "./src/operations.graphql",
"plugins": [
{ "typescript": {} },
{ "typescript-operations": {} },
{ "typescript-graphql-request": {} }
{
"typescript-operations": {}
},
{
"typescript-generic-sdk": {
"dedupeFragments": true
}
}
],
"config": {
"scalars": {
Expand Down
5 changes: 3 additions & 2 deletions packages/providers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"graphql": "^16.6.0",
"graphql-request": "^5.0.0",
"graphql-tag": "^2.12.6",
"graphql-sse": "^2.2.1",
"ramda": "^0.29.0",
"tai64": "^1.0.0"
},
Expand All @@ -47,8 +48,8 @@
"@graphql-codegen/typescript": "^2.8.0",
"@graphql-codegen/typescript-graphql-request": "^4.5.7",
"@graphql-codegen/typescript-operations": "^2.5.5",
"@graphql-codegen/typescript-generic-sdk": "^3.1.0",
"@types/ramda": "^0.29.3",
"get-graphql-schema": "^2.1.2",
"typescript": "^4.8.4"
"get-graphql-schema": "^2.1.2"
}
}
59 changes: 38 additions & 21 deletions packages/providers/src/operations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@
# generate `operations.ts` from this file.

# Fragments

fragment transactionStatusFragment on TransactionStatus {
type: __typename
... on SubmittedStatus {
time
}
... on SuccessStatus {
block {
id
}
time
programState {
returnType
data
}
}
... on FailureStatus {
block {
id
}
time
reason
}
}

fragment transactionFragment on Transaction {
id
rawPayload
Expand All @@ -12,27 +37,7 @@ fragment transactionFragment on Transaction {
...receiptFragment
}
status {
type: __typename
... on SubmittedStatus {
time
}
... on SuccessStatus {
block {
id
}
time
programState {
returnType
data
}
}
... on FailureStatus {
block {
id
}
time
reason
}
...transactionStatusFragment
}
}

Expand Down Expand Up @@ -462,3 +467,15 @@ mutation produceBlocks(
startTimestamp: $startTimestamp
)
}

subscription submitAndAwait($encodedTransaction: HexString!) {
submitAndAwait(tx: $encodedTransaction) {
...transactionStatusFragment
}
}

subscription statusChange($transactionId: TransactionId!) {
statusChange(id: $transactionId) {
...transactionStatusFragment
}
}
Loading
Loading