Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Change metadata implementation to graphene interface
fowczarek5303b1666726
diff --git a/saleor/graphql/account/types.py b/saleor/graphql/account/types.pyindex aa2808b97c..4e35186dc5 100644--- a/saleor/graphql/account/types.py+++ b/saleor/graphql/account/types.py@@ -13,7 +13,7 @@ from ..checkout.types import Checkoutfrom ..core.connection import CountableDjangoObjectTypefrom ..core.fields import PrefetchingConnectionFieldfrom ..core.resolvers import resolve_meta, resolve_private_meta-from ..core.types import CountryDisplay, Image, MetadataObjectType, PermissionDisplay+from ..core.types import CountryDisplay, Image, ObjectWithMetadata, PermissionDisplayfrom ..core.utils import get_node_optimizedfrom ..decorators import one_of_permissions_required, permission_requiredfrom ..utils import format_permissions_for_display@@ -186,7 +186,7 @@ class ServiceAccountToken(CountableDjangoObjectType):@key(fields="id")-class ServiceAccount(MetadataObjectType, CountableDjangoObjectType):+class ServiceAccount(CountableDjangoObjectType):permissions = graphene.List(PermissionDisplay, description="List of the service's permissions.")@@ -204,7 +204,7 @@ class ServiceAccount(MetadataObjectType, CountableDjangoObjectType):class Meta:description = "Represents service account data."- interfaces = [relay.Node]+ interfaces = [relay.Node, ObjectWithMetadata]model = models.ServiceAccountpermissions = (AccountPermissions.MANAGE_SERVICE_ACCOUNTS,)only_fields = [@@ -239,7 +239,7 @@ class ServiceAccount(MetadataObjectType, CountableDjangoObjectType):@key("id")@key("email")-class User(MetadataObjectType, CountableDjangoObjectType):+class User(CountableDjangoObjectType):addresses = gql_optimizer.field(graphene.List(Address, description="List of all user's addresses."),model_field="addresses",@@ -279,7 +279,7 @@ class User(MetadataObjectType, CountableDjangoObjectType):class Meta:description = "Represents user data."- interfaces = [relay.Node]+ interfaces = [relay.Node, ObjectWithMetadata]model = get_user_model()only_fields = ["date_joined",diff --git a/saleor/graphql/checkout/types.py b/saleor/graphql/checkout/types.pyindex 017c4652d6..a2aebd838d 100644--- a/saleor/graphql/checkout/types.py+++ b/saleor/graphql/checkout/types.py@@ -9,7 +9,7 @@ from ...core.taxes import display_gross_prices, zero_taxed_moneyfrom ...extensions.manager import get_extensions_managerfrom ..core.connection import CountableDjangoObjectTypefrom ..core.resolvers import resolve_meta, resolve_private_meta-from ..core.types.meta import MetadataObjectType+from ..core.types.meta import ObjectWithMetadatafrom ..core.types.money import TaxedMoneyfrom ..decorators import permission_requiredfrom ..giftcard.types import GiftCard@@ -66,7 +66,7 @@ class CheckoutLine(CountableDjangoObjectType):return root.is_shipping_required()-class Checkout(MetadataObjectType, CountableDjangoObjectType):+class Checkout(CountableDjangoObjectType):available_shipping_methods = graphene.List(ShippingMethod,required=True,@@ -131,7 +131,7 @@ class Checkout(MetadataObjectType, CountableDjangoObjectType):]description = "Checkout object."model = models.Checkout- interfaces = [graphene.relay.Node]+ interfaces = [graphene.relay.Node, ObjectWithMetadata]filter_fields = ["token"]@staticmethoddiff --git a/saleor/graphql/core/types/__init__.py b/saleor/graphql/core/types/__init__.pyindex 7d20929a2c..4a6a30cf9d 100644--- a/saleor/graphql/core/types/__init__.py+++ b/saleor/graphql/core/types/__init__.py@@ -10,7 +10,7 @@ from .common import (Weight,)from .filter_input import FilterInputObjectType-from .meta import MetadataObjectType, MetaInput, MetaPath+from .meta import MetaInput, MetaPath, ObjectWithMetadatafrom .money import VAT, Money, MoneyRange, ReducedRate, TaxedMoney, TaxedMoneyRangefrom .sort_input import SortInputObjectTypefrom .upload import Uploaddiff --git a/saleor/graphql/core/types/meta.py b/saleor/graphql/core/types/meta.pyindex 8d4a678b24..0b84ddf342 100644--- a/saleor/graphql/core/types/meta.py+++ b/saleor/graphql/core/types/meta.py@@ -55,7 +55,7 @@ class MetaInput(MetaPath):value = graphene.String(required=True, description="Stored metadata value.")-class MetadataObjectType(graphene.ObjectType):+class ObjectWithMetadata(graphene.Interface):private_meta = graphene.List(MetaStore,required=True,diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.pyindex 9a9555f437..89d457dde7 100644--- a/saleor/graphql/order/types.py+++ b/saleor/graphql/order/types.py@@ -15,7 +15,7 @@ from ..account.types import Userfrom ..core.connection import CountableDjangoObjectTypefrom ..core.resolvers import resolve_meta, resolve_private_metafrom ..core.types.common import Image-from ..core.types.meta import MetadataObjectType+from ..core.types.meta import ObjectWithMetadatafrom ..core.types.money import Money, TaxedMoneyfrom ..decorators import permission_requiredfrom ..giftcard.types import GiftCard@@ -168,7 +168,7 @@ class FulfillmentLine(CountableDjangoObjectType):return root.order_line-class Fulfillment(MetadataObjectType, CountableDjangoObjectType):+class Fulfillment(CountableDjangoObjectType):lines = gql_optimizer.field(graphene.List(FulfillmentLine, description="List of lines for the fulfillment."@@ -179,7 +179,7 @@ class Fulfillment(MetadataObjectType, CountableDjangoObjectType):class Meta:description = "Represents order fulfillment."- interfaces = [relay.Node]+ interfaces = [relay.Node, ObjectWithMetadata]model = models.Fulfillmentonly_fields = ["fulfillment_order",@@ -274,7 +274,7 @@ class OrderLine(CountableDjangoObjectType):return root.translated_variant_name-class Order(MetadataObjectType, CountableDjangoObjectType):+class Order(CountableDjangoObjectType):fulfillments = gql_optimizer.field(graphene.List(Fulfillment, required=True, description="List of shipments for the order."@@ -350,7 +350,7 @@ class Order(MetadataObjectType, CountableDjangoObjectType):class Meta:description = "Represents an order in the shop."- interfaces = [relay.Node]+ interfaces = [relay.Node, ObjectWithMetadata]model = models.Orderonly_fields = ["billing_address",diff --git a/saleor/graphql/product/types/attributes.py b/saleor/graphql/product/types/attributes.pyindex 94b8485644..e271bfd90e 100644--- a/saleor/graphql/product/types/attributes.py+++ b/saleor/graphql/product/types/attributes.py@@ -8,7 +8,7 @@ from ....core.permissions import ProductPermissionsfrom ....product import modelsfrom ...core.connection import CountableDjangoObjectTypefrom ...core.resolvers import resolve_meta, resolve_private_meta-from ...core.types import MetadataObjectType+from ...core.types import ObjectWithMetadatafrom ...decorators import permission_requiredfrom ...translations.fields import TranslationFieldfrom ...translations.types import AttributeTranslation, AttributeValueTranslation@@ -58,7 +58,7 @@ class AttributeValue(CountableDjangoObjectType):return root.input_type-class Attribute(CountableDjangoObjectType, MetadataObjectType):+class Attribute(CountableDjangoObjectType):input_type = AttributeInputTypeEnum(description=AttributeDescriptions.INPUT_TYPE)name = graphene.String(description=AttributeDescriptions.NAME)@@ -97,7 +97,7 @@ class Attribute(CountableDjangoObjectType, MetadataObjectType):"variants at the product type level.")only_fields = ["id", "product_types", "product_variant_types"]- interfaces = [relay.Node]+ interfaces = [relay.Node, ObjectWithMetadata]model = models.Attribute@staticmethoddiff --git a/saleor/graphql/product/types/digital_contents.py b/saleor/graphql/product/types/digital_contents.pyindex 2a98b76179..959ae6212f 100644--- a/saleor/graphql/product/types/digital_contents.py+++ b/saleor/graphql/product/types/digital_contents.py@@ -6,7 +6,7 @@ from ....core.permissions import ProductPermissionsfrom ....product import modelsfrom ...core.connection import CountableDjangoObjectTypefrom ...core.resolvers import resolve_meta, resolve_private_meta-from ...core.types import MetadataObjectType+from ...core.types import ObjectWithMetadatafrom ...decorators import permission_required@@ -23,7 +23,7 @@ class DigitalContentUrl(CountableDjangoObjectType):return root.get_absolute_url()-class DigitalContent(CountableDjangoObjectType, MetadataObjectType):+class DigitalContent(CountableDjangoObjectType):urls = gql_optimizer.field(graphene.List(lambda: DigitalContentUrl,@@ -43,7 +43,7 @@ class DigitalContent(CountableDjangoObjectType, MetadataObjectType):"urls","use_default_settings",]- interfaces = (relay.Node,)+ interfaces = (relay.Node, ObjectWithMetadata)@staticmethoddef resolve_urls(root: models.DigitalContent, info, **_kwargs):diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.pyindex a69d585fab..a36097190c 100644--- a/saleor/graphql/product/types/products.py+++ b/saleor/graphql/product/types/products.py@@ -34,9 +34,9 @@ from ...core.fields import FilterInputConnectionField, PrefetchingConnectionFielfrom ...core.resolvers import resolve_meta, resolve_private_metafrom ...core.types import (Image,- MetadataObjectType,Money,MoneyRange,+ ObjectWithMetadata,TaxedMoney,TaxedMoneyRange,TaxType,@@ -194,7 +194,7 @@ class ProductPricingInfo(BasePricingInfo):@key(fields="id")-class ProductVariant(CountableDjangoObjectType, MetadataObjectType):+class ProductVariant(CountableDjangoObjectType):quantity = graphene.Int(required=True,description="Quantity of a product in the store's possession, "@@ -282,7 +282,7 @@ class ProductVariant(CountableDjangoObjectType, MetadataObjectType):"Represents a version of a product such as different size or color.")only_fields = ["id", "name", "product", "sku", "track_inventory", "weight"]- interfaces = [relay.Node]+ interfaces = [relay.Node, ObjectWithMetadata]model = models.ProductVariant@staticmethod@@ -408,7 +408,7 @@ class ProductVariant(CountableDjangoObjectType, MetadataObjectType):@key(fields="id")-class Product(CountableDjangoObjectType, MetadataObjectType):+class Product(CountableDjangoObjectType):url = graphene.String(description="The storefront URL for the product.", required=True)@@ -466,7 +466,7 @@ class Product(CountableDjangoObjectType, MetadataObjectType):class Meta:description = "Represents an individual item for sale in the storefront."- interfaces = [relay.Node]+ interfaces = [relay.Node, ObjectWithMetadata]model = models.Productonly_fields = ["category",@@ -614,7 +614,7 @@ class Product(CountableDjangoObjectType, MetadataObjectType):@key(fields="id")-class ProductType(CountableDjangoObjectType, MetadataObjectType):+class ProductType(CountableDjangoObjectType):products = gql_optimizer.field(PrefetchingConnectionField(Product, description="List of products of this type."@@ -640,7 +640,7 @@ class ProductType(CountableDjangoObjectType, MetadataObjectType):"Represents a type of product. It defines what attributes are available to ""products of this type.")- interfaces = [relay.Node]+ interfaces = [relay.Node, ObjectWithMetadata]model = models.ProductTypeonly_fields = ["has_variants",@@ -708,7 +708,7 @@ class ProductType(CountableDjangoObjectType, MetadataObjectType):@key(fields="id")-class Collection(CountableDjangoObjectType, MetadataObjectType):+class Collection(CountableDjangoObjectType):products = gql_optimizer.field(PrefetchingConnectionField(Product, description="List of products in this collection."@@ -733,7 +733,7 @@ class Collection(CountableDjangoObjectType, MetadataObjectType):"seo_title","slug",]- interfaces = [relay.Node]+ interfaces = [relay.Node, ObjectWithMetadata]model = models.Collection@staticmethod@@ -777,7 +777,7 @@ class Collection(CountableDjangoObjectType, MetadataObjectType):@key(fields="id")-class Category(CountableDjangoObjectType, MetadataObjectType):+class Category(CountableDjangoObjectType):ancestors = PrefetchingConnectionField(lambda: Category, description="List of ancestors of the category.")@@ -814,7 +814,7 @@ class Category(CountableDjangoObjectType, MetadataObjectType):"seo_title","slug",]- interfaces = [relay.Node]+ interfaces = [relay.Node, ObjectWithMetadata]model = models.Category@staticmethoddiff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 92cd7c8bd7..2b96486c07 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -190,7 +190,7 @@ type AssignNavigation {menuErrors: [MenuError!]}-type Attribute implements Node {+type Attribute implements Node, ObjectWithMetadata {id: ID!productTypes(before: String, after: String, first: Int, last: Int): ProductTypeCountableConnection!productVariantTypes(before: String, after: String, first: Int, last: Int): ProductTypeCountableConnection!@@ -497,7 +497,7 @@ input CatalogueInput {collections: [ID]}-type Category implements Node {+type Category implements Node, ObjectWithMetadata {seoTitle: StringseoDescription: Stringid: ID!@@ -628,7 +628,7 @@ type CategoryUpdatePrivateMeta {category: Category}-type Checkout implements Node {+type Checkout implements Node, ObjectWithMetadata {created: DateTime!lastChange: DateTime!user: User@@ -841,7 +841,7 @@ type ChoiceValue {verbose: String}-type Collection implements Node {+type Collection implements Node, ObjectWithMetadata {seoTitle: StringseoDescription: Stringid: ID!@@ -1402,7 +1402,7 @@ input DateTimeRangeInput {scalar Decimal-type DigitalContent implements Node {+type DigitalContent implements Node, ObjectWithMetadata {useDefaultSettings: Boolean!automaticFulfillment: Boolean!productVariant: ProductVariant!@@ -1597,7 +1597,7 @@ enum ExtensionsErrorCode {UNIQUE}-type Fulfillment implements Node {+type Fulfillment implements Node, ObjectWithMetadata {id: ID!fulfillmentOrder: Int!status: FulfillmentStatus!@@ -2371,7 +2371,12 @@ interface Node {id: ID!}-type Order implements Node {+interface ObjectWithMetadata {+ privateMeta: [MetaStore]!+ meta: [MetaStore]!+}++type Order implements Node, ObjectWithMetadata {id: ID!created: DateTime!status: OrderStatus!@@ -3063,7 +3068,7 @@ input PriceRangeInput {lte: Float}-type Product implements Node {+type Product implements Node, ObjectWithMetadata {id: ID!seoTitle: StringseoDescription: String@@ -3320,7 +3325,7 @@ type ProductTranslation implements Node {language: LanguageDisplay!}-type ProductType implements Node {+type ProductType implements Node, ObjectWithMetadata {id: ID!name: String!slug: String!@@ -3461,7 +3466,7 @@ type ProductUpdatePrivateMeta {product: Product}-type ProductVariant implements Node {+type ProductVariant implements Node, ObjectWithMetadata {id: ID!name: String!sku: String!@@ -3821,7 +3826,7 @@ input SeoInput {description: String}-type ServiceAccount implements Node {+type ServiceAccount implements Node, ObjectWithMetadata {id: ID!created: DateTimeisActive: Boolean@@ -4452,7 +4457,7 @@ scalar UUIDscalar Upload-type User implements Node {+type User implements Node, ObjectWithMetadata {id: ID!lastLogin: DateTimeemail: String!