Skip to content

Commit

Permalink
fix(graph): performance improvement on the transfers query (#2679)
Browse files Browse the repository at this point in the history
  • Loading branch information
alber70g authored Nov 21, 2024
1 parent 54268f4 commit a8204ab
Show file tree
Hide file tree
Showing 18 changed files with 965 additions and 328 deletions.
8 changes: 8 additions & 0 deletions .changeset/beige-nails-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@kadena/graph': major
---

BREAKING: removed totalCount on any `transfers` connection

We removed this as it caused performance issues You can rely on hasNextPage and
hasPreviousPage to determine if there are more pages
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const accountTransfers: DocumentNode = gql`
node(id: $id) {
... on FungibleAccount {
transfers(first: $first, after: $after, last: $last, before: $before) {
totalCount
pageInfo {
endCursor
hasNextPage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export const AccountTransfersTable: FC<{ accountName: string }> = ({
setPage={handlePageChange}
pageSize={pageSize}
pageInfo={innerData.node!.transfers.pageInfo}
totalCount={innerData.node!.transfers.totalCount}
isLoading={isLoading}
fields={[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const loadingData: AccountTransfersQuery = {
hasPreviousPage: false,
startCursor: '',
},
totalCount: 0,
edges: Array(6).fill({
node: {
requestKey: '0',
Expand Down
1 change: 0 additions & 1 deletion packages/apps/graph/generated-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ type FungibleAccountTransactionsConnectionEdge {
type FungibleAccountTransfersConnection {
edges: [FungibleAccountTransfersConnectionEdge!]!
pageInfo: PageInfo!
totalCount: Int!
}

type FungibleAccountTransfersConnectionEdge {
Expand Down
5 changes: 3 additions & 2 deletions packages/apps/graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"scripts": {
"build": "pnpm run pactjs:generate:contracts && pnpm prisma:generate && tsc",
"deploy:marmalade": "ts-node -T src/devnet/deployment/index.ts deploy:marmalade",
"devnet": "docker volume create kadena_devnet; docker run --rm -it -p 8080:8080 -p 5432:5432 -p 9999:9999 -p 1789:1789 -v kadena_devnet:/data -v ./cwd-extra-migrations:/cwd-extra-migrations:ro --name devnet kadena/devnet",
"devnet": "docker volume create kadena_devnet_crashnet; docker run --rm -it -p 8080:8080 -p 5432:5432 -p 9999:9999 -p 1789:1789 -p 1848:1848 -v kadena_devnet_crashnet:/data -v ./cwd-extra-migrations:/cwd-extra-migrations:ro --name devnet kadena/devnet:crashnet-arm64",
"devnet:update": "docker pull kadena/devnet",
"format": "pnpm run --sequential /^format:.*/",
"format:lint": "pnpm run lint:src --fix",
Expand All @@ -41,7 +41,7 @@
"simulate:coin": "ts-node -T src/devnet/simulation/index.ts simulate:coin",
"simulate:flood": "ts-node -T src/devnet/simulation/index.ts simulate:flood",
"simulate:marmalade": "ts-node -T src/devnet/simulation/index.ts simulate:marmalade",
"start": "npx ts-node-dev --respawn --no-notify --exit-child src/index.ts",
"start": "npx ts-node-dev -T --respawn --no-notify --exit-child src/index.ts",
"start:generate": "pnpm build && npx ts-node-dev --respawn --no-notify --exit-child src/index.ts",
"test": "echo \"no test specified\"",
"testing": "ts-node -T src/devnet/simulation/index.ts test",
Expand Down Expand Up @@ -92,6 +92,7 @@
"@rushstack/eslint-config": "~3.6.9",
"@types/debug": "~4.1.12",
"@types/js-yaml": "4.0.9",
"@types/lodash": "^4.17.13",
"@types/node": "^20.12.7",
"@types/pg": "~8.11.5",
"@types/seedrandom": "~3.0.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/graph/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
generator client {
provider = "prisma-client-js"
previewFeatures = ["views"]
previewFeatures = ["views", "relationJoins"]
}

generator pothos {
Expand Down
Loading

0 comments on commit a8204ab

Please sign in to comment.