make sorting optional

This commit is contained in:
Riccardo Balbo 2024-10-16 09:21:05 +02:00 committed by k00b
parent 40f24236fd
commit bb91b629f7
3 changed files with 15 additions and 5 deletions

View File

@ -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

View File

@ -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!

View File

@ -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