-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimize transaction history request (#1572)
- Closes #1553 --- - Fetch transaction history cursors using a simplified query to optimize data retrieval. - Improve loading time by reducing the page info query complexity.
- Loading branch information
1 parent
c2e875e
commit 9718513
Showing
6 changed files
with
97 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"fuels-wallet": minor | ||
--- | ||
|
||
Reduce transaction history loading time by optimizing the complexity of the page info query. |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export const graphqlRequest = async <R, T = Record<string, unknown>>( | ||
url: string, | ||
operationName: string, | ||
query: string, | ||
variables: T | ||
): Promise<R> => { | ||
const res = await fetch(url, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
operationName, | ||
query, | ||
variables, | ||
}), | ||
}); | ||
|
||
if (res.ok) { | ||
const response = await res.json(); | ||
return response.data as R; | ||
} | ||
|
||
const error = await res.json(); | ||
return Promise.reject(error); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
export type GetPageInfoQuery = { | ||
transactionsByOwner: { | ||
pageInfo: { | ||
hasPreviousPage: boolean; | ||
hasNextPage: boolean; | ||
startCursor: string; | ||
endCursor: string; | ||
}; | ||
}; | ||
}; | ||
|
||
export const getPageInfoQuery = ` | ||
query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) { | ||
transactionsByOwner( | ||
owner: $owner | ||
after: $after | ||
before: $before | ||
first: $first | ||
last: $last | ||
) { | ||
pageInfo { | ||
...pageInfoFragment | ||
} | ||
} | ||
} | ||
fragment pageInfoFragment on PageInfo { | ||
hasPreviousPage | ||
hasNextPage | ||
startCursor | ||
endCursor | ||
} | ||
`; |
This file contains 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
This file contains 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