This commit is contained in:
+1
-1
Submodule graphql-contracts updated: 7b6c8ce509...1932411ebf
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user