From 5fa310f45fb57aa7ef16eb4ea66deb50a2e078e6 Mon Sep 17 00:00:00 2001 From: Vandana Date: Mon, 25 May 2026 11:06:33 -0400 Subject: [PATCH] fix(graphql): make usdt wallet balance nullable --- dev/apollo-federation/supergraph.graphql | 2 +- src/graphql/admin/schema.graphql | 2 +- src/graphql/public/schema.graphql | 2 +- .../shared/types/object/usdt-wallet.ts | 2 +- .../graphql/wallet-balance-validation.spec.ts | 30 +++++++++++++++++++ 5 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 test/flash/unit/graphql/wallet-balance-validation.spec.ts diff --git a/dev/apollo-federation/supergraph.graphql b/dev/apollo-federation/supergraph.graphql index bb5202f04..865c5fd87 100644 --- a/dev/apollo-federation/supergraph.graphql +++ b/dev/apollo-federation/supergraph.graphql @@ -2039,7 +2039,7 @@ type UsdtWallet implements Wallet @join__type(graph: PUBLIC) { accountId: ID! - balance: FractionalCentAmount! + balance: FractionalCentAmount id: ID! isExternal: Boolean! lnurlp: Lnurl diff --git a/src/graphql/admin/schema.graphql b/src/graphql/admin/schema.graphql index 1eb75c263..87eed84b2 100644 --- a/src/graphql/admin/schema.graphql +++ b/src/graphql/admin/schema.graphql @@ -572,7 +572,7 @@ A wallet belonging to an account which contains a USDT balance and a list of tra """ type UsdtWallet implements Wallet { accountId: ID! - balance: FractionalCentAmount! + balance: FractionalCentAmount id: ID! isExternal: Boolean! lnurlp: Lnurl diff --git a/src/graphql/public/schema.graphql b/src/graphql/public/schema.graphql index e2f607717..e0bac3237 100644 --- a/src/graphql/public/schema.graphql +++ b/src/graphql/public/schema.graphql @@ -1654,7 +1654,7 @@ A wallet belonging to an account which contains a USDT balance and a list of tra """ type UsdtWallet implements Wallet { accountId: ID! - balance: FractionalCentAmount! + balance: FractionalCentAmount id: ID! isExternal: Boolean! lnurlp: Lnurl diff --git a/src/graphql/shared/types/object/usdt-wallet.ts b/src/graphql/shared/types/object/usdt-wallet.ts index 046e21bb7..3ea7dba1f 100644 --- a/src/graphql/shared/types/object/usdt-wallet.ts +++ b/src/graphql/shared/types/object/usdt-wallet.ts @@ -56,7 +56,7 @@ const UsdtWallet = GT.Object({ }, balance: { - type: GT.NonNull(FractionalCentAmount), + type: FractionalCentAmount, resolve: async (source) => { const balance = await Wallets.getBalanceForWallet({ walletId: source.id, diff --git a/test/flash/unit/graphql/wallet-balance-validation.spec.ts b/test/flash/unit/graphql/wallet-balance-validation.spec.ts new file mode 100644 index 000000000..8a2c828c9 --- /dev/null +++ b/test/flash/unit/graphql/wallet-balance-validation.spec.ts @@ -0,0 +1,30 @@ +import { parse, validate } from "graphql" + +import { gqlMainSchema } from "@graphql/public" + +describe("wallet balance query validation", () => { + it("allows querying USD and USDT wallet balances with the same response name", () => { + const query = parse(` + query Me { + me { + defaultAccount { + wallets { + ... on UsdtWallet { + id + balance + } + ... on UsdWallet { + id + balance + } + } + } + } + } + `) + + const errors = validate(gqlMainSchema, query) + + expect(errors).toEqual([]) + }) +})