Fix KYC user resolvers when root is None
All checks were successful
Build Docker Image / build (push) Successful in 1m41s
All checks were successful
Build Docker Image / build (push) Successful in 1m41s
This commit is contained in:
@@ -86,6 +86,23 @@ class CreateKYCApplicationRussia(graphene.Mutation):
|
|||||||
return CreateKYCApplicationRussia(kyc_application=kyc_application, success=True)
|
return CreateKYCApplicationRussia(kyc_application=kyc_application, success=True)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_applications(info):
|
||||||
|
user_id = getattr(info.context, 'user_id', None)
|
||||||
|
if not user_id:
|
||||||
|
return []
|
||||||
|
return KYCApplication.objects.filter(user_id=user_id)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_application(info, uuid):
|
||||||
|
user_id = getattr(info.context, 'user_id', None)
|
||||||
|
if not user_id:
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
return KYCApplication.objects.get(uuid=uuid, user_id=user_id)
|
||||||
|
except KYCApplication.DoesNotExist:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class UserQuery(graphene.ObjectType):
|
class UserQuery(graphene.ObjectType):
|
||||||
"""User schema - ID token authentication"""
|
"""User schema - ID token authentication"""
|
||||||
# Keep old names for backwards compatibility
|
# Keep old names for backwards compatibility
|
||||||
@@ -95,32 +112,17 @@ class UserQuery(graphene.ObjectType):
|
|||||||
kyc_applications = graphene.List(KYCApplicationType, description="Get user's KYC applications")
|
kyc_applications = graphene.List(KYCApplicationType, description="Get user's KYC applications")
|
||||||
kyc_application = graphene.Field(KYCApplicationType, uuid=graphene.String(required=True))
|
kyc_application = graphene.Field(KYCApplicationType, uuid=graphene.String(required=True))
|
||||||
|
|
||||||
def resolve_kyc_requests(self, info):
|
def resolve_kyc_requests(root, info):
|
||||||
return self._get_applications(info)
|
return _get_applications(info)
|
||||||
|
|
||||||
def resolve_kyc_applications(self, info):
|
def resolve_kyc_applications(root, info):
|
||||||
return self._get_applications(info)
|
return _get_applications(info)
|
||||||
|
|
||||||
def _get_applications(self, info):
|
def resolve_kyc_request(root, info, uuid):
|
||||||
user_id = getattr(info.context, 'user_id', None)
|
return _get_application(info, uuid)
|
||||||
if not user_id:
|
|
||||||
return []
|
|
||||||
return KYCApplication.objects.filter(user_id=user_id)
|
|
||||||
|
|
||||||
def resolve_kyc_request(self, info, uuid):
|
def resolve_kyc_application(root, info, uuid):
|
||||||
return self._get_application(info, uuid)
|
return _get_application(info, uuid)
|
||||||
|
|
||||||
def resolve_kyc_application(self, info, uuid):
|
|
||||||
return self._get_application(info, uuid)
|
|
||||||
|
|
||||||
def _get_application(self, info, uuid):
|
|
||||||
user_id = getattr(info.context, 'user_id', None)
|
|
||||||
if not user_id:
|
|
||||||
return None
|
|
||||||
try:
|
|
||||||
return KYCApplication.objects.get(uuid=uuid, user_id=user_id)
|
|
||||||
except KYCApplication.DoesNotExist:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class UserMutation(graphene.ObjectType):
|
class UserMutation(graphene.ObjectType):
|
||||||
|
|||||||
Reference in New Issue
Block a user