Skip to content

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

Add objevt with attributes interface (#18156)

Maciej Korycinski75891d7750b4
diff --git a/saleor/graphql/attribute/types.py b/saleor/graphql/attribute/types.py
index 727f734271..3991042a42 100644
--- a/saleor/graphql/attribute/types.py
+++ b/saleor/graphql/attribute/types.py
@@ -1443,3 +1443,32 @@ ASSIGNED_ATTRIBUTE_TYPES = (
+ list(ASSIGNED_SINGLE_REFERENCE_MAP.values())
+ list(ASSIGNED_MULTI_REFERENCE_MAP.values())
)
+
+
+class ObjectWithAttributes(BaseInterface):
+ assigned_attribute = graphene.Field(
+ AssignedAttribute,
+ slug=graphene.Argument(
+ graphene.String,
+ description="Slug of the attribute",
+ required=True,
+ ),
+ description="Get a single attribute attached to the object by attribute slug."
+ + ADDED_IN_322,
+ )
+ assigned_attributes = NonNullList(
+ AssignedAttribute,
+ required=True,
+ description="List of attributes assigned to the object." + ADDED_IN_322,
+ limit=PositiveInt(
+ description=(
+ "Maximum number of attributes to return. "
+ f"Default is {DEFAULT_NESTED_LIST_LIMIT}."
+ ),
+ default_value=DEFAULT_NESTED_LIST_LIMIT,
+ ),
+ )
+
+ class Meta:
+ description = "An object with attributes." + ADDED_IN_322
+ doc_category = DOC_CATEGORY_ATTRIBUTES
diff --git a/saleor/graphql/page/types.py b/saleor/graphql/page/types.py
index 5fb4dce804..dda90cca8e 100644
--- a/saleor/graphql/page/types.py
+++ b/saleor/graphql/page/types.py
@@ -10,7 +10,12 @@ from ..attribute.filters import (
AttributeWhereInput,
filter_attribute_search,
)
-from ..attribute.types import Attribute, AttributeCountableConnection, SelectedAttribute
+from ..attribute.types import (
+ Attribute,
+ AttributeCountableConnection,
+ ObjectWithAttributes,
+ SelectedAttribute,
+)
from ..attribute.utils.shared import AssignedAttributeData
from ..core import ResolveInfo
from ..core.connection import (
@@ -226,7 +231,7 @@ class Page(ChannelContextType[models.Page]):
"A static page that can be manually added by a shop operator through the "
"dashboard."
)
- interfaces = [graphene.relay.Node, ObjectWithMetadata]
+ interfaces = [graphene.relay.Node, ObjectWithMetadata, ObjectWithAttributes]
model = models.Page
@staticmethod
diff --git a/saleor/graphql/product/tests/queries/test_product_variant_query.py b/saleor/graphql/product/tests/queries/test_product_variant_query.py
index bf8a4ae043..f7a1f27f90 100644
--- a/saleor/graphql/product/tests/queries/test_product_variant_query.py
+++ b/saleor/graphql/product/tests/queries/test_product_variant_query.py
@@ -1,5 +1,4 @@
import graphene
-import pytest
from django.contrib.sites.models import Site
from measurement.measures import Weight
@@ -8,7 +7,6 @@ from .....core.units import WeightUnits
from .....warehouse import WarehouseClickAndCollectOption
from ....core.enums import WeightUnitsEnum
from ....tests.utils import assert_no_permission, get_graphql_content
-from ...enums import VariantAttributeScope
QUERY_VARIANT = """query ProductVariantDetails(
$id: ID!, $address: AddressInput, $countryCode: CountryCode, $channel: String
@@ -863,73 +861,6 @@ def test_query_product_variant_for_federation_as_staff_user_without_chanel(
]
- "variant_selection",
- [
- VariantAttributeScope.ALL.name,
- VariantAttributeScope.VARIANT_SELECTION.name,
- ],
-)
-def test_applies_limit_on_product_assigned_attributes(
- variant,
- channel_USD,
- user_api_client,
- size_attribute,
- weight_attribute,
- variant_selection,
-):
- # given
- query = """
- query productVariant($id: ID!, $channel: String, $variantSelection: VariantAttributeScope) {
- productVariant(id: $id, channel: $channel) {
- assignedAttributes(limit: 1, variantSelection: $variantSelection) {
- attribute {
- slug
- }
- }
- }
- }
- """
-
- product_type = variant.product.product_type
- product_type.variant_attributes.set([size_attribute, weight_attribute])
-
- weight_attribute.storefront_search_position = (
- size_attribute.storefront_search_position + 1
- )
- weight_attribute.save(update_fields=["storefront_search_position"])
-
- associate_attribute_values_to_instance(
- variant,
- {
- size_attribute.pk: [size_attribute.values.first()],
- weight_attribute.pk: [weight_attribute.values.first()],
- },
- )
-
- variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)
- variables = {
- "id": variant_id,
- "channel": channel_USD.slug,
- "variantSelection": variant_selection,
- }
-
- # when
- response = user_api_client.post_graphql(query, variables)
-
- # then
- content = get_graphql_content(response)
-
- expected_limit = 1
- assert (
- len(content["data"]["productVariant"]["assignedAttributes"]) == expected_limit
- )
- assert (
- content["data"]["productVariant"]["assignedAttributes"][0]["attribute"]["slug"]
- == size_attribute.slug
- )
-
-
QUERY_PRODUCT_VARIANT_WITH_ASSIGNED_ATTRIBUTE = """
query productVariant($id: ID!, $channel: String, $attrSlug: String!) {
productVariant(id: $id, channel: $channel) {
diff --git a/saleor/graphql/product/tests/queries/test_variant_query.py b/saleor/graphql/product/tests/queries/test_variant_query.py
index 5c9afcfa03..2ba5294b6a 100644
--- a/saleor/graphql/product/tests/queries/test_variant_query.py
+++ b/saleor/graphql/product/tests/queries/test_variant_query.py
@@ -28,7 +28,7 @@ query variant(
id
sku
externalReference
- assignedAttributes(variantSelection: $variantSelection) {
+ assignedAttributes {
attribute {
slug
}
@@ -581,20 +581,12 @@ def test_get_variant_by_id_with_variant_selection_filter(
data["attributes"][0]["attribute"]["slug"]
== file_attribute_with_file_input_type_without_values.slug
)
- assert len(data["assignedAttributes"]) == 1
- assert (
- data["assignedAttributes"][0]["attribute"]["slug"]
- == file_attribute_with_file_input_type_without_values.slug
- )
elif variant_selection == VariantAttributeScope.VARIANT_SELECTION.name:
assert len(data["attributes"]) == 1
assert data["attributes"][0]["attribute"]["slug"] == size_attribute.slug
- assert len(data["assignedAttributes"]) == 1
- assert data["assignedAttributes"][0]["attribute"]["slug"] == size_attribute.slug
else:
assert len(data["attributes"]) == 2
- assert len(data["assignedAttributes"]) == 2
def test_get_variant_with_sorted_attribute_values(
diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.py
index 2077137b40..85c191efbd 100644
--- a/saleor/graphql/product/types/products.py
+++ b/saleor/graphql/product/types/products.py
@@ -49,6 +49,7 @@ from ...attribute.types import (
AssignedVariantAttribute,
Attribute,
AttributeCountableConnection,
+ ObjectWithAttributes,
SelectedAttribute,
)
from ...attribute.utils.shared import AssignedAttributeData
@@ -354,10 +355,6 @@ class ProductVariant(ChannelContextType[models.ProductVariant]):
AssignedAttribute,
required=True,
description="List of attributes assigned to this variant." + ADDED_IN_322,
- variant_selection=graphene.Argument(
- VariantAttributeScope,
- description="Define scope of returned attributes.",
- ),
limit=PositiveInt(
description=(
"Maximum number of attributes to return. "
@@ -469,7 +466,7 @@ class ProductVariant(ChannelContextType[models.ProductVariant]):
description = (
"Represents a version of a product such as different size or color."
)
- interfaces = [relay.Node, ObjectWithMetadata]
+ interfaces = [relay.Node, ObjectWithMetadata, ObjectWithAttributes]
model = models.ProductVariant
@staticmethod
@@ -672,9 +669,9 @@ class ProductVariant(ChannelContextType[models.ProductVariant]):
cls,
root: ChannelContext[models.ProductVariant],
info,
- variant_selection: str | None = None,
limit: int = DEFAULT_NESTED_LIST_LIMIT,
):
+ variant_selection = None
return cls._resolve_attributes(root, info, variant_selection, limit)
@classmethod
@@ -1194,7 +1191,7 @@ class Product(ChannelContextType[models.Product]):
class Meta:
default_resolver = ChannelContextType.resolver_with_context
description = "Represents an individual item for sale in the storefront."
- interfaces = [relay.Node, ObjectWithMetadata]
+ interfaces = [relay.Node, ObjectWithMetadata, ObjectWithAttributes]
model = models.Product
@staticmethod
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 00de537ed9..189e5edd8e 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -5605,7 +5605,7 @@ type ProductCountableEdge @doc(category: "Products") {
}
"""Represents an individual item for sale in the storefront."""
-type Product implements Node & ObjectWithMetadata @doc(category: "Products") {
+type Product implements Node & ObjectWithMetadata & ObjectWithAttributes @doc(category: "Products") {
"""The ID of the product."""
id: ID!
@@ -5639,6 +5639,26 @@ type Product implements Node & ObjectWithMetadata @doc(category: "Products") {
"""
metafields(keys: [String!]): Metadata
+ """
+ Get a single attribute attached to product by attribute slug.
+
+ Added in Saleor 3.22.
+ """
+ assignedAttribute(
+ """Slug of the attribute"""
+ slug: String!
+ ): AssignedAttribute
+
+ """
+ List of attributes assigned to this product.
+
+ Added in Saleor 3.22.
+ """
+ assignedAttributes(
+ """Maximum number of attributes to return. Default is 100."""
+ limit: PositiveInt = 100
+ ): [AssignedAttribute!]!
+
"""SEO title of the product."""
seoTitle: String
@@ -5726,26 +5746,6 @@ type Product implements Node & ObjectWithMetadata @doc(category: "Products") {
"""A type of tax. Assigned by enabled tax gateway"""
taxType: TaxType @deprecated(reason: "Use `taxClass` field instead.")
- """
- Get a single attribute attached to product by attribute slug.
-
- Added in Saleor 3.22.
- """
- assignedAttribute(
- """Slug of the attribute"""
- slug: String!
- ): AssignedAttribute
-
- """
- List of attributes assigned to this product.
-
- Added in Saleor 3.22.
- """
- assignedAttributes(
- """Maximum number of attributes to return. Default is 100."""
- limit: PositiveInt = 100
- ): [AssignedAttribute!]!
-
"""Get a single attribute attached to product by attribute slug."""
attribute(
"""Slug of the attribute"""
@@ -5863,215 +5863,40 @@ type Product implements Node & ObjectWithMetadata @doc(category: "Products") {
}
"""
-Represents a type of product. It defines what attributes are available to products of this type.
-"""
-type ProductType implements Node & ObjectWithMetadata @doc(category: "Products") {
- """The ID of the product type."""
- id: ID!
-
- """List of private metadata items. Requires staff permissions to access."""
- privateMetadata: [MetadataItem!]!
-
- """
- A single key from private metadata. Requires staff permissions to access.
-
- Tip: Use GraphQL aliases to fetch multiple keys.
- """
- privateMetafield(key: String!): String
-
- """
- Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
- """
- privateMetafields(keys: [String!]): Metadata
-
- """List of public metadata items. Can be accessed without permissions."""
- metadata: [MetadataItem!]!
-
- """
- A single key from public metadata.
-
- Tip: Use GraphQL aliases to fetch multiple keys.
- """
- metafield(key: String!): String
-
- """
- Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.
- """
- metafields(keys: [String!]): Metadata
-
- """Name of the product type."""
- name: String!
-
- """Slug of the product type."""
- slug: String!
-
- """Whether the product type has variants."""
- hasVariants: Boolean!
-
- """Whether shipping is required for this product type."""
- isShippingRequired: Boolean!
-
- """Whether the product type is digital."""
- isDigital: Boolean!
-
- """Weight of the product type."""
- weight: Weight
-
- """The product type kind."""
- kind: ProductTypeKindEnum!
-
- """List of products of this type."""
- products(
- """Slug of a channel for which the data should be returned."""
- channel: String
-
- """Return the elements in the list that come before the specified cursor."""
- before: String
-
- """Return the elements in the list that come after the specified cursor."""
- after: String
-
- """
- Retrieve the first n elements from the list. Note that the system only allows fetching a maximum of 100 objects in a single query.
- """
- first: Int
-
- """
- Retrieve the last n elements from the list. Note that the system only allows fetching a maximum of 100 objects in a single query.
- """
- last: Int
- ): ProductCountableConnection @deprecated(reason: "Use the top-level `products` query with the `productTypes` filter.")
+An object with attributes.
- """A type of tax. Assigned by enabled tax gateway"""
- taxType: TaxType @deprecated(reason: "Use `taxClass` field instead.")
-
- """
- Tax class assigned to this product type. All products of this product type use this tax class, unless it's overridden in the `Product` type.
-
- Requires one of the following permissions: AUTHENTICATED_STAFF_USER, AUTHENTICATED_APP.
- """
- taxClass: TaxClass
-
- """Variant attributes of that product type."""
- variantAttributes(
- """Define scope of returned attributes."""
- variantSelection: VariantAttributeScope
- ): [Attribute!] @deprecated(reason: "Use `assignedVariantAttributes` instead.")
-
- """
- Variant attributes of that product type with attached variant selection.
- """
- assignedVariantAttributes(
- """Define scope of returned attributes."""
- variantSelection: VariantAttributeScope
- ): [AssignedVariantAttribute!]
-
- """Product attributes of that product type."""
- productAttributes: [Attribute!]
-
- """
- List of attributes which can be assigned to this product type.
-
- Requires one of the following permissions: MANAGE_PRODUCTS.
- """
- availableAttributes(
- """Filtering options for attributes of this product type."""
- filter: AttributeFilterInput @deprecated(reason: "Use `where` filter instead.")
-
- """Where filtering options for attributes of this product type."""
- where: AttributeWhereInput
-
- """Search attributes."""
- search: String
-
- """Return the elements in the list that come before the specified cursor."""
- before: String
-
- """Return the elements in the list that come after the specified cursor."""
- after: String
-
- """
- Retrieve the first n elements from the list. Note that the system only allows fetching a maximum of 100 objects in a single query.
- """
- first: Int
-
- """
- Retrieve the last n elements from the list. Note that the system only allows fetching a maximum of 100 objects in a single query.
- """
- last: Int
- ): AttributeCountableConnection
-}
-
-enum ProductTypeKindEnum @doc(category: "Products") {
- NORMAL
- GIFT_CARD
-}
-
-"""Representation of tax types fetched from tax gateway."""
-type TaxType @doc(category: "Taxes") {
- """Description of the tax type."""
- description: String
-
- """External tax code used to identify given tax group."""
- taxCode: String
-}
-
-"""
-Tax class is a named object used to define tax rates per country. Tax class can be assigned to product types, products and shipping methods to define their tax rates.
+Added in Saleor 3.22.
"""
-type TaxClass implements Node & ObjectWithMetadata @doc(category: "Taxes") {
- """The ID of the object."""
- id: ID!
-
- """List of private metadata items. Requires staff permissions to access."""
- privateMetadata: [MetadataItem!]!
-
+interface ObjectWithAttributes @doc(category: "Attributes") {
"""
- A single key from private metadata. Requires staff permissions to access.
+ Get a single attribute attached to the object by attribute slug.
- Tip: Use GraphQL aliases to fetch multiple keys.
- """
- privateMetafield(key: String!): String
-
- """
- Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
+ Added in Saleor 3.22.
"""
- privateMetafields(keys: [String!]): Metadata
-
- """List of public metadata items. Can be accessed without permissions."""
- metadata: [MetadataItem!]!
+ assignedAttribute(
+ """Slug of the attribute"""
+ slug: String!
+ ): AssignedAttribute @doc(category: "Attributes")
"""
- A single key from public metadata.
+ List of attributes assigned to the object.
- Tip: Use GraphQL aliases to fetch multiple keys.
- """
- metafield(key: String!): String
-
- """
- Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.
+ Added in Saleor 3.22.
"""
- metafields(keys: [String!]): Metadata
-
- """Name of the tax class."""
- name: String!
-
- """Country-specific tax rates for this tax class."""
- countries: [TaxClassCountryRate!]!
+ assignedAttributes(
+ """Maximum number of attributes to return. Default is 100."""
+ limit: PositiveInt = 100
+ ): [AssignedAttribute!]!
}
"""
-Tax rate for a country. When tax class is null, it represents the default tax rate for that country; otherwise it's a country tax rate specific to the given tax class.
-"""
-type TaxClassCountryRate @doc(category: "Taxes") {
- """Country in which this tax rate applies."""
- country: CountryDisplay!
-
- """Tax rate value."""
- rate: Float!
+Represents an attribute assigned to an object.
- """Related tax class."""
- taxClass: TaxClass
+Added in Saleor 3.22.
+"""
+interface AssignedAttribute @doc(category: "Attributes") {
+ """Attribute assigned to an object."""
+ attribute: Attribute!
}
"""
@@ -6464,108 +6289,320 @@ type AttributeTranslatableContent implements Node @doc(category: "Attributes") {
"""The ID of the attribute to translate."""
attributeId: ID!
- """Name of the attribute to translate."""
- name: String!
+ """Name of the attribute to translate."""
+ name: String!
+
+ """Returns translated attribute fields for the given language code."""
+ translation(
+ """A language code to return the translation for attribute."""
+ languageCode: LanguageCodeEnum!
+ ): AttributeTranslation
+
+ """Custom attribute of a product."""
+ attribute: Attribute @deprecated(reason: "Get model fields from the root level queries.")
+}
+
+"""Represents attribute translations."""
+type AttributeTranslation implements Node @doc(category: "Attributes") {
+ """The ID of the attribute translation."""
+ id: ID!
+
+ """Translation language."""
+ language: LanguageDisplay!
+
+ """Translated attribute name."""
+ name: String!
+
+ """Represents the attribute fields to translate."""
+ translatableContent: AttributeTranslatableContent
+}
+
+type File {
+ """The URL of the file."""
+ url: String!
+
+ """Content type of the file."""
+ contentType: String
+}
+
+"""
+The `Date` scalar type represents a Date
+value as specified by
+[iso8601](https://en.wikipedia.org/wiki/ISO_8601).
+"""
+scalar Date
+
+input AttributeChoicesSortingInput @doc(category: "Attributes") {
+ """Specifies the direction in which to sort attribute choices."""
+ direction: OrderDirection!
+
+ """Sort attribute choices by the selected field."""
+ field: AttributeChoicesSortField!
+}
+
+enum AttributeChoicesSortField @doc(category: "Attributes") {
+ """Sort attribute choice by name."""
+ NAME
+
+ """Sort attribute choice by slug."""
+ SLUG
+}
+
+input AttributeValueFilterInput @doc(category: "Attributes") {
+ search: String
+ ids: [ID!]
+ slugs: [String!]
+}
+
+"""Where filtering options for attribute values."""
+input AttributeValueWhereInput @doc(category: "Attributes") {
+ ids: [ID!]
+ name: StringFilterInput
+ slug: StringFilterInput
+
+ """List of conditions that must be met."""
+ AND: [AttributeValueWhereInput!]
+
+ """A list of conditions of which at least one must be met."""
+ OR: [AttributeValueWhereInput!]
+}
+
+"""Define the filtering options for string fields."""
+input StringFilterInput {
+ """The value equal to."""
+ eq: String
+
+ """The value included in."""
+ oneOf: [String!]
+}
+
+type ProductTypeCountableConnection @doc(category: "Products") {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [ProductTypeCountableEdge!]!
+
+ """A total count of items in the collection."""
+ totalCount: Int
+}
+
+type ProductTypeCountableEdge @doc(category: "Products") {
+ """The item at the end of the edge."""
+ node: ProductType!
+
+ """A cursor for use in pagination."""
+ cursor: String!
+}
+
+"""
+Represents a type of product. It defines what attributes are available to products of this type.
+"""
+type ProductType implements Node & ObjectWithMetadata @doc(category: "Products") {
+ """The ID of the product type."""
+ id: ID!
+
+ """List of private metadata items. Requires staff permissions to access."""
+ privateMetadata: [MetadataItem!]!
+
+ """
+ A single key from private metadata. Requires staff permissions to access.
+
+ Tip: Use GraphQL aliases to fetch multiple keys.
+ """
+ privateMetafield(key: String!): String
+
+ """
+ Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
+ """
+ privateMetafields(keys: [String!]): Metadata
+
+ """List of public metadata items. Can be accessed without permissions."""
+ metadata: [MetadataItem!]!
+
+ """
+ A single key from public metadata.
+
+ Tip: Use GraphQL aliases to fetch multiple keys.
+ """
+ metafield(key: String!): String
+
+ """
+ Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.
+ """
+ metafields(keys: [String!]): Metadata
+
+ """Name of the product type."""
+ name: String!
+
+ """Slug of the product type."""
+ slug: String!
+
+ """Whether the product type has variants."""
+ hasVariants: Boolean!
+
+ """Whether shipping is required for this product type."""
+ isShippingRequired: Boolean!
+
+ """Whether the product type is digital."""
+ isDigital: Boolean!
+
+ """Weight of the product type."""
+ weight: Weight
+
+ """The product type kind."""
+ kind: ProductTypeKindEnum!
+
+ """List of products of this type."""
+ products(
+ """Slug of a channel for which the data should be returned."""
+ channel: String
+
+ """Return the elements in the list that come before the specified cursor."""
+ before: String
+
+ """Return the elements in the list that come after the specified cursor."""
+ after: String
+
+ """
+ Retrieve the first n elements from the list. Note that the system only allows fetching a maximum of 100 objects in a single query.
+ """
+ first: Int
+
+ """
+ Retrieve the last n elements from the list. Note that the system only allows fetching a maximum of 100 objects in a single query.
+ """
+ last: Int
+ ): ProductCountableConnection @deprecated(reason: "Use the top-level `products` query with the `productTypes` filter.")
+
+ """A type of tax. Assigned by enabled tax gateway"""
+ taxType: TaxType @deprecated(reason: "Use `taxClass` field instead.")
+
+ """
+ Tax class assigned to this product type. All products of this product type use this tax class, unless it's overridden in the `Product` type.
+
+ Requires one of the following permissions: AUTHENTICATED_STAFF_USER, AUTHENTICATED_APP.
+ """
+ taxClass: TaxClass
+
+ """Variant attributes of that product type."""
+ variantAttributes(
+ """Define scope of returned attributes."""
+ variantSelection: VariantAttributeScope
+ ): [Attribute!] @deprecated(reason: "Use `assignedVariantAttributes` instead.")
+
+ """
+ Variant attributes of that product type with attached variant selection.
+ """
+ assignedVariantAttributes(
+ """Define scope of returned attributes."""
+ variantSelection: VariantAttributeScope
+ ): [AssignedVariantAttribute!]
+
+ """Product attributes of that product type."""
+ productAttributes: [Attribute!]
+
+ """
+ List of attributes which can be assigned to this product type.
+
+ Requires one of the following permissions: MANAGE_PRODUCTS.
+ """
+ availableAttributes(
+ """Filtering options for attributes of this product type."""
+ filter: AttributeFilterInput @deprecated(reason: "Use `where` filter instead.")
+
+ """Where filtering options for attributes of this product type."""
+ where: AttributeWhereInput
- """Returns translated attribute fields for the given language code."""
- translation(
- """A language code to return the translation for attribute."""
- languageCode: LanguageCodeEnum!
- ): AttributeTranslation
+ """Search attributes."""
+ search: String
- """Custom attribute of a product."""
- attribute: Attribute @deprecated(reason: "Get model fields from the root level queries.")
-}
+ """Return the elements in the list that come before the specified cursor."""
+ before: String
-"""Represents attribute translations."""
-type AttributeTranslation implements Node @doc(category: "Attributes") {
- """The ID of the attribute translation."""
- id: ID!
+ """Return the elements in the list that come after the specified cursor."""
+ after: String
- """Translation language."""
- language: LanguageDisplay!
+ """
+ Retrieve the first n elements from the list. Note that the system only allows fetching a maximum of 100 objects in a single query.
+ """
+ first: Int
- """Translated attribute name."""
- name: String!
+ """
+ Retrieve the last n elements from the list. Note that the system only allows fetching a maximum of 100 objects in a single query.
+ """
+ last: Int
+ ): AttributeCountableConnection
+}
- """Represents the attribute fields to translate."""
- translatableContent: AttributeTranslatableContent
+enum ProductTypeKindEnum @doc(category: "Products") {
+ NORMAL
+ GIFT_CARD
}
-type File {
- """The URL of the file."""
- url: String!
+"""Representation of tax types fetched from tax gateway."""
+type TaxType @doc(category: "Taxes") {
+ """Description of the tax type."""
+ description: String
- """Content type of the file."""
- contentType: String
+ """External tax code used to identify given tax group."""
+ taxCode: String
}
"""
-The `Date` scalar type represents a Date
-value as specified by
-[iso8601](https://en.wikipedia.org/wiki/ISO_8601).
+Tax class is a named object used to define tax rates per country. Tax class can be assigned to product types, products and shipping methods to define their tax rates.
"""
-scalar Date
-
-input AttributeChoicesSortingInput @doc(category: "Attributes") {
- """Specifies the direction in which to sort attribute choices."""
- direction: OrderDirection!
-
- """Sort attribute choices by the selected field."""
- field: AttributeChoicesSortField!
-}
+type TaxClass implements Node & ObjectWithMetadata @doc(category: "Taxes") {
+ """The ID of the object."""
+ id: ID!
-enum AttributeChoicesSortField @doc(category: "Attributes") {
- """Sort attribute choice by name."""
- NAME
+ """List of private metadata items. Requires staff permissions to access."""
+ privateMetadata: [MetadataItem!]!
- """Sort attribute choice by slug."""
- SLUG
-}
+ """
+ A single key from private metadata. Requires staff permissions to access.
+
+ Tip: Use GraphQL aliases to fetch multiple keys.
+ """
+ privateMetafield(key: String!): String
-input AttributeValueFilterInput @doc(category: "Attributes") {
- search: String
- ids: [ID!]
- slugs: [String!]
-}
+ """
+ Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
+ """
+ privateMetafields(keys: [String!]): Metadata
-"""Where filtering options for attribute values."""
-input AttributeValueWhereInput @doc(category: "Attributes") {
- ids: [ID!]
- name: StringFilterInput
- slug: StringFilterInput
+ """List of public metadata items. Can be accessed without permissions."""
+ metadata: [MetadataItem!]!
- """List of conditions that must be met."""
- AND: [AttributeValueWhereInput!]
+ """
+ A single key from public metadata.
+
+ Tip: Use GraphQL aliases to fetch multiple keys.
+ """
+ metafield(key: String!): String
- """A list of conditions of which at least one must be met."""
- OR: [AttributeValueWhereInput!]
-}
+ """
+ Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.
+ """
+ metafields(keys: [String!]): Metadata
-"""Define the filtering options for string fields."""
-input StringFilterInput {
- """The value equal to."""
- eq: String
+ """Name of the tax class."""
+ name: String!
- """The value included in."""
- oneOf: [String!]
+ """Country-specific tax rates for this tax class."""
+ countries: [TaxClassCountryRate!]!
}
-type ProductTypeCountableConnection @doc(category: "Products") {
- """Pagination data for this connection."""
- pageInfo: PageInfo!
- edges: [ProductTypeCountableEdge!]!
-
- """A total count of items in the collection."""
- totalCount: Int
-}
+"""
+Tax rate for a country. When tax class is null, it represents the default tax rate for that country; otherwise it's a country tax rate specific to the given tax class.
+"""
+type TaxClassCountryRate @doc(category: "Taxes") {
+ """Country in which this tax rate applies."""
+ country: CountryDisplay!
-type ProductTypeCountableEdge @doc(category: "Products") {
- """The item at the end of the edge."""
- node: ProductType!
+ """Tax rate value."""
+ rate: Float!
- """A cursor for use in pagination."""
- cursor: String!
+ """Related tax class."""
+ taxClass: TaxClass
}
enum VariantAttributeScope @doc(category: "Products") {
@@ -6687,6 +6724,13 @@ input MeasurementUnitsEnumFilterInput @doc(category: "Attributes") {
oneOf: [MeasurementUnitsEnum!]
}
+"""
+Positive Integer scalar implementation.
+
+Should be used in places where value must be positive (greater than 0).
+"""
+scalar PositiveInt
+
"""
Represents a single category of products. Categories allow to organize products in a tree-hierarchies which can be used for navigation in the storefront.
"""
@@ -7356,7 +7400,7 @@ type CategoryTranslatableContent implements Node @doc(category: "Products") {
}
"""Represents a version of a product such as different size or color."""
-type ProductVariant implements Node & ObjectWithMetadata @doc(category: "Products") {
+type ProductVariant implements Node & ObjectWithMetadata & ObjectWithAttributes @doc(category: "Products") {
"""The ID of the product variant."""
id: ID!
@@ -7390,6 +7434,26 @@ type ProductVariant implements Node & ObjectWithMetadata @doc(category: "Product
"""
metafields(keys: [String!]): Metadata
+ """
+ Get a single attribute attached to product by attribute slug.
+
+ Added in Saleor 3.22.
+ """
+ assignedAttribute(
+ """Slug of the attribute"""
+ slug: String!
+ ): AssignedAttribute
+
+ """
+ List of attributes assigned to this variant.
+
+ Added in Saleor 3.22.
+ """
+ assignedAttributes(
+ """Maximum number of attributes to return. Default is 100."""
+ limit: PositiveInt = 100
+ ): [AssignedAttribute!]!
+
"""The name of the product variant."""
name: String!
@@ -7432,29 +7496,6 @@ type ProductVariant implements Node & ObjectWithMetadata @doc(category: "Product
address: AddressInput
): VariantPricingInfo
- """
- Get a single attribute attached to product by attribute slug.
-
- Added in Saleor 3.22.
- """
- assignedAttribute(
- """Slug of the attribute"""
- slug: String!
- ): AssignedAttribute
-
- """
- List of attributes assigned to this variant.
-
- Added in Saleor 3.22.
- """
- assignedAttributes(
- """Define scope of returned attributes."""
- variantSelection: VariantAttributeScope
-
- """Maximum number of attributes to return. Default is 100."""
- limit: PositiveInt = 100
- ): [AssignedAttribute!]!
-
"""List of attributes assigned to this variant."""
attributes(
"""Define scope of returned attributes."""
@@ -7696,23 +7737,6 @@ input MetadataInput {
value: String!
}
-"""
-Represents an attribute assigned to an object.
-
-Added in Saleor 3.22.
-"""
-interface AssignedAttribute @doc(category: "Attributes") {
- """Attribute assigned to an object."""
- attribute: Attribute!
-}
-
-"""
-Positive Integer scalar implementation.
-
-Should be used in places where value must be positive (greater than 0).
-"""
-scalar PositiveInt
-
"""Represents an assigned attribute to an object."""
type SelectedAttribute @doc(category: "Attributes") {
"""Name of an attribute displayed in the interface."""
@@ -8698,7 +8722,7 @@ type PageTranslation implements Node @doc(category: "Pages") {
"""
A static page that can be manually added by a shop operator through the dashboard.
"""
-type Page implements Node & ObjectWithMetadata @doc(category: "Pages") {
+type Page implements Node & ObjectWithMetadata & ObjectWithAttributes @doc(category: "Pages") {
"""ID of the page."""
id: ID!
@@ -8732,6 +8756,26 @@ type Page implements Node & ObjectWithMetadata @doc(category: "Pages") {
"""
metafields(keys: [String!]): Metadata
+ """
+ Get a single attribute attached to page by attribute slug.
+
+ Added in Saleor 3.22.
+ """
+ assignedAttribute(
+ """Slug of the attribute"""
+ slug: String!
+ ): AssignedAttribute
+
+ """
+ List of attributes assigned to this page.
+
+ Added in Saleor 3.22.
+ """
+ assignedAttributes(
+ """Maximum number of attributes to return. Default is 100."""
+ limit: PositiveInt = 100
+ ): [AssignedAttribute!]!
+
"""Title of the page for SEO."""
seoTitle: String
@@ -8783,26 +8827,6 @@ type Page implements Node & ObjectWithMetadata @doc(category: "Pages") {
slug: String!
): SelectedAttribute @deprecated(reason: "Use `assignedAttribute` field instead.")
- """
- Get a single attribute attached to page by attribute slug.
-
- Added in Saleor 3.22.
- """
- assignedAttribute(
- """Slug of the attribute"""
- slug: String!
- ): AssignedAttribute
-
- """
- List of attributes assigned to this page.
-
- Added in Saleor 3.22.
- """
- assignedAttributes(
- """Maximum number of attributes to return. Default is 100."""
- limit: PositiveInt = 100
- ): [AssignedAttribute!]!
-
"""List of attributes assigned to this page."""
attributes: [SelectedAttribute!]! @deprecated(reason: "Use `assignedAttributes` field instead.")
}