Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Use typed errors for confirmAccount mutation

Marcin Gębala19fdba6d1e47
diff --git a/saleor/graphql/account/mutations/base.py b/saleor/graphql/account/mutations/base.py
index ba3e4e51d6..6358ceb02b 100644
--- a/saleor/graphql/account/mutations/base.py
+++ b/saleor/graphql/account/mutations/base.py
@@ -154,6 +154,8 @@ class RequestPasswordReset(BaseMutation):
class ConfirmAccount(BaseMutation):
+ user = graphene.Field(User, description="An activated user account.")
+
class Arguments:
token = graphene.String(
description="A one-time token required to set the password.", required=True
@@ -165,6 +167,8 @@ class ConfirmAccount(BaseMutation):
class Meta:
description = "Confirm user account by token sent by email during registration"
+ error_type_class = AccountError
+ error_type_field = "account_errors"
@classmethod
def perform_mutation(cls, _root, info, **data):
@@ -188,8 +192,7 @@ class ConfirmAccount(BaseMutation):
user.is_active = True
user.save(update_fields=["is_active"])
match_orders_with_new_user(user)
-
- return ConfirmAccount()
+ return ConfirmAccount(user=user)
class PasswordChange(BaseMutation):
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 96147a9ee5..27898da7a6 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -1051,6 +1051,8 @@ enum ConfigurationTypeFieldEnum {
type ConfirmAccount {
errors: [Error!]!
+ user: User
+ accountErrors: [AccountError!]!
}
type ConfirmEmailChange {