mirror of
https://github.com/Retropex/apolloapi-v2.git
synced 2025-05-28 13:02:35 +02:00
Added poolsUpdate to API
This commit is contained in:
parent
ace08c7167
commit
025877355d
31
src/graphql/graphqlModules/Pool/PoolsUpdate.js
Normal file
31
src/graphql/graphqlModules/Pool/PoolsUpdate.js
Normal file
@ -0,0 +1,31 @@
|
||||
module.exports.typeDefs = `
|
||||
type PoolActions {
|
||||
updateAll (input: [PoolsUpdateInput!]!): PoolsUpdateOutput!
|
||||
}
|
||||
|
||||
input PoolsUpdateInput {
|
||||
index: Int!
|
||||
enabled: Boolean!
|
||||
url: String!
|
||||
username: String
|
||||
password: String
|
||||
proxy: String
|
||||
}
|
||||
|
||||
type PoolsUpdateOutput {
|
||||
result: PoolsUpdateResult
|
||||
error: Error
|
||||
}
|
||||
|
||||
type PoolsUpdateResult {
|
||||
pools: [Pool!]!
|
||||
}
|
||||
`
|
||||
|
||||
module.exports.resolvers = {
|
||||
PoolActions: {
|
||||
updateAll (root, args, { dispatch }) {
|
||||
return dispatch('api/pools/updateAll', args.input)
|
||||
}
|
||||
}
|
||||
}
|
8
src/store/api/pools/collection/poolsUpdate.js
Normal file
8
src/store/api/pools/collection/poolsUpdate.js
Normal file
@ -0,0 +1,8 @@
|
||||
module.exports = ({ define }) => {
|
||||
define('updateAll', async (data = {}, { dispatch, knex, errors, utils }) => {
|
||||
return await knex.transaction(async function(trx) {
|
||||
await trx.delete().from('pools')
|
||||
await trx.insert(data).into('pools')
|
||||
});
|
||||
})
|
||||
}
|
9
src/store/api/pools/poolsUpdate.js
Normal file
9
src/store/api/pools/poolsUpdate.js
Normal file
@ -0,0 +1,9 @@
|
||||
module.exports = ({ define }) => {
|
||||
define('updateAll', async (payload, { dispatch, errors, utils }) => {
|
||||
await dispatch('api/pools/collection/updateAll', payload)
|
||||
const { items: pools } = await dispatch('api/pools/collection/read', {})
|
||||
return {
|
||||
pools
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user