Expose KYC pricing context
Build and deploy Docker image / build (push) Successful in 2m35s

This commit is contained in:
Ruslan Bakiev
2026-08-24 18:09:10 +07:00
parent a89e66f373
commit d992e67d32
2 changed files with 34 additions and 1 deletions
+33
View File
@@ -1,6 +1,13 @@
import { prisma } from '../db.js'
export const m2mTypeDefs = `#graphql
type KycPricingContext {
userId: String!
profileUuid: String!
countryCode: String!
resolvedAt: String!
}
type CreateKycProfileResult {
success: Boolean!
profileUuid: String
@@ -9,6 +16,7 @@ export const m2mTypeDefs = `#graphql
type Query {
health: String!
pricingContextForUser(userId: String!): KycPricingContext
}
type Mutation {
@@ -59,9 +67,34 @@ async function createProfile(_: unknown, args: { kycApplicationId: string }) {
}
}
async function pricingContextForUser(_: unknown, args: { userId: string }) {
const profile = await prisma.kYCProfile.findFirst({
where: {
userId: args.userId,
workflowStatus: {
in: ['active', 'approved'],
},
},
orderBy: {
updatedAt: 'desc',
},
})
if (profile === null) return null
if (profile.countryCode.length !== 2) {
throw new Error(`Active KYC profile ${profile.uuid} has no valid country code`)
}
return {
userId: profile.userId,
profileUuid: profile.uuid,
countryCode: profile.countryCode.toUpperCase(),
resolvedAt: profile.updatedAt.toISOString(),
}
}
export const m2mResolvers = {
Query: {
health: () => 'ok',
pricingContextForUser,
},
Mutation: {
createKycProfile: createProfile,