From bb91b629f7714001bb2b6a079336216aad5b44c7 Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Wed, 16 Oct 2024 09:21:05 +0200 Subject: [PATCH] make sorting optional --- api/resolvers/wallet.js | 4 ++-- api/typeDefs/wallet.js | 2 +- fragments/wallet.js | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/api/resolvers/wallet.js b/api/resolvers/wallet.js index c2c0d8a2..4ec27a8c 100644 --- a/api/resolvers/wallet.js +++ b/api/resolvers/wallet.js @@ -176,7 +176,7 @@ const resolvers = { }) return wallet }, - wallets: async (parent, { includeReceivers = true, includeSenders = true, onlyEnabled = false }, { me, models }) => { + wallets: async (parent, { includeReceivers = true, includeSenders = true, onlyEnabled = false, prioritySort = undefined }, { me, models }) => { if (!me) { throw new GqlAuthenticationError() } @@ -202,7 +202,7 @@ const resolvers = { const out = await models.wallet.findMany({ where: filter, orderBy: { - priority: 'asc' + priority: prioritySort } }) return out diff --git a/api/typeDefs/wallet.js b/api/typeDefs/wallet.js index c17e38c3..86b1d559 100644 --- a/api/typeDefs/wallet.js +++ b/api/typeDefs/wallet.js @@ -67,7 +67,7 @@ const typeDefs = ` numBolt11s: Int! connectAddress: String! walletHistory(cursor: String, inc: String): History - wallets(includeReceivers: Boolean, includeSenders: Boolean, onlyEnabled: Boolean): [Wallet!]! + wallets(includeReceivers: Boolean, includeSenders: Boolean, onlyEnabled: Boolean, prioritySort: String): [Wallet!]! wallet(id: ID!): Wallet walletByType(type: String!): Wallet walletLogs(type: String, from: String, to: String, cursor: String): WalletLog! diff --git a/fragments/wallet.js b/fragments/wallet.js index ea007f73..af8ba5a1 100644 --- a/fragments/wallet.js +++ b/fragments/wallet.js @@ -198,9 +198,19 @@ export const WALLETS = gql` } ` +export const BEST_WALLETS = gql` + query BestWallets { + wallets (includeSenders: true, includeReceivers: true, onlyEnabled: true, prioritySort: "asc") { + id + priority + type + updatedAt + } + } +` export const BEST_SEND_WALLETS = gql` - query SendWallets { - wallets (includeSenders: true, includeReceivers: false, onlyEnabled: true) { + query BestWallets { + wallets (includeSenders: true, includeReceivers: false, onlyEnabled: true, prioritySort: "asc") { id priority type