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