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

View File

@ -121,7 +121,7 @@ export async function processXComPendingSendCoins(
} }
} }
} catch (err) { } catch (err) {
logger.error(`Error:`, err) throw new LogError(`Error:`, err)
} }
return sendCoinsResult 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 { export class SendCoinsResult {
constructor() { constructor() {
this.vote = false this.vote = false
@ -9,9 +9,9 @@ export class SendCoinsResult {
@Field(() => Boolean) @Field(() => Boolean)
vote: boolean vote: boolean
@Field(() => String, { nullable: true }) @Field(() => String)
recipGradidoID: string | null recipGradidoID: string | null
@Field(() => String, { nullable: true }) @Field(() => String)
recipName: string | null recipName: string | null
} }

View File

@ -68,8 +68,13 @@ describe('SendCoinsResolver', () => {
senderCommunityUuid: $senderCommunityUuid senderCommunityUuid: $senderCommunityUuid
senderUserUuid: $senderUserUuid senderUserUuid: $senderUserUuid
senderUserName: $senderUserName senderUserName: $senderUserName
) ) {
}` vote
recipGradidoID
recipName
}
}
`
const settleSendCoinsMutation = ` const settleSendCoinsMutation = `
mutation ( mutation (
@ -220,7 +225,11 @@ describe('SendCoinsResolver', () => {
).toEqual( ).toEqual(
expect.objectContaining({ expect.objectContaining({
data: { 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() @Resolver()
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
export class SendCoinsResolver { export class SendCoinsResolver {
@Mutation(() => String) @Mutation(() => SendCoinsResult)
async voteForSendCoins( async voteForSendCoins(
@Args() @Args()
{ {