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' import { prisma } from '../db.js'
export const m2mTypeDefs = `#graphql export const m2mTypeDefs = `#graphql
type KycPricingContext {
userId: String!
profileUuid: String!
countryCode: String!
resolvedAt: String!
}
type CreateKycProfileResult { type CreateKycProfileResult {
success: Boolean! success: Boolean!
profileUuid: String profileUuid: String
@@ -9,6 +16,7 @@ export const m2mTypeDefs = `#graphql
type Query { type Query {
health: String! health: String!
pricingContextForUser(userId: String!): KycPricingContext
} }
type Mutation { 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 = { export const m2mResolvers = {
Query: { Query: {
health: () => 'ok', health: () => 'ok',
pricingContextForUser,
}, },
Mutation: { Mutation: {
createKycProfile: createProfile, createKycProfile: createProfile,