Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add public metadata to User
Jakub Draganek056ec1bbb99e
diff --git a/saleor/graphql/account/types.py b/saleor/graphql/account/types.pyindex 30f75d3a9b..9c4ee37e39 100644--- a/saleor/graphql/account/types.py+++ b/saleor/graphql/account/types.py@@ -192,7 +192,12 @@ class User(CountableDjangoObjectType):private_meta = graphene.List(MetaStore,required=True,- description="List of privately stored metadata groups.",+ description="List of privately stored metadata namespaces.",+ )+ meta = graphene.List(+ MetaStore,+ required=True,+ description="List of publicly stored metadata namespaces.",)class Meta:@@ -282,6 +287,10 @@ class User(CountableDjangoObjectType):key=itemgetter("namespace"),)+ @staticmethod+ def resolve_meta(root: models.User, _info):+ return []+class ChoiceValue(graphene.ObjectType):raw = graphene.String()diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 9ac5e1e55e..777364236b 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -3097,6 +3097,7 @@ type User implements Node {events: [CustomerEvent]storedPaymentSources: [PaymentSource]privateMeta: [MetaStore]!+ meta: [MetaStore]!}input UserAddressInput {diff --git a/tests/api/test_account_meta.py b/tests/api/test_account_meta.pyindex 52342f5cc4..507bdc62e9 100644--- a/tests/api/test_account_meta.py+++ b/tests/api/test_account_meta.py@@ -6,6 +6,8 @@ import pytestfrom tests.api.utils import get_graphql_contentMETA_NAMESPACE = "TEST_NAMESPACE"++META_CLIENT = "TEST_PLUGIN"KEY = "name"@@ -224,3 +226,29 @@ def test_clear_silentyle_metadata_from_nonexistent_client(assert meta["clients"] == [{"metadata": [{"key": KEY, "value": VALUE}], "name": META_CLIENT}]+++MY_PUBLIC_META_QUERY = """+ {+ me {+ meta {+ namespace+ clients {+ name+ metadata {+ key+ value+ }+ }+ }+ }+ }+"""+++def test_access_users_public_metadata(user_api_client, customer_with_meta):+ response = user_api_client.post_graphql(MY_PUBLIC_META_QUERY)+ data = json.loads(response.content.decode("utf8"))+ assert "errors" not in data+ assert data["data"]["me"]["meta"] == []