correct graphql result definition for voteForSendCoins

This commit is contained in:
Claus-Peter Huebner 2023-09-20 16:47:59 +02:00
parent 32496a0353
commit fe85e45d38
5 changed files with 25 additions and 13 deletions

View File

@ -34,18 +34,21 @@ export class SendCoinsClient {
voteForSendCoins = async (args: SendCoinsArgs): Promise<SendCoinsResult> => {
logger.debug('X-Com: voteForSendCoins against endpoint=', this.endpoint)
try {
logger.debug(`SendCoinsClient: voteForSendCoins with args=`, args)
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { data } = await this.client.rawRequest(voteForSendCoins, { args })
logger.debug(`SendCoinsClient: after rawRequest...`, data)
const sendCoinsResult = data as SendCoinsResult
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (!data?.voteForSendCoins?.vote) {
if (!sendCoinsResult.vote) {
logger.warn(
'X-Com: voteForSendCoins failed with: ',
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
data.voteForSendCoins.recipGradidoID,
sendCoinsResult.recipGradidoID,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
data.voteForSendCoins.recipName,
sendCoinsResult.recipName,
)
return new SendCoinsResult()
return sendCoinsResult
}
const result = new SendCoinsResult()
result.vote = true

View File

@ -121,7 +121,7 @@ export async function processXComPendingSendCoins(
}
}
} catch (err) {
logger.error(`Error:`, err)
throw new LogError(`Error:`, err)
}
return sendCoinsResult
}

View File

@ -1,6 +1,6 @@
import { ArgsType, Field } from 'type-graphql'
import { Field, ObjectType } from 'type-graphql'
@ArgsType()
@ObjectType()
export class SendCoinsResult {
constructor() {
this.vote = false
@ -9,9 +9,9 @@ export class SendCoinsResult {
@Field(() => Boolean)
vote: boolean
@Field(() => String, { nullable: true })
@Field(() => String)
recipGradidoID: string | null
@Field(() => String, { nullable: true })
@Field(() => String)
recipName: string | null
}

View File

@ -68,8 +68,13 @@ describe('SendCoinsResolver', () => {
senderCommunityUuid: $senderCommunityUuid
senderUserUuid: $senderUserUuid
senderUserName: $senderUserName
)
}`
) {
vote
recipGradidoID
recipName
}
}
`
const settleSendCoinsMutation = `
mutation (
@ -220,7 +225,11 @@ describe('SendCoinsResolver', () => {
).toEqual(
expect.objectContaining({
data: {
voteForSendCoins: 'recipUser-FirstName recipUser-LastName',
voteForSendCoins: {
recipGradidoID: '56a55482-909e-46a4-bfa2-cd025e894ebd',
recipName: 'recipUser-FirstName recipUser-LastName',
vote: true,
},
},
}),
)

View File

@ -19,7 +19,7 @@ import { SendCoinsResult } from '../model/SendCoinsResult'
@Resolver()
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export class SendCoinsResolver {
@Mutation(() => String)
@Mutation(() => SendCoinsResult)
async voteForSendCoins(
@Args()
{