Skip to content

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

Separate queries for staff and customers; fix SetPassword mutation

Marcin Gębalab22133748f1c
diff --git a/saleor/graphql/account/resolvers.py b/saleor/graphql/account/resolvers.py
index 7571601f9c..e96bede120 100644
--- a/saleor/graphql/account/resolvers.py
+++ b/saleor/graphql/account/resolvers.py
@@ -6,7 +6,7 @@ from ..utils import filter_by_query_param, get_node
from .types import User
-USER_SEARCH_FIELDS = (
+CUSTOMER_SEARCH_FIELDS = (
'email', 'default_shipping_address__first_name',
'default_shipping_address__last_name', 'default_shipping_address__city',
'default_shipping_address__country')
@@ -18,7 +18,7 @@ GROUP_SEARCH_FIELDS = ('name', )
def resolve_users(info, query):
qs = models.User.objects.all().prefetch_related('addresses')
return filter_by_query_param(
- queryset=qs, query=query, search_fields=USER_SEARCH_FIELDS)
+ queryset=qs, query=query, search_fields=CUSTOMER_SEARCH_FIELDS)
@permission_required(['account.manage_users'])
diff --git a/saleor/graphql/api.py b/saleor/graphql/api.py
index 4a9afc2f3d..e07fba87dc 100644
--- a/saleor/graphql/api.py
+++ b/saleor/graphql/api.py
@@ -1,6 +1,5 @@
import graphene
import graphql_jwt
-from graphene_django.fields import DjangoConnectionField
from graphene_django.filter import DjangoFilterConnectionField
from graphql_jwt.decorators import permission_required
diff --git a/saleor/graphql/core/mutations.py b/saleor/graphql/core/mutations.py
index 06710f4504..83c93573a0 100644
--- a/saleor/graphql/core/mutations.py
+++ b/saleor/graphql/core/mutations.py
@@ -193,6 +193,7 @@ class ModelMutation(BaseMutation):
model fields' validation. Returns errors ready to be returned by
the GraphQL response (if any occured).
"""
+ print(instance.__dict__)
try:
instance.full_clean()
except ValidationError as validation_errors:
diff --git a/saleor/graphql/descriptions.py b/saleor/graphql/descriptions.py
index 8887a05046..6edc0f0998 100644
--- a/saleor/graphql/descriptions.py
+++ b/saleor/graphql/descriptions.py
@@ -1,4 +1,5 @@
-from .account.resolvers import GROUP_SEARCH_FIELDS, USER_SEARCH_FIELDS
+from .account.resolvers import (
+ CUSTOMER_SEARCH_FIELDS, GROUP_SEARCH_FIELDS, STAFF_SEARCH_FIELDS)
from .discount.resolvers import SALE_SEARCH_FIELDS, VOUCHER_SEARCH_FIELDS
from .menu.resolvers import MENU_ITEM_SEARCH_FIELDS, MENU_SEARCH_FIELDS
from .order.resolvers import ORDER_SEARCH_FIELDS
@@ -15,6 +16,7 @@ DESCRIPTIONS = {
'category': generate_query_argument_description(CATEGORY_SEARCH_FIELDS),
'collection': generate_query_argument_description(
COLLECTION_SEARCH_FIELDS),
+ 'customer': generate_query_argument_description(CUSTOMER_SEARCH_FIELDS),
'group': generate_query_argument_description(GROUP_SEARCH_FIELDS),
'menu': generate_query_argument_description(MENU_SEARCH_FIELDS),
'menu_item': generate_query_argument_description(MENU_ITEM_SEARCH_FIELDS),
@@ -23,4 +25,4 @@ DESCRIPTIONS = {
'product': generate_query_argument_description(PRODUCT_SEARCH_FIELDS),
'voucher': generate_query_argument_description(VOUCHER_SEARCH_FIELDS),
'sale': generate_query_argument_description(SALE_SEARCH_FIELDS),
- 'user': generate_query_argument_description(USER_SEARCH_FIELDS)}
+ 'staff': generate_query_argument_description(STAFF_SEARCH_FIELDS)}