Skip to content

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

Add referencedObject to attributeValue (#17907)

Maciej Korycinski705b43d4102e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8df9596d95..f3c50c593e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -79,6 +79,7 @@ All notable, unreleased changes to this project will be documented in this file.
- `collection.products`
- `pageType.availableAttributes`
- Extend `AttributeEntityType` with `CATEGORY` and `COLLECTION`. You can now assign category and collection as a attribute reference.
+- Attribute values now expose the `referencedObject`, allowing for easier access to the linked entity.
### Webhooks
diff --git a/saleor/graphql/attribute/types.py b/saleor/graphql/attribute/types.py
index 0970779981..ffe038d2b6 100644
--- a/saleor/graphql/attribute/types.py
+++ b/saleor/graphql/attribute/types.py
@@ -1,12 +1,13 @@
import graphene
-from ...attribute import AttributeInputType, models
+from ...attribute import AttributeEntityType, AttributeInputType, models
from ...permission.enums import (
PagePermissions,
PageTypePermissions,
ProductPermissions,
ProductTypePermissions,
)
+from ..channel.types import ChannelContext
from ..core import ResolveInfo
from ..core.connection import (
CountableConnection,
@@ -35,6 +36,8 @@ from ..core.types import (
)
from ..decorators import check_attribute_required_permissions
from ..meta.types import ObjectWithMetadata
+from ..page.dataloaders import PageByIdLoader
+from ..product.dataloaders.products import ProductByIdLoader, ProductVariantByIdLoader
from ..translations.fields import TranslationField
from ..translations.types import AttributeTranslation, AttributeValueTranslation
from .dataloaders import AttributesByAttributeId
@@ -45,6 +48,18 @@ from .sorters import AttributeChoicesSortingInput
from .utils import AttributeAssignmentMixin
+def get_reference_pk(attribute, root: models.AttributeValue) -> None | int:
+ if attribute.input_type != AttributeInputType.REFERENCE:
+ return None
+ reference_field = AttributeAssignmentMixin.ENTITY_TYPE_MAPPING[
+ attribute.entity_type
+ ].value_field
+ reference_pk = getattr(root, f"{reference_field}_id", None)
+ if reference_pk is None:
+ return None
+ return reference_pk
+
+
class AttributeValue(ModelObjectType[models.AttributeValue]):
id = graphene.GlobalID(required=True, description="The ID of the attribute value.")
name = graphene.String(description=AttributeValueDescriptions.NAME)
@@ -54,7 +69,12 @@ class AttributeValue(ModelObjectType[models.AttributeValue]):
AttributeValueTranslation, type_name="attribute value"
)
input_type = AttributeInputTypeEnum(description=AttributeDescriptions.INPUT_TYPE)
- reference = graphene.ID(description="The ID of the attribute reference.")
+ reference = graphene.ID(description="The ID of the referenced object.")
+ referenced_object = graphene.Field(
+ "saleor.graphql.attribute.unions.AttributeValueReferencedObject",
+ description="The object referenced by the attribute value." + ADDED_IN_322,
+ )
+
file = graphene.Field(
File, description=AttributeValueDescriptions.FILE, required=False
)
@@ -81,6 +101,41 @@ class AttributeValue(ModelObjectType[models.AttributeValue]):
interfaces = [graphene.relay.Node]
model = models.AttributeValue
+ @staticmethod
+ def resolve_referenced_object(root: models.AttributeValue, info: ResolveInfo):
+ def prepare_referenced_object(attribute):
+ if not attribute:
+ return None
+ reference_pk = get_reference_pk(attribute, root)
+
+ if reference_pk is None:
+ return None
+
+ def wrap_with_channel_context(_object):
+ return ChannelContext(node=_object, channel_slug=None)
+
+ if attribute.entity_type == AttributeEntityType.PRODUCT:
+ return (
+ ProductByIdLoader(info.context)
+ .load(reference_pk)
+ .then(wrap_with_channel_context)
+ )
+ if attribute.entity_type == AttributeEntityType.PRODUCT_VARIANT:
+ return (
+ ProductVariantByIdLoader(info.context)
+ .load(reference_pk)
+ .then(wrap_with_channel_context)
+ )
+ if attribute.entity_type == AttributeEntityType.PAGE:
+ return PageByIdLoader(info.context).load(reference_pk)
+ return None
+
+ return (
+ AttributesByAttributeId(info.context)
+ .load(root.attribute_id)
+ .then(prepare_referenced_object)
+ )
+
@staticmethod
def resolve_input_type(root: models.AttributeValue, info: ResolveInfo):
return (
@@ -98,18 +153,10 @@ class AttributeValue(ModelObjectType[models.AttributeValue]):
@staticmethod
def resolve_reference(root: models.AttributeValue, info: ResolveInfo):
def prepare_reference(attribute) -> None | str:
- if attribute.input_type != AttributeInputType.REFERENCE:
- return None
- reference_field = AttributeAssignmentMixin.ENTITY_TYPE_MAPPING[
- attribute.entity_type
- ].value_field
- reference_pk = getattr(root, f"{reference_field}_id", None)
+ reference_pk = get_reference_pk(attribute, root)
if reference_pk is None:
return None
- reference_id = graphene.Node.to_global_id(
- attribute.entity_type, reference_pk
- )
- return reference_id
+ return graphene.Node.to_global_id(attribute.entity_type, reference_pk)
return (
AttributesByAttributeId(info.context)
diff --git a/saleor/graphql/attribute/unions.py b/saleor/graphql/attribute/unions.py
new file mode 100644
index 0000000000..68e12078a3
--- /dev/null
+++ b/saleor/graphql/attribute/unions.py
@@ -0,0 +1,28 @@
+import graphene
+
+from ...page import models as page_models
+from ...product import models as product_models
+from ..core.context import ChannelContext
+from ..page.types import Page
+from ..product.types import Product, ProductVariant
+
+
+class AttributeValueReferencedObject(graphene.Union):
+ class Meta:
+ types = (
+ Product,
+ ProductVariant,
+ Page,
+ )
+
+ @classmethod
+ def resolve_type(cls, instance, info):
+ if isinstance(instance, ChannelContext):
+ instance = instance.node
+ if isinstance(instance, product_models.Product):
+ return Product
+ if isinstance(instance, product_models.ProductVariant):
+ return ProductVariant
+ if isinstance(instance, page_models.Page):
+ return Page
+ return super().resolve_type(instance, info)
diff --git a/saleor/graphql/page/tests/queries/test_page.py b/saleor/graphql/page/tests/queries/test_page.py
index 26d28fc60a..11d2dc4200 100644
--- a/saleor/graphql/page/tests/queries/test_page.py
+++ b/saleor/graphql/page/tests/queries/test_page.py
@@ -7,7 +7,7 @@ from .....attribute.tests.model_helpers import (
get_page_attributes,
)
from .....attribute.utils import associate_attribute_values_to_instance
-from .....page.models import PageTranslation
+from .....page.models import Page, PageTranslation
from .....tests.utils import dummy_editorjs
from ....core.enums import LanguageCodeEnum
from ....tests.utils import get_graphql_content, get_graphql_content_from_response
@@ -470,6 +470,24 @@ query Page($id: ID!, $slug: String!) {
id
slug
}
+ values {
+ reference
+ referencedObject {
+ __typename
+ ... on Page {
+ id
+ publicationDate
+ }
+ ... on ProductVariant {
+ id
+ created
+ }
+ ... on Product {
+ id
+ created
+ }
+ }
+ }
}
}
}
@@ -601,3 +619,171 @@ def test_page_attribute_visible_in_storefront_for_staff_is_always_returned(
# then
content = get_graphql_content(response)
assert content["data"]["page"]["attribute"]["attribute"]["slug"] == attribute.slug
+
+
+def test_page_attribute_with_referenced_page_object(
+ staff_api_client,
+ page_type_page_reference_attribute,
+ permission_manage_pages,
+ page,
+):
+ # given
+ staff_api_client.user.user_permissions.add(permission_manage_pages)
+
+ # Create a second page to reference
+ referenced_page = Page.objects.create(
+ title="Referenced Page",
+ slug="referenced-page",
+ page_type=page.page_type,
+ is_published=True,
+ )
+
+ page_type = page.page_type
+ page_type.page_attributes.all().delete()
+ page_type.page_attributes.add(page_type_page_reference_attribute)
+
+ attribute_value = AttributeValue.objects.create(
+ attribute=page_type_page_reference_attribute,
+ name=f"Page {referenced_page.pk}",
+ slug=f"page-{referenced_page.pk}",
+ reference_page=referenced_page,
+ )
+
+ associate_attribute_values_to_instance(
+ page, {page_type_page_reference_attribute.pk: [attribute_value]}
+ )
+
+ query = QUERY_PAGE_WITH_ATTRIBUTE
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("Page", page.pk),
+ "slug": page_type_page_reference_attribute.slug,
+ }
+ response = staff_api_client.post_graphql(query, variables)
+
+ # then
+ content = get_graphql_content(response)
+ page_data = content["data"]["page"]
+ page_attributes = page_data["attributes"]
+ assert len(page_attributes) == 1
+
+ attribute_with_reference = page_attributes[0]
+ assert attribute_with_reference["attribute"]["slug"] == "page-reference"
+
+ assert len(attribute_with_reference["values"]) == 1
+ value = attribute_with_reference["values"][0]
+ assert value["reference"] == graphene.Node.to_global_id("Page", referenced_page.id)
+ assert value["referencedObject"]["__typename"] == "Page"
+ assert value["referencedObject"]["id"] == graphene.Node.to_global_id(
+ "Page", referenced_page.id
+ )
+
+
+def test_page_attribute_with_referenced_product_variant_object(
+ staff_api_client,
+ page_type_variant_reference_attribute,
+ permission_manage_pages,
+ page,
+ product,
+):
+ # given
+ staff_api_client.user.user_permissions.add(permission_manage_pages)
+
+ product_variant = product.variants.first()
+ page_type = page.page_type
+ page_type.page_attributes.all().delete()
+ page_type.page_attributes.add(page_type_variant_reference_attribute)
+
+ attribute_value = AttributeValue.objects.create(
+ attribute=page_type_variant_reference_attribute,
+ name=f"Variant {product_variant.pk}",
+ slug=f"variant-{product_variant.pk}",
+ reference_variant=product_variant,
+ )
+
+ associate_attribute_values_to_instance(
+ page,
+ {page_type_variant_reference_attribute.pk: [attribute_value]},
+ )
+
+ query = QUERY_PAGE_WITH_ATTRIBUTE
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("Page", page.pk),
+ "slug": page_type_variant_reference_attribute.slug,
+ }
+ response = staff_api_client.post_graphql(query, variables)
+
+ # then
+ content = get_graphql_content(response)
+ page_data = content["data"]["page"]
+ page_attributes = page_data["attributes"]
+ assert len(page_attributes) == 1
+
+ attribute_with_reference = page_attributes[0]
+ assert attribute_with_reference["attribute"]["slug"] == "variant-reference"
+
+ assert len(attribute_with_reference["values"]) == 1
+ value = attribute_with_reference["values"][0]
+ assert value["reference"] == graphene.Node.to_global_id(
+ "ProductVariant", product_variant.id
+ )
+ assert value["referencedObject"]["__typename"] == "ProductVariant"
+ assert value["referencedObject"]["id"] == graphene.Node.to_global_id(
+ "ProductVariant", product_variant.id
+ )
+
+
+def test_page_attribute_with_referenced_product_object(
+ staff_api_client,
+ page_type_product_reference_attribute,
+ permission_manage_pages,
+ page,
+ product,
+):
+ # given
+ staff_api_client.user.user_permissions.add(permission_manage_pages)
+
+ page_type = page.page_type
+ page_type.page_attributes.all().delete()
+ page_type.page_attributes.add(page_type_product_reference_attribute)
+
+ attribute_value = AttributeValue.objects.create(
+ attribute=page_type_product_reference_attribute,
+ name=f"Product {product.pk}",
+ slug=f"product-{product.pk}",
+ reference_product=product,
+ )
+
+ associate_attribute_values_to_instance(
+ page,
+ {page_type_product_reference_attribute.pk: [attribute_value]},
+ )
+
+ query = QUERY_PAGE_WITH_ATTRIBUTE
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("Page", page.pk),
+ "slug": page_type_product_reference_attribute.slug,
+ }
+ response = staff_api_client.post_graphql(query, variables)
+
+ # then
+ content = get_graphql_content(response)
+ page_data = content["data"]["page"]
+ page_attributes = page_data["attributes"]
+ assert len(page_attributes) == 1
+
+ attribute_with_reference = page_attributes[0]
+ assert attribute_with_reference["attribute"]["slug"] == "product-reference"
+
+ assert len(attribute_with_reference["values"]) == 1
+ value = attribute_with_reference["values"][0]
+ assert value["reference"] == graphene.Node.to_global_id("Product", product.id)
+ assert value["referencedObject"]["__typename"] == "Product"
+ assert value["referencedObject"]["id"] == graphene.Node.to_global_id(
+ "Product", product.id
+ )
diff --git a/saleor/graphql/product/tests/test_attributes.py b/saleor/graphql/product/tests/test_attributes.py
index 9bd42be725..a9ca8c517f 100644
--- a/saleor/graphql/product/tests/test_attributes.py
+++ b/saleor/graphql/product/tests/test_attributes.py
@@ -36,6 +36,22 @@ QUERY_PRODUCT_AND_VARIANTS_ATTRIBUTES = """
}
values {
slug
+ reference
+ referencedObject {
+ __typename
+ ... on Page {
+ id
+ publicationDate
+ }
+ ... on ProductVariant {
+ id
+ created
+ }
+ ... on Product {
+ id
+ created
+ }
+ }
}
}
variants {
@@ -46,6 +62,22 @@ QUERY_PRODUCT_AND_VARIANTS_ATTRIBUTES = """
}
values {
slug
+ reference
+ referencedObject {
+ __typename
+ ... on Page {
+ id
+ publicationDate
+ }
+ ... on ProductVariant {
+ id
+ created
+ }
+ ... on Product {
+ id
+ created
+ }
+ }
}
}
}
@@ -1767,3 +1799,317 @@ def test_sort_product_variant_attribute_values_invalid_value_id(
assert errors[0]["code"] == ProductErrorCode.NOT_FOUND.name
assert errors[0]["field"] == "moves"
assert errors[0]["values"] == [invalid_value_id]
+
+
+def test_product_attribute_with_referenced_page_object(
+ staff_api_client,
+ product_type_page_reference_attribute,
+ permission_manage_products,
+ page,
+ product,
+ channel_USD,
+):
+ # given
+ staff_api_client.user.user_permissions.add(permission_manage_products)
+
+ product_type = product.product_type
+ product_type.product_attributes.all().delete()
+
+ product_type.product_attributes.add(product_type_page_reference_attribute)
+
+ attribute_value = AttributeValue.objects.create(
+ attribute=product_type_page_reference_attribute,
+ name=f"Page {page.pk}",
+ slug=f"page-{page.pk}",
+ reference_page=page,
+ )
+
+ associate_attribute_values_to_instance(
+ product, {product_type_page_reference_attribute.pk: [attribute_value]}
+ )
+
+ query = QUERY_PRODUCT_AND_VARIANTS_ATTRIBUTES
+
+ # when
+ response = staff_api_client.post_graphql(query, {"channel": channel_USD.slug})
+
+ # then
+ content = get_graphql_content(response)
+ products = content["data"]["products"]["edges"]
+ assert len(products) == 1
+
+ product_attributes = products[0]["node"]["attributes"]
+ assert len(product_attributes) == 1
+
+ attribute_with_reference = product_attributes[0]
+ assert attribute_with_reference["attribute"]["slug"] == "page-reference"
+
+ assert len(attribute_with_reference["values"]) == 1
+ value = attribute_with_reference["values"][0]
+ assert value["reference"] == graphene.Node.to_global_id("Page", page.id)
+ assert value["referencedObject"]["__typename"] == "Page"
+ assert value["referencedObject"]["id"] == graphene.Node.to_global_id(
+ "Page", page.id
+ )
+
+
+def test_product_attribute_with_referenced_product_variant_object(
+ staff_api_client,
+ product_type_variant_reference_attribute,
+ permission_manage_products,
+ product,
+ channel_USD,
+):
+ # given
+ staff_api_client.user.user_permissions.add(permission_manage_products)
+
+ product_variant = product.variants.first()
+ product_type = product.product_type
+ product_type.product_attributes.all().delete()
+ product_type.product_attributes.add(product_type_variant_reference_attribute)
+
+ attribute_value = AttributeValue.objects.create(
+ attribute=product_type_variant_reference_attribute,
+ name=f"Variant {product_variant.pk}",
+ slug=f"variant-{product_variant.pk}",
+ reference_variant=product_variant,
+ )
+
+ associate_attribute_values_to_instance(
+ product, {product_type_variant_reference_attribute.pk: [attribute_value]}
+ )
+
+ query = QUERY_PRODUCT_AND_VARIANTS_ATTRIBUTES
+
+ # when
+ response = staff_api_client.post_graphql(query, {"channel": channel_USD.slug})
+
+ # then
+ content = get_graphql_content(response)
+ products = content["data"]["products"]["edges"]
+ assert len(products) == 1
+
+ product_attributes = products[0]["node"]["attributes"]
+ assert len(product_attributes) == 1
+
+ attribute_with_reference = product_attributes[0]
+ assert attribute_with_reference["attribute"]["slug"] == "variant-reference"
+
+ assert len(attribute_with_reference["values"]) == 1
+ value = attribute_with_reference["values"][0]
+ assert value["reference"] == graphene.Node.to_global_id(
+ "ProductVariant", product_variant.id
+ )
+ assert value["referencedObject"]["__typename"] == "ProductVariant"
+ assert value["referencedObject"]["id"] == graphene.Node.to_global_id(
+ "ProductVariant", product_variant.id
+ )
+
+
+def test_product_attribute_with_referenced_product_object(
+ staff_api_client,
+ product_type_product_reference_attribute,
+ permission_manage_products,
+ product,
+ channel_USD,
+):
+ # given
+ staff_api_client.user.user_permissions.add(permission_manage_products)
+
+ product_type = product.product_type
+ product_type.product_attributes.all().delete()
+ product_type.product_attributes.add(product_type_product_reference_attribute)
+
+ attribute_value = AttributeValue.objects.create(
+ attribute=product_type_product_reference_attribute,
+ name=f"Product {product.pk}",
+ slug=f"product-{product.pk}",
+ reference_product=product,
+ )
+
+ associate_attribute_values_to_instance(
+ product, {product_type_product_reference_attribute.pk: [attribute_value]}
+ )
+
+ query = QUERY_PRODUCT_AND_VARIANTS_ATTRIBUTES
+
+ # when
+ response = staff_api_client.post_graphql(query, {"channel": channel_USD.slug})
+
+ # then
+ content = get_graphql_content(response)
+ products = content["data"]["products"]["edges"]
+ assert len(products) == 1
+
+ product_attributes = products[0]["node"]["attributes"]
+ assert len(product_attributes) == 1
+
+ attribute_with_reference = product_attributes[0]
+ assert attribute_with_reference["attribute"]["slug"] == "product-reference"
+
+ assert len(attribute_with_reference["values"]) == 1
+ value = attribute_with_reference["values"][0]
+ assert value["reference"] == graphene.Node.to_global_id("Product", product.id)
+ assert value["referencedObject"]["__typename"] == "Product"
+ assert value["referencedObject"]["id"] == graphene.Node.to_global_id(
+ "Product", product.id
+ )
+
+
+def test_product_variant_attribute_with_referenced_page_object(
+ staff_api_client,
+ product_type_page_reference_attribute,
+ permission_manage_products,
+ page,
+ product,
+ channel_USD,
+):
+ # given
+ staff_api_client.user.user_permissions.add(permission_manage_products)
+
+ product_variant = product.variants.first()
+ product_type = product.product_type
+ product_type.variant_attributes.all().delete()
+ product_type.variant_attributes.add(product_type_page_reference_attribute)
+
+ attribute_value = AttributeValue.objects.create(
+ attribute=product_type_page_reference_attribute,
+ name=f"Page {page.pk}",
+ slug=f"page-{page.pk}",
+ reference_page=page,
+ )
+
+ associate_attribute_values_to_instance(
+ product_variant, {product_type_page_reference_attribute.pk: [attribute_value]}
+ )
+
+ query = QUERY_PRODUCT_AND_VARIANTS_ATTRIBUTES
+
+ # when
+ response = staff_api_client.post_graphql(query, {"channel": channel_USD.slug})
+
+ # then
+ content = get_graphql_content(response)
+ products = content["data"]["products"]["edges"]
+ assert len(products) == 1
+
+ variant_attributes = products[0]["node"]["variants"][0]["attributes"]
+ assert len(variant_attributes) == 1
+
+ attribute_with_reference = variant_attributes[0]
+ assert attribute_with_reference["attribute"]["slug"] == "page-reference"
+
+ assert len(attribute_with_reference["values"]) == 1
+ value = attribute_with_reference["values"][0]
+ assert value["reference"] == graphene.Node.to_global_id("Page", page.id)
+ assert value["referencedObject"]["__typename"] == "Page"
+ assert value["referencedObject"]["id"] == graphene.Node.to_global_id(
+ "Page", page.id
+ )
+
+
+def test_product_variant_attribute_with_referenced_product_variant_object(
+ staff_api_client,
+ product_type_variant_reference_attribute,
+ permission_manage_products,
+ product,
+ channel_USD,
+):
+ # given
+ staff_api_client.user.user_permissions.add(permission_manage_products)
+
+ product_variant = product.variants.first()
+ product_type = product.product_type
+ product_type.variant_attributes.all().delete()
+ product_type.variant_attributes.add(product_type_variant_reference_attribute)
+
+ attribute_value = AttributeValue.objects.create(
+ attribute=product_type_variant_reference_attribute,
+ name=f"Variant {product_variant.pk}",
+ slug=f"variant-{product_variant.pk}",
+ reference_variant=product_variant,
+ )
+
+ associate_attribute_values_to_instance(
+ product_variant,
+ {product_type_variant_reference_attribute.pk: [attribute_value]},
+ )
+
+ query = QUERY_PRODUCT_AND_VARIANTS_ATTRIBUTES
+
+ # when
+ response = staff_api_client.post_graphql(query, {"channel": channel_USD.slug})
+
+ # then
+ content = get_graphql_content(response)
+ products = content["data"]["products"]["edges"]
+ assert len(products) == 1
+
+ variant_attributes = products[0]["node"]["variants"][0]["attributes"]
+ assert len(variant_attributes) == 1
+
+ attribute_with_reference = variant_attributes[0]
+ assert attribute_with_reference["attribute"]["slug"] == "variant-reference"
+
+ assert len(attribute_with_reference["values"]) == 1
+ value = attribute_with_reference["values"][0]
+
+ assert value["reference"] == graphene.Node.to_global_id(
+ "ProductVariant", product_variant.id
+ )
+ assert value["referencedObject"]["__typename"] == "ProductVariant"
+ assert value["referencedObject"]["id"] == graphene.Node.to_global_id(
+ "ProductVariant", product_variant.id
+ )
+
+
+def test_product_variant_attribute_with_referenced_product_object(
+ staff_api_client,
+ product_type_product_reference_attribute,
+ permission_manage_products,
+ product,
+ channel_USD,
+):
+ # given
+ staff_api_client.user.user_permissions.add(permission_manage_products)
+
+ product_variant = product.variants.first()
+ product_type = product.product_type
+ product_type.variant_attributes.all().delete()
+ product_type.variant_attributes.add(product_type_product_reference_attribute)
+
+ attribute_value = AttributeValue.objects.create(
+ attribute=product_type_product_reference_attribute,
+ name=f"Product {product.pk}",
+ slug=f"product-{product.pk}",
+ reference_product=product,
+ )
+
+ associate_attribute_values_to_instance(
+ product_variant,
+ {product_type_product_reference_attribute.pk: [attribute_value]},
+ )
+
+ query = QUERY_PRODUCT_AND_VARIANTS_ATTRIBUTES
+
+ # when
+ response = staff_api_client.post_graphql(query, {"channel": channel_USD.slug})
+
+ # then
+ content = get_graphql_content(response)
+ products = content["data"]["products"]["edges"]
+ assert len(products) == 1
+
+ variant_attributes = products[0]["node"]["variants"][0]["attributes"]
+ assert len(variant_attributes) == 1
+
+ attribute_with_reference = variant_attributes[0]
+ assert attribute_with_reference["attribute"]["slug"] == "product-reference"
+
+ assert len(attribute_with_reference["values"]) == 1
+ value = attribute_with_reference["values"][0]
+ assert value["reference"] == graphene.Node.to_global_id("Product", product.id)
+ assert value["referencedObject"]["__typename"] == "Product"
+ assert value["referencedObject"]["id"] == graphene.Node.to_global_id(
+ "Product", product.id
+ )
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index a7feb9b4dd..e4fb5fafcf 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -6248,9 +6248,16 @@ type AttributeValue implements Node @doc(category: "Attributes") {
"""The input type to use for entering attribute values in the dashboard."""
inputType: AttributeInputTypeEnum
- """The ID of the attribute reference."""
+ """The ID of the referenced object."""
reference: ID
+ """
+ The object referenced by the attribute value.
+
+ Added in Saleor 3.22.
+ """
+ referencedObject: AttributeValueReferencedObject
+
"""Represents file URL and content type (if attribute value is a file)."""
file: File
@@ -6378,193 +6385,11 @@ type AttributeTranslation implements Node @doc(category: "Attributes") {
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!]
-}
-
-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!
-}
-
-enum VariantAttributeScope @doc(category: "Products") {
- ALL
- VARIANT_SELECTION
- NOT_VARIANT_SELECTION
-}
-
-"""
-Represents assigned attribute to variant with variant selection attached.
-"""
-type AssignedVariantAttribute @doc(category: "Attributes") {
- """Attribute assigned to variant."""
- attribute: Attribute!
-
- """
- Determines, whether assigned attribute is allowed for variant selection. Supported variant types for variant selection are: ['dropdown', 'boolean', 'swatch', 'numeric']
- """
- variantSelection: Boolean!
-}
-
-type AttributeCountableConnection @doc(category: "Attributes") {
- """Pagination data for this connection."""
- pageInfo: PageInfo!
- edges: [AttributeCountableEdge!]!
-
- """A total count of items in the collection."""
- totalCount: Int
-}
-
-type AttributeCountableEdge @doc(category: "Attributes") {
- """The item at the end of the edge."""
- node: Attribute!
-
- """A cursor for use in pagination."""
- cursor: String!
-}
-
-input AttributeFilterInput @doc(category: "Attributes") {
- valueRequired: Boolean
- isVariantOnly: Boolean
- visibleInStorefront: Boolean
- filterableInStorefront: Boolean
- filterableInDashboard: Boolean
- availableInGrid: Boolean
- metadata: [MetadataFilter!]
- search: String
- ids: [ID!]
- type: AttributeTypeEnum
- inCollection: ID
- inCategory: ID
- slugs: [String!]
-
- """Specifies the channel by which the data should be filtered."""
- channel: String @deprecated(reason: "Use root-level channel argument instead.")
-}
-
-input MetadataFilter {
- """Key of a metadata item."""
- key: String!
-
- """Value of a metadata item."""
- value: String
-}
-
-"""Where filtering options."""
-input AttributeWhereInput @doc(category: "Attributes") {
- metadata: [MetadataFilter!]
- ids: [ID!]
- name: StringFilterInput
- slug: StringFilterInput
- withChoices: Boolean
- inputType: AttributeInputTypeEnumFilterInput
- entityType: AttributeEntityTypeEnumFilterInput
- type: AttributeTypeEnumFilterInput
- unit: MeasurementUnitsEnumFilterInput
- inCollection: ID
- inCategory: ID
- valueRequired: Boolean
- visibleInStorefront: Boolean
- filterableInDashboard: Boolean
-
- """List of conditions that must be met."""
- AND: [AttributeWhereInput!]
-
- """A list of conditions of which at least one must be met."""
- OR: [AttributeWhereInput!]
-}
-
-"""Define the filtering options for string fields."""
-input StringFilterInput {
- """The value equal to."""
- eq: String
-
- """The value included in."""
- oneOf: [String!]
-}
-
-input AttributeInputTypeEnumFilterInput @doc(category: "Attributes") {
- """The value equal to."""
- eq: AttributeInputTypeEnum
-
- """The value included in."""
- oneOf: [AttributeInputTypeEnum!]
-}
-
-input AttributeEntityTypeEnumFilterInput @doc(category: "Attributes") {
- """The value equal to."""
- eq: AttributeEntityTypeEnum
-
- """The value included in."""
- oneOf: [AttributeEntityTypeEnum!]
-}
-
-input AttributeTypeEnumFilterInput @doc(category: "Attributes") {
- """The value equal to."""
- eq: AttributeTypeEnum
-
- """The value included in."""
- oneOf: [AttributeTypeEnum!]
-}
-
-input MeasurementUnitsEnumFilterInput @doc(category: "Attributes") {
- """The value equal to."""
- eq: MeasurementUnitsEnum
-
- """The value included in."""
- oneOf: [MeasurementUnitsEnum!]
-}
+union AttributeValueReferencedObject = Product | ProductVariant | Page
-"""
-Represents a single category of products. Categories allow to organize products in a tree-hierarchies which can be used for navigation in the storefront.
-"""
-type Category implements Node & ObjectWithMetadata @doc(category: "Products") {
- """The ID of the category."""
+"""Represents a version of a product such as different size or color."""
+type ProductVariant implements Node & ObjectWithMetadata @doc(category: "Products") {
+ """The ID of the product variant."""
id: ID!
"""List of private metadata items. Requires staff permissions to access."""
@@ -6597,492 +6422,882 @@ type Category implements Node & ObjectWithMetadata @doc(category: "Products") {
"""
metafields(keys: [String!]): Metadata
- """SEO title of category."""
- seoTitle: String
+ """The name of the product variant."""
+ name: String!
- """SEO description of category."""
- seoDescription: String
+ """The SKU (stock keeping unit) of the product variant."""
+ sku: String
- """Name of category"""
- name: String!
+ """The product to which the variant belongs."""
+ product: Product!
"""
- Description of the category.
-
- Rich text format. For reference see https://editorjs.io/
+ Determines if the inventory of this variant should be tracked. If false, the quantity won't change when customers buy this item. If the field is not provided, `Shop.trackInventoryByDefault` will be used.
"""
- description: JSONString
+ trackInventory: Boolean!
- """Slug of the category."""
- slug: String!
+ """The maximum quantity of this variant that a customer can purchase."""
+ quantityLimitPerCustomer: Int
- """Parent category."""
- parent: Category
+ """The weight of the product variant."""
+ weight: Weight
- """Level of the category."""
- level: Int!
+ """
+ Channel given to retrieve this product variant. Also used by federation gateway to resolve this object in a federated query.
+ """
+ channel: String
"""
- Description of the category.
+ List of price information in channels for the product.
- Rich text format. For reference see https://editorjs.io/
+ Requires one of the following permissions: AUTHENTICATED_APP, AUTHENTICATED_STAFF_USER.
"""
- descriptionJson: JSONString @deprecated(reason: "Use the `description` field instead.")
-
- """The date and time when the category was last updated."""
- updatedAt: DateTime!
-
- """List of ancestors of the category."""
- ancestors(
- """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
+ channelListings: [ProductVariantChannelListing!]
+ """
+ Lists the storefront variant's pricing, the current price and discounts, only meant for displaying.
+ """
+ pricing(
"""
- Retrieve the first n elements from the list. Note that the system only allows fetching a maximum of 100 objects in a single query.
+ Destination address used to find warehouses where stock availability for this product is checked. If address is empty, uses `Shop.companyAddress` or fallbacks to server's `settings.DEFAULT_COUNTRY` configuration.
"""
- first: Int
+ address: AddressInput
+ ): VariantPricingInfo
- """
- 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
- ): CategoryCountableConnection
+ """List of attributes assigned to this variant."""
+ attributes(
+ """Define scope of returned attributes."""
+ variantSelection: VariantAttributeScope
+ ): [SelectedAttribute!]!
+
+ """Gross margin percentage value."""
+ margin: Int
"""
- List of products in the category. Requires the following permissions to include the unpublished items: MANAGE_ORDERS, MANAGE_DISCOUNTS, MANAGE_PRODUCTS.
+ Total quantity ordered.
+
+ Requires one of the following permissions: MANAGE_PRODUCTS.
"""
- products(
- """
- Filtering options for products. {DEPRECATED_IN_3X_INPUT} Use `where` filter instead.
- """
- filter: ProductFilterInput
-
- """Where filtering options for products."""
- where: ProductWhereInput
-
- """Sort products."""
- sortBy: ProductOrder
-
- """Search products."""
- search: String
-
- """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
+ quantityOrdered: Int
- """Return the elements in the list that come after the specified cursor."""
- after: String
+ """
+ Total revenue generated by a variant in given period of time. Note: this field should be queried using `reportProductSales` query as it uses optimizations suitable for such calculations.
+
+ Requires one of the following permissions: MANAGE_PRODUCTS.
+ """
+ revenue(period: ReportingPeriod): TaxedMoney
- """
- 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
+ """List of images for the product variant."""
+ images: [ProductImage!] @deprecated(reason: "Use the `media` field instead.")
- """
- 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
+ """List of media for the product variant."""
+ media: [ProductMedia!]
- """List of children of the category."""
- children(
- """Return the elements in the list that come before the specified cursor."""
- before: String
+ """Returns translated product variant fields for the given language code."""
+ translation(
+ """A language code to return the translation for product variant."""
+ languageCode: LanguageCodeEnum!
+ ): ProductVariantTranslation
- """Return the elements in the list that come after the specified cursor."""
- after: String
+ """
+ Digital content for the product variant.
+
+ Requires one of the following permissions: MANAGE_PRODUCTS.
+ """
+ digitalContent: DigitalContent
+ """
+ Stocks for the product variant.
+
+ Requires one of the following permissions: MANAGE_PRODUCTS, MANAGE_ORDERS.
+ """
+ stocks(
"""
- Retrieve the first n elements from the list. Note that the system only allows fetching a maximum of 100 objects in a single query.
+ Destination address used to find warehouses where stock availability for this product is checked. If address is empty, uses `Shop.companyAddress` or fallbacks to server's `settings.DEFAULT_COUNTRY` configuration.
"""
- first: Int
+ address: AddressInput
- """
- 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
- ): CategoryCountableConnection
+ """Two-letter ISO 3166-1 country code."""
+ countryCode: CountryCode @deprecated(reason: "Use `address` argument instead.")
+ ): [Stock!]
- """Background image of the category."""
- backgroundImage(
+ """
+ Quantity of a product available for sale in one checkout. Field value will be `null` when no `limitQuantityPerCheckout` in global settings has been set, and `productVariant` stocks are not tracked.
+ """
+ quantityAvailable(
"""
- Desired longest side the image in pixels. Defaults to 4096. Images are never cropped. Pass 0 to retrieve the original size (not recommended).
+ Destination address used to find warehouses where stock availability for this product is checked. If address is empty, uses `Shop.companyAddress` or fallbacks to server's `settings.DEFAULT_COUNTRY` configuration.
"""
- size: Int
+ address: AddressInput
"""
- The format of the image. When not provided, format of the original image will be used.
+ Two-letter ISO 3166-1 country code. When provided, the exact quantity from a warehouse operating in shipping zones that contain this country will be returned. Otherwise, it will return the maximum quantity from all shipping zones.
"""
- format: ThumbnailFormatEnum = ORIGINAL
- ): Image
-
- """Returns translated category fields for the given language code."""
- translation(
- """A language code to return the translation for category."""
- languageCode: LanguageCodeEnum!
- ): CategoryTranslation
-}
+ countryCode: CountryCode @deprecated(reason: "Use `address` argument instead.")
+ ): Int
-type CategoryCountableConnection @doc(category: "Products") {
- """Pagination data for this connection."""
- pageInfo: PageInfo!
- edges: [CategoryCountableEdge!]!
+ """Preorder data for product variant."""
+ preorder: PreorderData
- """A total count of items in the collection."""
- totalCount: Int
-}
+ """The date and time when the product variant was created."""
+ created: DateTime!
-type CategoryCountableEdge @doc(category: "Products") {
- """The item at the end of the edge."""
- node: Category!
+ """The date and time when the product variant was last updated."""
+ updatedAt: DateTime!
- """A cursor for use in pagination."""
- cursor: String!
+ """External ID of this product."""
+ externalReference: String
}
-input ProductFilterInput @doc(category: "Products") {
- isPublished: Boolean
- collections: [ID!]
- categories: [ID!]
- hasCategory: Boolean
- attributes: [AttributeInput!]
-
- """Filter by variants having specific stock status."""
- stockAvailability: StockAvailability
- stocks: ProductStockFilterInput
- search: String
- metadata: [MetadataFilter!]
+"""Represents product variant channel listing."""
+type ProductVariantChannelListing implements Node @doc(category: "Products") {
+ """The ID of the variant channel listing."""
+ id: ID!
- """Filter by the publication date."""
- publishedFrom: DateTime
+ """The channel to which the variant listing belongs."""
+ channel: Channel!
- """Filter by availability for purchase."""
- isAvailable: Boolean
+ """The price of the variant."""
+ price: Money
- """Filter by the date of availability for purchase."""
- availableFrom: DateTime
+ """Cost price of the variant."""
+ costPrice: Money
- """Filter by visibility in product listings."""
- isVisibleInListing: Boolean
- price: PriceRangeInput
+ """
+ Prior price of the variant used for discount calculations.
+
+ Added in Saleor 3.21.
+ """
+ priorPrice: Money
- """Filter by the lowest variant price after discounts."""
- minimalPrice: PriceRangeInput
+ """
+ Gross margin percentage value.
+
+ Requires one of the following permissions: MANAGE_PRODUCTS.
+ """
+ margin: Int
- """Filter by when was the most recent update."""
- updatedAt: DateTimeRangeInput
- productTypes: [ID!]
+ """Preorder variant data."""
+ preorderThreshold: PreorderThreshold
+}
- """Filter on whether product is a gift card or not."""
- giftCard: Boolean
- ids: [ID!]
- hasPreorderedVariants: Boolean
- slugs: [String!]
+"""Represents preorder variant data for channel."""
+type PreorderThreshold @doc(category: "Products") {
+ """Preorder threshold for product variant in this channel."""
+ quantity: Int
- """Specifies the channel by which the data should be filtered."""
- channel: String @deprecated(reason: "Use root-level channel argument instead.")
+ """Number of sold product variant in this channel."""
+ soldUnits: Int!
}
-input AttributeInput @doc(category: "Attributes") {
- """Internal representation of an attribute name."""
- slug: String!
+"""Represents availability of a variant in the storefront."""
+type VariantPricingInfo @doc(category: "Products") {
+ """Whether it is in sale or not."""
+ onSale: Boolean
+
+ """The discount amount if in sale (null otherwise)."""
+ discount: TaxedMoney
"""
- Names corresponding to the attributeValues associated with the Attribute. When specified, it filters the results to include only records with one of the matching values.
+ The discount amount compared to prior price. Null if product is not on sale or prior price was not provided in VariantChannelListing
- Added in Saleor 3.22.
+ Added in Saleor 3.21.
"""
- valueNames: [String!]
+ discountPrior: TaxedMoney
- """
- Slugs identifying the attributeValues associated with the Attribute. When specified, it filters the results to include only records with one of the matching values.
- """
- values: [String!]
+ """The discount amount in the local currency."""
+ discountLocalCurrency: TaxedMoney @deprecated(reason: "Always returns `null`.")
- """The range that the returned values should be in."""
- valuesRange: IntRangeInput
+ """The price, with any discount subtracted."""
+ price: TaxedMoney
- """The date/time range that the returned values should be in."""
- dateTime: DateTimeRangeInput
+ """The price without any discount."""
+ priceUndiscounted: TaxedMoney
"""
- The date range that the returned values should be in. In case of date/time attributes, the UTC midnight of the given date is used.
+ The price prior to discount.
+
+ Added in Saleor 3.21.
"""
- date: DateRangeInput
+ pricePrior: TaxedMoney
- """The boolean value of the attribute."""
- boolean: Boolean
+ """The discounted price in the local currency."""
+ priceLocalCurrency: TaxedMoney @deprecated(reason: "Always returns `null`.")
}
-input IntRangeInput {
- """Value greater than or equal to."""
- gte: Int
+"""
+Represents a monetary value with taxes. In cases where taxes were not applied, net and gross values will be equal.
+"""
+type TaxedMoney {
+ """Currency code."""
+ currency: String!
- """Value less than or equal to."""
- lte: Int
-}
+ """Amount of money including taxes."""
+ gross: Money!
-input DateTimeRangeInput {
- """Start date."""
- gte: DateTime
+ """Amount of money without taxes."""
+ net: Money!
- """End date."""
- lte: DateTime
-}
-
-input DateRangeInput {
- """Start date."""
- gte: Date
-
- """End date."""
- lte: Date
-}
-
-enum StockAvailability @doc(category: "Products") {
- IN_STOCK
- OUT_OF_STOCK
-}
-
-input ProductStockFilterInput @doc(category: "Products") {
- warehouseIds: [ID!]
- quantity: IntRangeInput
-}
-
-input PriceRangeInput {
- """Price greater than or equal to."""
- gte: Float
-
- """Price less than or equal to."""
- lte: Float
+ """Amount of taxes."""
+ tax: Money!
}
-input ProductWhereInput @doc(category: "Products") {
- metadata: [MetadataFilter!]
- ids: [ID!]
-
- """Filter by product name."""
- name: StringFilterInput
-
- """Filter by product slug."""
- slug: StringFilterInput
-
- """Filter by product type."""
- productType: GlobalIDFilterInput
-
- """Filter by product category."""
- category: GlobalIDFilterInput
-
- """Filter by collection."""
- collection: GlobalIDFilterInput
-
- """Filter by availability for purchase."""
- isAvailable: Boolean
-
- """Filter by public visibility."""
- isPublished: Boolean
-
- """Filter by visibility on the channel."""
- isVisibleInListing: Boolean
-
- """Filter by the publication date."""
- publishedFrom: DateTime
+input AddressInput {
+ """Given name."""
+ firstName: String
- """Filter by the date of availability for purchase."""
- availableFrom: DateTime
+ """Family name."""
+ lastName: String
- """Filter by product with category assigned."""
- hasCategory: Boolean
+ """Company or organization."""
+ companyName: String
- """Filter by product variant price."""
- price: DecimalFilterInput
+ """Address."""
+ streetAddress1: String
- """Filter by the lowest variant price after discounts."""
- minimalPrice: DecimalFilterInput
+ """Address."""
+ streetAddress2: String
- """Filter by attributes associated with the product."""
- attributes: [AttributeInput!]
+ """City."""
+ city: String
- """Filter by variants having specific stock status."""
- stockAvailability: StockAvailability
+ """District."""
+ cityArea: String
- """Filter by stock of the product variant."""
- stocks: ProductStockFilterInput
+ """Postal code."""
+ postalCode: String
- """Filter on whether product is a gift card or not."""
- giftCard: Boolean
+ """Country."""
+ country: CountryCode
- """Filter by product with preordered variants."""
- hasPreorderedVariants: Boolean
+ """State or province."""
+ countryArea: String
- """Filter by when was the most recent update."""
- updatedAt: DateTimeFilterInput
+ """
+ Phone number.
+
+ Phone numbers are validated with Google's [libphonenumber](https://github.com/google/libphonenumber) library.
+ """
+ phone: String
- """List of conditions that must be met."""
- AND: [ProductWhereInput!]
+ """
+ Address public metadata. Can be read by any API client authorized to read the object it's attached to.
+
+ Warning: never store sensitive information, including financial data such as credit card details.
+ """
+ metadata: [MetadataInput!]
- """A list of conditions of which at least one must be met."""
- OR: [ProductWhereInput!]
+ """
+ Determine if the address should be validated. By default, Saleor accepts only address inputs matching ruleset from [Google Address Data]{https://chromium-i18n.appspot.com/ssl-address), using [i18naddress](https://github.com/mirumee/google-i18n-address) library. Some mutations may require additional permissions to use the the field. More info about permissions can be found in relevant mutation.
+
+ Added in Saleor 3.19.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ skipValidation: Boolean = false
}
-"""Define the filtering options for foreign key fields."""
-input GlobalIDFilterInput {
- """The value equal to."""
- eq: ID
+input MetadataInput {
+ """Key of a metadata item."""
+ key: String!
- """The value included in."""
- oneOf: [ID!]
+ """Value of a metadata item."""
+ value: String!
}
-"""Define the filtering options for decimal fields."""
-input DecimalFilterInput {
- """The value equal to."""
- eq: Decimal
+"""Represents a custom attribute."""
+type SelectedAttribute @doc(category: "Attributes") {
+ """Name of an attribute displayed in the interface."""
+ attribute: Attribute!
- """The value included in."""
- oneOf: [Decimal!]
+ """Values of an attribute."""
+ values: [AttributeValue!]!
+}
- """The value in range."""
- range: DecimalRangeInput
+enum VariantAttributeScope @doc(category: "Products") {
+ ALL
+ VARIANT_SELECTION
+ NOT_VARIANT_SELECTION
}
-"""
-Custom Decimal implementation.
+enum ReportingPeriod {
+ TODAY
+ THIS_MONTH
+}
-Returns Decimal as a float in the API,
-parses float to the Decimal on the way back.
-"""
-scalar Decimal
+"""Represents a product image."""
+type ProductImage @doc(category: "Products") {
+ """The ID of the image."""
+ id: ID!
-input DecimalRangeInput {
- """Decimal value greater than or equal to."""
- gte: Decimal
+ """The alt text of the image."""
+ alt: String
- """Decimal value less than or equal to."""
- lte: Decimal
-}
+ """
+ The new relative sorting position of the item (from -inf to +inf). 1 moves the item one position forward, -1 moves the item one position backward, 0 leaves the item unchanged.
+ """
+ sortOrder: Int
-"""Define the filtering options for date time fields."""
-input DateTimeFilterInput {
- """The value equal to."""
- eq: DateTime
+ """The URL of the image."""
+ url(
+ """
+ Desired longest side the image in pixels. Defaults to 4096. Images are never cropped. Pass 0 to retrieve the original size (not recommended).
+ """
+ size: Int
- """The value included in."""
- oneOf: [DateTime!]
+ """
+ The format of the image. When not provided, format of the original image will be used.
+ """
+ format: ThumbnailFormatEnum = ORIGINAL
+ ): String!
+}
- """The value in range."""
- range: DateTimeRangeInput
+enum ThumbnailFormatEnum {
+ ORIGINAL
+ AVIF
+ WEBP
}
-input ProductOrder @doc(category: "Products") {
- """Specifies the direction in which to sort products."""
- direction: OrderDirection!
+"""Represents a product media."""
+type ProductMedia implements Node & ObjectWithMetadata @doc(category: "Products") {
+ """The unique ID of the product media."""
+ id: ID!
- """Specifies the channel in which to sort the data."""
- channel: String @deprecated(reason: "Use root-level channel argument instead.")
+ """List of private metadata items. Requires staff permissions to access."""
+ privateMetadata: [MetadataItem!]!
"""
- Sort product by the selected attribute's values.
- Note: this doesn't take translations into account yet.
+ A single key from private metadata. Requires staff permissions to access.
+
+ Tip: Use GraphQL aliases to fetch multiple keys.
"""
- attributeId: ID
-
- """Sort products by the selected field."""
- field: ProductOrderField
-}
-
-enum ProductOrderField @doc(category: "Products") {
- """Sort products by name."""
- NAME
+ privateMetafield(key: String!): String
"""
- Sort products by rank. Note: This option is available only with the `search` filter.
+ Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
"""
- RANK
+ privateMetafields(keys: [String!]): Metadata
+
+ """List of public metadata items. Can be accessed without permissions."""
+ metadata: [MetadataItem!]!
"""
- Sort products by price.
+ A single key from public metadata.
- This option requires a channel filter to work as the values can vary between channels.
+ Tip: Use GraphQL aliases to fetch multiple keys.
"""
- PRICE
+ metafield(key: String!): String
"""
- Sort products by a minimal price of a product's variant.
-
- This option requires a channel filter to work as the values can vary between channels.
+ Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.
"""
- MINIMAL_PRICE
+ metafields(keys: [String!]): Metadata
+
+ """The sort order of the media."""
+ sortOrder: Int
+
+ """The alt text of the media."""
+ alt: String!
+
+ """The type of the media."""
+ type: ProductMediaType!
+
+ """The oEmbed data of the media."""
+ oembedData: JSONString!
+
+ """The URL of the media."""
+ url(
+ """
+ Desired longest side the image in pixels. Defaults to 4096. Images are never cropped. Pass 0 to retrieve the original size (not recommended).
+ """
+ size: Int
+
+ """
+ The format of the image. When not provided, format of the original image will be used.
+ """
+ format: ThumbnailFormatEnum = ORIGINAL
+ ): String!
+
+ """Product id the media refers to."""
+ productId: ID
+}
+
+enum ProductMediaType @doc(category: "Products") {
+ IMAGE
+ VIDEO
+}
+
+"""Represents product variant translations."""
+type ProductVariantTranslation implements Node @doc(category: "Products") {
+ """The ID of the product variant translation."""
+ id: ID!
+
+ """Translation language."""
+ language: LanguageDisplay!
+
+ """Translated product variant name."""
+ name: String!
+
+ """Represents the product variant fields to translate."""
+ translatableContent: ProductVariantTranslatableContent
+}
+
+"""
+Represents product variant's original translatable fields and related translations.
+"""
+type ProductVariantTranslatableContent implements Node @doc(category: "Products") {
+ """The ID of the product variant translatable content."""
+ id: ID!
+
+ """The ID of the product variant to translate."""
+ productVariantId: ID!
+
+ """Name of the product variant to translate."""
+ name: String!
+
+ """Returns translated product variant fields for the given language code."""
+ translation(
+ """A language code to return the translation for product variant."""
+ languageCode: LanguageCodeEnum!
+ ): ProductVariantTranslation
+
+ """Represents a version of a product such as different size or color."""
+ productVariant: ProductVariant @deprecated(reason: "Get model fields from the root level queries.")
+
+ """List of product variant attribute values that can be translated."""
+ attributeValues: [AttributeValueTranslatableContent!]!
+}
+
+"""Represents digital content associated with a product variant."""
+type DigitalContent implements Node & ObjectWithMetadata @doc(category: "Products") {
+ """The ID of the digital content."""
+ 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
+
+ """Default settings indicator for digital content."""
+ useDefaultSettings: Boolean!
+
+ """Indicator for automatic fulfillment of digital content."""
+ automaticFulfillment: Boolean!
+
+ """File associated with digital content."""
+ contentFile: String!
+
+ """Maximum number of allowed downloads for the digital content."""
+ maxDownloads: Int
+
+ """Number of days the URL for the digital content remains valid."""
+ urlValidDays: Int
+
+ """List of URLs for the digital variant."""
+ urls: [DigitalContentUrl!]
+
+ """Product variant assigned to digital content."""
+ productVariant: ProductVariant!
+}
+
+"""Represents a URL for digital content."""
+type DigitalContentUrl implements Node @doc(category: "Products") {
+ """The ID of the digital content URL."""
+ id: ID!
+
+ """Digital content associated with the URL."""
+ content: DigitalContent!
+
+ """Date and time when the digital content URL was created."""
+ created: DateTime!
+
+ """Number of times digital content has been downloaded."""
+ downloadNum: Int!
+
+ """URL for digital content."""
+ url: String
+
+ """UUID of digital content."""
+ token: UUID!
+}
+
+scalar UUID
+
+"""Represents stock."""
+type Stock implements Node @doc(category: "Products") {
+ """The ID of stock."""
+ id: ID!
+
+ """The warehouse associated with the stock."""
+ warehouse: Warehouse!
+
+ """Information about the product variant."""
+ productVariant: ProductVariant!
+
+ """
+ Quantity of a product in the warehouse's possession, including the allocated stock that is waiting for shipment.
+
+ Requires one of the following permissions: MANAGE_PRODUCTS, MANAGE_ORDERS.
+ """
+ quantity: Int!
+
+ """
+ Quantity allocated for orders.
+
+ Requires one of the following permissions: MANAGE_PRODUCTS, MANAGE_ORDERS.
+ """
+ quantityAllocated: Int!
+
+ """
+ Quantity reserved for checkouts.
+
+ Requires one of the following permissions: MANAGE_PRODUCTS, MANAGE_ORDERS.
+ """
+ quantityReserved: Int!
+}
+
+"""Represents preorder settings for product variant."""
+type PreorderData @doc(category: "Products") {
+ """
+ The global preorder threshold for product variant.
+
+ Requires one of the following permissions: MANAGE_PRODUCTS.
+ """
+ globalThreshold: Int
+
+ """
+ Total number of sold product variant during preorder.
+
+ Requires one of the following permissions: MANAGE_PRODUCTS.
+ """
+ globalSoldUnits: Int!
+
+ """Preorder end date."""
+ endDate: DateTime
+}
+
+"""
+A static page that can be manually added by a shop operator through the dashboard.
+"""
+type Page implements Node & ObjectWithMetadata @doc(category: "Pages") {
+ """ID of the page."""
+ 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
+
+ """Title of the page for SEO."""
+ seoTitle: String
+
+ """Description of the page for SEO."""
+ seoDescription: String
+
+ """Title of the page."""
+ title: String!
+
+ """
+ Content of the page.
+
+ Rich text format. For reference see https://editorjs.io/
+ """
+ content: JSONString
+ publicationDate: Date @deprecated(reason: "Use the `publishedAt` field to fetch the publication date.")
+
+ """The page publication date."""
+ publishedAt: DateTime
+
+ """Determines if the page is published."""
+ isPublished: Boolean!
+
+ """Slug of the page."""
+ slug: String!
+
+ """Determines the type of page"""
+ pageType: PageType!
+
+ """Date and time at which page was created."""
+ created: DateTime!
+
+ """
+ Content of the page.
+
+ Rich text format. For reference see https://editorjs.io/
+ """
+ contentJson: JSONString! @deprecated(reason: "Use the `content` field instead.")
+
+ """Returns translated page fields for the given language code."""
+ translation(
+ """A language code to return the translation for page."""
+ languageCode: LanguageCodeEnum!
+ ): PageTranslation
+
+ """Get a single attribute attached to page by attribute slug."""
+ attribute(
+ """Slug of the attribute"""
+ slug: String!
+ ): SelectedAttribute
+
+ """List of attributes assigned to this page."""
+ attributes: [SelectedAttribute!]!
+}
+
+"""
+The `Date` scalar type represents a Date
+value as specified by
+[iso8601](https://en.wikipedia.org/wiki/ISO_8601).
+"""
+scalar Date
+
+"""
+Represents a type of page. It defines what attributes are available to pages of this type.
+"""
+type PageType implements Node & ObjectWithMetadata @doc(category: "Pages") {
+ """ID of the page 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 page type."""
+ name: String!
+
+ """Slug of the page type."""
+ slug: String!
+
+ """Page attributes of that page type."""
+ attributes: [Attribute!]
+
+ """
+ Attributes that can be assigned to the page type.
+
+ Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES.
+ """
+ availableAttributes(
+ """Filtering options for attributes."""
+ filter: AttributeFilterInput @deprecated(reason: "Use `where` filter instead.")
+
+ """Where filtering options for attributes."""
+ 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
+
+ """
+ Whether page type has pages assigned.
+
+ Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES.
+ """
+ hasPages: Boolean
+}
+
+type AttributeCountableConnection @doc(category: "Attributes") {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [AttributeCountableEdge!]!
+
+ """A total count of items in the collection."""
+ totalCount: Int
+}
+
+type AttributeCountableEdge @doc(category: "Attributes") {
+ """The item at the end of the edge."""
+ node: Attribute!
+
+ """A cursor for use in pagination."""
+ cursor: String!
+}
+
+input AttributeFilterInput @doc(category: "Attributes") {
+ valueRequired: Boolean
+ isVariantOnly: Boolean
+ visibleInStorefront: Boolean
+ filterableInStorefront: Boolean
+ filterableInDashboard: Boolean
+ availableInGrid: Boolean
+ metadata: [MetadataFilter!]
+ search: String
+ ids: [ID!]
+ type: AttributeTypeEnum
+ inCollection: ID
+ inCategory: ID
+ slugs: [String!]
+
+ """Specifies the channel by which the data should be filtered."""
+ channel: String @deprecated(reason: "Use root-level channel argument instead.")
+}
+
+input MetadataFilter {
+ """Key of a metadata item."""
+ key: String!
- """Sort products by update date."""
- LAST_MODIFIED @deprecated(reason: "Use `LAST_MODIFIED_AT` instead.")
+ """Value of a metadata item."""
+ value: String
+}
- """Sort products by update date."""
- DATE @deprecated(reason: "Use `LAST_MODIFIED_AT` instead.")
+"""Where filtering options."""
+input AttributeWhereInput @doc(category: "Attributes") {
+ metadata: [MetadataFilter!]
+ ids: [ID!]
+ name: StringFilterInput
+ slug: StringFilterInput
+ withChoices: Boolean
+ inputType: AttributeInputTypeEnumFilterInput
+ entityType: AttributeEntityTypeEnumFilterInput
+ type: AttributeTypeEnumFilterInput
+ unit: MeasurementUnitsEnumFilterInput
+ inCollection: ID
+ inCategory: ID
+ valueRequired: Boolean
+ visibleInStorefront: Boolean
+ filterableInDashboard: Boolean
- """Sort products by type."""
- TYPE
+ """List of conditions that must be met."""
+ AND: [AttributeWhereInput!]
- """
- Sort products by publication status.
-
- This option requires a channel filter to work as the values can vary between channels.
- """
- PUBLISHED
+ """A list of conditions of which at least one must be met."""
+ OR: [AttributeWhereInput!]
+}
- """
- Sort products by publication date.
-
- This option requires a channel filter to work as the values can vary between channels.
- """
- PUBLICATION_DATE @deprecated(reason: "Use `PUBLISHED_AT` instead.")
+"""Define the filtering options for string fields."""
+input StringFilterInput {
+ """The value equal to."""
+ eq: String
- """
- Sort products by publication date.
-
- This option requires a channel filter to work as the values can vary between channels.
- """
- PUBLISHED_AT
+ """The value included in."""
+ oneOf: [String!]
+}
- """Sort products by update date."""
- LAST_MODIFIED_AT
+input AttributeInputTypeEnumFilterInput @doc(category: "Attributes") {
+ """The value equal to."""
+ eq: AttributeInputTypeEnum
- """
- Sort products by collection. Note: This option is available only for the `Collection.products` query.
-
- This option requires a channel filter to work as the values can vary between channels.
- """
- COLLECTION
+ """The value included in."""
+ oneOf: [AttributeInputTypeEnum!]
+}
- """Sort products by rating."""
- RATING
+input AttributeEntityTypeEnumFilterInput @doc(category: "Attributes") {
+ """The value equal to."""
+ eq: AttributeEntityTypeEnum
- """Sort products by creation date."""
- CREATED_AT
+ """The value included in."""
+ oneOf: [AttributeEntityTypeEnum!]
}
-"""Represents an image."""
-type Image {
- """The URL of the image."""
- url: String!
+input AttributeTypeEnumFilterInput @doc(category: "Attributes") {
+ """The value equal to."""
+ eq: AttributeTypeEnum
- """Alt text for an image."""
- alt: String
+ """The value included in."""
+ oneOf: [AttributeTypeEnum!]
}
-enum ThumbnailFormatEnum {
- ORIGINAL
- AVIF
- WEBP
+input MeasurementUnitsEnumFilterInput @doc(category: "Attributes") {
+ """The value equal to."""
+ eq: MeasurementUnitsEnum
+
+ """The value included in."""
+ oneOf: [MeasurementUnitsEnum!]
}
-"""Represents category translations."""
-type CategoryTranslation implements Node @doc(category: "Products") {
- """The ID of the category translation."""
+"""Represents page translations."""
+type PageTranslation implements Node @doc(category: "Pages") {
+ """The ID of the page translation."""
id: ID!
"""Translation language."""
@@ -7095,42 +7310,42 @@ type CategoryTranslation implements Node @doc(category: "Products") {
seoDescription: String
"""
- Translated category slug.
+ Translated page slug.
Added in Saleor 3.21.
"""
slug: String
- """Translated category name."""
- name: String
+ """Translated page title."""
+ title: String
"""
- Translated description of the category.
+ Translated content of the page.
Rich text format. For reference see https://editorjs.io/
"""
- description: JSONString
+ content: JSONString
"""
- Translated description of the category.
+ Translated description of the page.
Rich text format. For reference see https://editorjs.io/
"""
- descriptionJson: JSONString @deprecated(reason: "Use the `description` field instead.")
+ contentJson: JSONString @deprecated(reason: "Use the `content` field instead.")
- """Represents the category fields to translate."""
- translatableContent: CategoryTranslatableContent
+ """Represents the page fields to translate."""
+ translatableContent: PageTranslatableContent
}
"""
-Represents category original translatable fields and related translations.
+Represents page's original translatable fields and related translations.
"""
-type CategoryTranslatableContent implements Node @doc(category: "Products") {
- """The ID of the category translatable content."""
+type PageTranslatableContent implements Node @doc(category: "Pages") {
+ """The ID of the page translatable content."""
id: ID!
- """The ID of the category to translate."""
- categoryId: ID!
+ """The ID of the page to translate."""
+ pageId: ID!
"""SEO title to translate."""
seoTitle: String
@@ -7145,633 +7360,702 @@ type CategoryTranslatableContent implements Node @doc(category: "Products") {
"""
slug: String
- """Name of the category translatable content."""
- name: String!
+ """Page title to translate."""
+ title: String!
"""
- Category description to translate.
+ Content of the page to translate.
Rich text format. For reference see https://editorjs.io/
"""
- description: JSONString
+ content: JSONString
"""
- Description of the category.
+ Content of the page.
Rich text format. For reference see https://editorjs.io/
"""
- descriptionJson: JSONString @deprecated(reason: "Use the `description` field instead.")
+ contentJson: JSONString @deprecated(reason: "Use the `content` field instead.")
- """Returns translated category fields for the given language code."""
+ """Returns translated page fields for the given language code."""
translation(
- """A language code to return the translation for category."""
+ """A language code to return the translation for page."""
languageCode: LanguageCodeEnum!
- ): CategoryTranslation
+ ): PageTranslation
- """Represents a single category of products."""
- category: Category @deprecated(reason: "Get model fields from the root level queries.")
-}
+ """
+ A static page that can be manually added by a shop operator through the dashboard.
+ """
+ page: Page @deprecated(reason: "Get model fields from the root level queries.")
-"""Represents a version of a product such as different size or color."""
-type ProductVariant implements Node & ObjectWithMetadata @doc(category: "Products") {
- """The ID of the product variant."""
- id: ID!
+ """List of page content attribute values that can be translated."""
+ attributeValues: [AttributeValueTranslatableContent!]!
+}
- """List of private metadata items. Requires staff permissions to access."""
- privateMetadata: [MetadataItem!]!
+type File {
+ """The URL of the file."""
+ url: String!
- """
- A single key from private metadata. Requires staff permissions to access.
-
- Tip: Use GraphQL aliases to fetch multiple keys.
- """
- privateMetafield(key: String!): String
+ """Content type of the file."""
+ contentType: 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
+input AttributeChoicesSortingInput @doc(category: "Attributes") {
+ """Specifies the direction in which to sort attribute choices."""
+ direction: OrderDirection!
- """List of public metadata items. Can be accessed without permissions."""
- metadata: [MetadataItem!]!
+ """Sort attribute choices by the selected field."""
+ field: AttributeChoicesSortField!
+}
- """
- A single key from public metadata.
-
- Tip: Use GraphQL aliases to fetch multiple keys.
- """
- metafield(key: String!): String
+enum AttributeChoicesSortField @doc(category: "Attributes") {
+ """Sort attribute choice by name."""
+ NAME
- """
- Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.
- """
- metafields(keys: [String!]): Metadata
+ """Sort attribute choice by slug."""
+ SLUG
+}
- """The name of the product variant."""
- name: String!
+input AttributeValueFilterInput @doc(category: "Attributes") {
+ search: String
+ ids: [ID!]
+ slugs: [String!]
+}
- """The SKU (stock keeping unit) of the product variant."""
- sku: String
+type ProductTypeCountableConnection @doc(category: "Products") {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [ProductTypeCountableEdge!]!
- """The product to which the variant belongs."""
- product: Product!
+ """A total count of items in the collection."""
+ totalCount: Int
+}
- """
- Determines if the inventory of this variant should be tracked. If false, the quantity won't change when customers buy this item. If the field is not provided, `Shop.trackInventoryByDefault` will be used.
- """
- trackInventory: Boolean!
+type ProductTypeCountableEdge @doc(category: "Products") {
+ """The item at the end of the edge."""
+ node: ProductType!
- """The maximum quantity of this variant that a customer can purchase."""
- quantityLimitPerCustomer: Int
+ """A cursor for use in pagination."""
+ cursor: String!
+}
- """The weight of the product variant."""
- weight: Weight
+"""
+Represents assigned attribute to variant with variant selection attached.
+"""
+type AssignedVariantAttribute @doc(category: "Attributes") {
+ """Attribute assigned to variant."""
+ attribute: Attribute!
"""
- Channel given to retrieve this product variant. Also used by federation gateway to resolve this object in a federated query.
+ Determines, whether assigned attribute is allowed for variant selection. Supported variant types for variant selection are: ['dropdown', 'boolean', 'swatch', 'numeric']
"""
- channel: String
+ variantSelection: Boolean!
+}
+
+"""
+Represents a single category of products. Categories allow to organize products in a tree-hierarchies which can be used for navigation in the storefront.
+"""
+type Category implements Node & ObjectWithMetadata @doc(category: "Products") {
+ """The ID of the category."""
+ id: ID!
+
+ """List of private metadata items. Requires staff permissions to access."""
+ privateMetadata: [MetadataItem!]!
"""
- List of price information in channels for the product.
+ A single key from private metadata. Requires staff permissions to access.
- Requires one of the following permissions: AUTHENTICATED_APP, AUTHENTICATED_STAFF_USER.
+ Tip: Use GraphQL aliases to fetch multiple keys.
"""
- channelListings: [ProductVariantChannelListing!]
+ privateMetafield(key: String!): String
"""
- Lists the storefront variant's pricing, the current price and discounts, only meant for displaying.
+ Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
"""
- pricing(
- """
- Destination address used to find warehouses where stock availability for this product is checked. If address is empty, uses `Shop.companyAddress` or fallbacks to server's `settings.DEFAULT_COUNTRY` configuration.
- """
- address: AddressInput
- ): VariantPricingInfo
-
- """List of attributes assigned to this variant."""
- attributes(
- """Define scope of returned attributes."""
- variantSelection: VariantAttributeScope
- ): [SelectedAttribute!]!
+ privateMetafields(keys: [String!]): Metadata
- """Gross margin percentage value."""
- margin: Int
+ """List of public metadata items. Can be accessed without permissions."""
+ metadata: [MetadataItem!]!
"""
- Total quantity ordered.
+ A single key from public metadata.
- Requires one of the following permissions: MANAGE_PRODUCTS.
+ Tip: Use GraphQL aliases to fetch multiple keys.
"""
- quantityOrdered: Int
+ metafield(key: String!): String
"""
- Total revenue generated by a variant in given period of time. Note: this field should be queried using `reportProductSales` query as it uses optimizations suitable for such calculations.
-
- Requires one of the following permissions: MANAGE_PRODUCTS.
+ Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.
"""
- revenue(period: ReportingPeriod): TaxedMoney
+ metafields(keys: [String!]): Metadata
- """List of images for the product variant."""
- images: [ProductImage!] @deprecated(reason: "Use the `media` field instead.")
+ """SEO title of category."""
+ seoTitle: String
- """List of media for the product variant."""
- media: [ProductMedia!]
+ """SEO description of category."""
+ seoDescription: String
- """Returns translated product variant fields for the given language code."""
- translation(
- """A language code to return the translation for product variant."""
- languageCode: LanguageCodeEnum!
- ): ProductVariantTranslation
+ """Name of category"""
+ name: String!
"""
- Digital content for the product variant.
+ Description of the category.
- Requires one of the following permissions: MANAGE_PRODUCTS.
+ Rich text format. For reference see https://editorjs.io/
"""
- digitalContent: DigitalContent
+ description: JSONString
+
+ """Slug of the category."""
+ slug: String!
+
+ """Parent category."""
+ parent: Category
+
+ """Level of the category."""
+ level: Int!
"""
- Stocks for the product variant.
+ Description of the category.
- Requires one of the following permissions: MANAGE_PRODUCTS, MANAGE_ORDERS.
+ Rich text format. For reference see https://editorjs.io/
"""
- stocks(
- """
- Destination address used to find warehouses where stock availability for this product is checked. If address is empty, uses `Shop.companyAddress` or fallbacks to server's `settings.DEFAULT_COUNTRY` configuration.
- """
- address: AddressInput
+ descriptionJson: JSONString @deprecated(reason: "Use the `description` field instead.")
- """Two-letter ISO 3166-1 country code."""
- countryCode: CountryCode @deprecated(reason: "Use `address` argument instead.")
- ): [Stock!]
+ """The date and time when the category was last updated."""
+ updatedAt: DateTime!
+
+ """List of ancestors of the category."""
+ ancestors(
+ """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
- """
- Quantity of a product available for sale in one checkout. Field value will be `null` when no `limitQuantityPerCheckout` in global settings has been set, and `productVariant` stocks are not tracked.
- """
- quantityAvailable(
"""
- Destination address used to find warehouses where stock availability for this product is checked. If address is empty, uses `Shop.companyAddress` or fallbacks to server's `settings.DEFAULT_COUNTRY` configuration.
+ Retrieve the first n elements from the list. Note that the system only allows fetching a maximum of 100 objects in a single query.
"""
- address: AddressInput
+ first: Int
"""
- Two-letter ISO 3166-1 country code. When provided, the exact quantity from a warehouse operating in shipping zones that contain this country will be returned. Otherwise, it will return the maximum quantity from all shipping zones.
+ Retrieve the last n elements from the list. Note that the system only allows fetching a maximum of 100 objects in a single query.
"""
- countryCode: CountryCode @deprecated(reason: "Use `address` argument instead.")
- ): Int
-
- """Preorder data for product variant."""
- preorder: PreorderData
-
- """The date and time when the product variant was created."""
- created: DateTime!
-
- """The date and time when the product variant was last updated."""
- updatedAt: DateTime!
-
- """External ID of this product."""
- externalReference: String
-}
-
-"""Represents product variant channel listing."""
-type ProductVariantChannelListing implements Node @doc(category: "Products") {
- """The ID of the variant channel listing."""
- id: ID!
+ last: Int
+ ): CategoryCountableConnection
- """The channel to which the variant listing belongs."""
- channel: Channel!
+ """
+ List of products in the category. Requires the following permissions to include the unpublished items: MANAGE_ORDERS, MANAGE_DISCOUNTS, MANAGE_PRODUCTS.
+ """
+ products(
+ """
+ Filtering options for products. {DEPRECATED_IN_3X_INPUT} Use `where` filter instead.
+ """
+ filter: ProductFilterInput
- """The price of the variant."""
- price: Money
+ """Where filtering options for products."""
+ where: ProductWhereInput
- """Cost price of the variant."""
- costPrice: Money
+ """Sort products."""
+ sortBy: ProductOrder
- """
- Prior price of the variant used for discount calculations.
-
- Added in Saleor 3.21.
- """
- priorPrice: Money
+ """Search products."""
+ search: String
- """
- Gross margin percentage value.
-
- Requires one of the following permissions: MANAGE_PRODUCTS.
- """
- margin: Int
+ """Slug of a channel for which the data should be returned."""
+ channel: String
- """Preorder variant data."""
- preorderThreshold: PreorderThreshold
-}
+ """Return the elements in the list that come before the specified cursor."""
+ before: String
-"""Represents preorder variant data for channel."""
-type PreorderThreshold @doc(category: "Products") {
- """Preorder threshold for product variant in this channel."""
- quantity: Int
+ """Return the elements in the list that come after the specified cursor."""
+ after: String
- """Number of sold product variant in this channel."""
- soldUnits: Int!
-}
+ """
+ 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
-"""Represents availability of a variant in the storefront."""
-type VariantPricingInfo @doc(category: "Products") {
- """Whether it is in sale or not."""
- onSale: Boolean
+ """
+ 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
- """The discount amount if in sale (null otherwise)."""
- discount: TaxedMoney
+ """List of children of the category."""
+ children(
+ """Return the elements in the list that come before the specified cursor."""
+ before: String
- """
- The discount amount compared to prior price. Null if product is not on sale or prior price was not provided in VariantChannelListing
-
- Added in Saleor 3.21.
- """
- discountPrior: TaxedMoney
+ """Return the elements in the list that come after the specified cursor."""
+ after: String
- """The discount amount in the local currency."""
- discountLocalCurrency: TaxedMoney @deprecated(reason: "Always returns `null`.")
+ """
+ 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
- """The price, with any discount subtracted."""
- price: TaxedMoney
+ """
+ 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
+ ): CategoryCountableConnection
- """The price without any discount."""
- priceUndiscounted: TaxedMoney
+ """Background image of the category."""
+ backgroundImage(
+ """
+ Desired longest side the image in pixels. Defaults to 4096. Images are never cropped. Pass 0 to retrieve the original size (not recommended).
+ """
+ size: Int
- """
- The price prior to discount.
-
- Added in Saleor 3.21.
- """
- pricePrior: TaxedMoney
+ """
+ The format of the image. When not provided, format of the original image will be used.
+ """
+ format: ThumbnailFormatEnum = ORIGINAL
+ ): Image
- """The discounted price in the local currency."""
- priceLocalCurrency: TaxedMoney @deprecated(reason: "Always returns `null`.")
+ """Returns translated category fields for the given language code."""
+ translation(
+ """A language code to return the translation for category."""
+ languageCode: LanguageCodeEnum!
+ ): CategoryTranslation
}
-"""
-Represents a monetary value with taxes. In cases where taxes were not applied, net and gross values will be equal.
-"""
-type TaxedMoney {
- """Currency code."""
- currency: String!
+type CategoryCountableConnection @doc(category: "Products") {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [CategoryCountableEdge!]!
- """Amount of money including taxes."""
- gross: Money!
+ """A total count of items in the collection."""
+ totalCount: Int
+}
- """Amount of money without taxes."""
- net: Money!
+type CategoryCountableEdge @doc(category: "Products") {
+ """The item at the end of the edge."""
+ node: Category!
- """Amount of taxes."""
- tax: Money!
+ """A cursor for use in pagination."""
+ cursor: String!
}
-input AddressInput {
- """Given name."""
- firstName: String
+input ProductFilterInput @doc(category: "Products") {
+ isPublished: Boolean
+ collections: [ID!]
+ categories: [ID!]
+ hasCategory: Boolean
+ attributes: [AttributeInput!]
- """Family name."""
- lastName: String
+ """Filter by variants having specific stock status."""
+ stockAvailability: StockAvailability
+ stocks: ProductStockFilterInput
+ search: String
+ metadata: [MetadataFilter!]
- """Company or organization."""
- companyName: String
+ """Filter by the publication date."""
+ publishedFrom: DateTime
- """Address."""
- streetAddress1: String
+ """Filter by availability for purchase."""
+ isAvailable: Boolean
- """Address."""
- streetAddress2: String
+ """Filter by the date of availability for purchase."""
+ availableFrom: DateTime
- """City."""
- city: String
+ """Filter by visibility in product listings."""
+ isVisibleInListing: Boolean
+ price: PriceRangeInput
- """District."""
- cityArea: String
+ """Filter by the lowest variant price after discounts."""
+ minimalPrice: PriceRangeInput
- """Postal code."""
- postalCode: String
+ """Filter by when was the most recent update."""
+ updatedAt: DateTimeRangeInput
+ productTypes: [ID!]
- """Country."""
- country: CountryCode
+ """Filter on whether product is a gift card or not."""
+ giftCard: Boolean
+ ids: [ID!]
+ hasPreorderedVariants: Boolean
+ slugs: [String!]
- """State or province."""
- countryArea: String
+ """Specifies the channel by which the data should be filtered."""
+ channel: String @deprecated(reason: "Use root-level channel argument instead.")
+}
+
+input AttributeInput @doc(category: "Attributes") {
+ """Internal representation of an attribute name."""
+ slug: String!
"""
- Phone number.
+ Names corresponding to the attributeValues associated with the Attribute. When specified, it filters the results to include only records with one of the matching values.
- Phone numbers are validated with Google's [libphonenumber](https://github.com/google/libphonenumber) library.
+ Added in Saleor 3.22.
"""
- phone: String
+ valueNames: [String!]
"""
- Address public metadata. Can be read by any API client authorized to read the object it's attached to.
-
- Warning: never store sensitive information, including financial data such as credit card details.
+ Slugs identifying the attributeValues associated with the Attribute. When specified, it filters the results to include only records with one of the matching values.
"""
- metadata: [MetadataInput!]
+ values: [String!]
+
+ """The range that the returned values should be in."""
+ valuesRange: IntRangeInput
+
+ """The date/time range that the returned values should be in."""
+ dateTime: DateTimeRangeInput
"""
- Determine if the address should be validated. By default, Saleor accepts only address inputs matching ruleset from [Google Address Data]{https://chromium-i18n.appspot.com/ssl-address), using [i18naddress](https://github.com/mirumee/google-i18n-address) library. Some mutations may require additional permissions to use the the field. More info about permissions can be found in relevant mutation.
-
- Added in Saleor 3.19.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ The date range that the returned values should be in. In case of date/time attributes, the UTC midnight of the given date is used.
"""
- skipValidation: Boolean = false
+ date: DateRangeInput
+
+ """The boolean value of the attribute."""
+ boolean: Boolean
}
-input MetadataInput {
- """Key of a metadata item."""
- key: String!
+input IntRangeInput {
+ """Value greater than or equal to."""
+ gte: Int
- """Value of a metadata item."""
- value: String!
+ """Value less than or equal to."""
+ lte: Int
}
-"""Represents a custom attribute."""
-type SelectedAttribute @doc(category: "Attributes") {
- """Name of an attribute displayed in the interface."""
- attribute: Attribute!
+input DateTimeRangeInput {
+ """Start date."""
+ gte: DateTime
- """Values of an attribute."""
- values: [AttributeValue!]!
+ """End date."""
+ lte: DateTime
}
-enum ReportingPeriod {
- TODAY
- THIS_MONTH
-}
+input DateRangeInput {
+ """Start date."""
+ gte: Date
-"""Represents a product image."""
-type ProductImage @doc(category: "Products") {
- """The ID of the image."""
- id: ID!
+ """End date."""
+ lte: Date
+}
- """The alt text of the image."""
- alt: String
+enum StockAvailability @doc(category: "Products") {
+ IN_STOCK
+ OUT_OF_STOCK
+}
- """
- The new relative sorting position of the item (from -inf to +inf). 1 moves the item one position forward, -1 moves the item one position backward, 0 leaves the item unchanged.
- """
- sortOrder: Int
+input ProductStockFilterInput @doc(category: "Products") {
+ warehouseIds: [ID!]
+ quantity: IntRangeInput
+}
- """The URL of the image."""
- url(
- """
- Desired longest side the image in pixels. Defaults to 4096. Images are never cropped. Pass 0 to retrieve the original size (not recommended).
- """
- size: Int
+input PriceRangeInput {
+ """Price greater than or equal to."""
+ gte: Float
- """
- The format of the image. When not provided, format of the original image will be used.
- """
- format: ThumbnailFormatEnum = ORIGINAL
- ): String!
+ """Price less than or equal to."""
+ lte: Float
}
-"""Represents a product media."""
-type ProductMedia implements Node & ObjectWithMetadata @doc(category: "Products") {
- """The unique ID of the product media."""
- id: ID!
+input ProductWhereInput @doc(category: "Products") {
+ metadata: [MetadataFilter!]
+ ids: [ID!]
- """List of private metadata items. Requires staff permissions to access."""
- privateMetadata: [MetadataItem!]!
+ """Filter by product name."""
+ name: StringFilterInput
- """
- A single key from private metadata. Requires staff permissions to access.
-
- Tip: Use GraphQL aliases to fetch multiple keys.
- """
- privateMetafield(key: String!): String
+ """Filter by product slug."""
+ slug: StringFilterInput
- """
- 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
+ """Filter by product type."""
+ productType: GlobalIDFilterInput
- """List of public metadata items. Can be accessed without permissions."""
- metadata: [MetadataItem!]!
+ """Filter by product category."""
+ category: GlobalIDFilterInput
- """
- A single key from public metadata.
-
- Tip: Use GraphQL aliases to fetch multiple keys.
- """
- metafield(key: String!): String
+ """Filter by collection."""
+ collection: GlobalIDFilterInput
- """
- Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.
- """
- metafields(keys: [String!]): Metadata
+ """Filter by availability for purchase."""
+ isAvailable: Boolean
- """The sort order of the media."""
- sortOrder: Int
+ """Filter by public visibility."""
+ isPublished: Boolean
- """The alt text of the media."""
- alt: String!
+ """Filter by visibility on the channel."""
+ isVisibleInListing: Boolean
- """The type of the media."""
- type: ProductMediaType!
+ """Filter by the publication date."""
+ publishedFrom: DateTime
- """The oEmbed data of the media."""
- oembedData: JSONString!
+ """Filter by the date of availability for purchase."""
+ availableFrom: DateTime
- """The URL of the media."""
- url(
- """
- Desired longest side the image in pixels. Defaults to 4096. Images are never cropped. Pass 0 to retrieve the original size (not recommended).
- """
- size: Int
+ """Filter by product with category assigned."""
+ hasCategory: Boolean
- """
- The format of the image. When not provided, format of the original image will be used.
- """
- format: ThumbnailFormatEnum = ORIGINAL
- ): String!
+ """Filter by product variant price."""
+ price: DecimalFilterInput
+
+ """Filter by the lowest variant price after discounts."""
+ minimalPrice: DecimalFilterInput
+
+ """Filter by attributes associated with the product."""
+ attributes: [AttributeInput!]
+
+ """Filter by variants having specific stock status."""
+ stockAvailability: StockAvailability
+
+ """Filter by stock of the product variant."""
+ stocks: ProductStockFilterInput
+
+ """Filter on whether product is a gift card or not."""
+ giftCard: Boolean
+
+ """Filter by product with preordered variants."""
+ hasPreorderedVariants: Boolean
+
+ """Filter by when was the most recent update."""
+ updatedAt: DateTimeFilterInput
- """Product id the media refers to."""
- productId: ID
-}
+ """List of conditions that must be met."""
+ AND: [ProductWhereInput!]
-enum ProductMediaType @doc(category: "Products") {
- IMAGE
- VIDEO
+ """A list of conditions of which at least one must be met."""
+ OR: [ProductWhereInput!]
}
-"""Represents product variant translations."""
-type ProductVariantTranslation implements Node @doc(category: "Products") {
- """The ID of the product variant translation."""
- id: ID!
+"""Define the filtering options for foreign key fields."""
+input GlobalIDFilterInput {
+ """The value equal to."""
+ eq: ID
- """Translation language."""
- language: LanguageDisplay!
+ """The value included in."""
+ oneOf: [ID!]
+}
- """Translated product variant name."""
- name: String!
+"""Define the filtering options for decimal fields."""
+input DecimalFilterInput {
+ """The value equal to."""
+ eq: Decimal
- """Represents the product variant fields to translate."""
- translatableContent: ProductVariantTranslatableContent
+ """The value included in."""
+ oneOf: [Decimal!]
+
+ """The value in range."""
+ range: DecimalRangeInput
}
"""
-Represents product variant's original translatable fields and related translations.
+Custom Decimal implementation.
+
+Returns Decimal as a float in the API,
+parses float to the Decimal on the way back.
"""
-type ProductVariantTranslatableContent implements Node @doc(category: "Products") {
- """The ID of the product variant translatable content."""
- id: ID!
+scalar Decimal
- """The ID of the product variant to translate."""
- productVariantId: ID!
+input DecimalRangeInput {
+ """Decimal value greater than or equal to."""
+ gte: Decimal
- """Name of the product variant to translate."""
- name: String!
+ """Decimal value less than or equal to."""
+ lte: Decimal
+}
- """Returns translated product variant fields for the given language code."""
- translation(
- """A language code to return the translation for product variant."""
- languageCode: LanguageCodeEnum!
- ): ProductVariantTranslation
+"""Define the filtering options for date time fields."""
+input DateTimeFilterInput {
+ """The value equal to."""
+ eq: DateTime
- """Represents a version of a product such as different size or color."""
- productVariant: ProductVariant @deprecated(reason: "Get model fields from the root level queries.")
+ """The value included in."""
+ oneOf: [DateTime!]
- """List of product variant attribute values that can be translated."""
- attributeValues: [AttributeValueTranslatableContent!]!
+ """The value in range."""
+ range: DateTimeRangeInput
}
-"""Represents digital content associated with a product variant."""
-type DigitalContent implements Node & ObjectWithMetadata @doc(category: "Products") {
- """The ID of the digital content."""
- id: ID!
+input ProductOrder @doc(category: "Products") {
+ """Specifies the direction in which to sort products."""
+ direction: OrderDirection!
- """List of private metadata items. Requires staff permissions to access."""
- privateMetadata: [MetadataItem!]!
+ """Specifies the channel in which to sort the data."""
+ channel: String @deprecated(reason: "Use root-level channel argument instead.")
"""
- A single key from private metadata. Requires staff permissions to access.
-
- Tip: Use GraphQL aliases to fetch multiple keys.
+ Sort product by the selected attribute's values.
+ Note: this doesn't take translations into account yet.
"""
- privateMetafield(key: String!): String
+ attributeId: ID
+
+ """Sort products by the selected field."""
+ field: ProductOrderField
+}
+
+enum ProductOrderField @doc(category: "Products") {
+ """Sort products by name."""
+ NAME
"""
- Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
+ Sort products by rank. Note: This option is available only with the `search` filter.
"""
- privateMetafields(keys: [String!]): Metadata
-
- """List of public metadata items. Can be accessed without permissions."""
- metadata: [MetadataItem!]!
+ RANK
"""
- A single key from public metadata.
+ Sort products by price.
- Tip: Use GraphQL aliases to fetch multiple keys.
+ This option requires a channel filter to work as the values can vary between channels.
"""
- metafield(key: String!): String
+ PRICE
"""
- Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.
+ Sort products by a minimal price of a product's variant.
+
+ This option requires a channel filter to work as the values can vary between channels.
"""
- metafields(keys: [String!]): Metadata
-
- """Default settings indicator for digital content."""
- useDefaultSettings: Boolean!
+ MINIMAL_PRICE
- """Indicator for automatic fulfillment of digital content."""
- automaticFulfillment: Boolean!
+ """Sort products by update date."""
+ LAST_MODIFIED @deprecated(reason: "Use `LAST_MODIFIED_AT` instead.")
- """File associated with digital content."""
- contentFile: String!
+ """Sort products by update date."""
+ DATE @deprecated(reason: "Use `LAST_MODIFIED_AT` instead.")
- """Maximum number of allowed downloads for the digital content."""
- maxDownloads: Int
+ """Sort products by type."""
+ TYPE
- """Number of days the URL for the digital content remains valid."""
- urlValidDays: Int
+ """
+ Sort products by publication status.
+
+ This option requires a channel filter to work as the values can vary between channels.
+ """
+ PUBLISHED
- """List of URLs for the digital variant."""
- urls: [DigitalContentUrl!]
+ """
+ Sort products by publication date.
+
+ This option requires a channel filter to work as the values can vary between channels.
+ """
+ PUBLICATION_DATE @deprecated(reason: "Use `PUBLISHED_AT` instead.")
- """Product variant assigned to digital content."""
- productVariant: ProductVariant!
-}
+ """
+ Sort products by publication date.
+
+ This option requires a channel filter to work as the values can vary between channels.
+ """
+ PUBLISHED_AT
-"""Represents a URL for digital content."""
-type DigitalContentUrl implements Node @doc(category: "Products") {
- """The ID of the digital content URL."""
- id: ID!
+ """Sort products by update date."""
+ LAST_MODIFIED_AT
- """Digital content associated with the URL."""
- content: DigitalContent!
+ """
+ Sort products by collection. Note: This option is available only for the `Collection.products` query.
+
+ This option requires a channel filter to work as the values can vary between channels.
+ """
+ COLLECTION
- """Date and time when the digital content URL was created."""
- created: DateTime!
+ """Sort products by rating."""
+ RATING
- """Number of times digital content has been downloaded."""
- downloadNum: Int!
+ """Sort products by creation date."""
+ CREATED_AT
+}
- """URL for digital content."""
- url: String
+"""Represents an image."""
+type Image {
+ """The URL of the image."""
+ url: String!
- """UUID of digital content."""
- token: UUID!
+ """Alt text for an image."""
+ alt: String
}
-scalar UUID
-
-"""Represents stock."""
-type Stock implements Node @doc(category: "Products") {
- """The ID of stock."""
+"""Represents category translations."""
+type CategoryTranslation implements Node @doc(category: "Products") {
+ """The ID of the category translation."""
id: ID!
- """The warehouse associated with the stock."""
- warehouse: Warehouse!
+ """Translation language."""
+ language: LanguageDisplay!
- """Information about the product variant."""
- productVariant: ProductVariant!
+ """Translated SEO title."""
+ seoTitle: String
+
+ """Translated SEO description."""
+ seoDescription: String
"""
- Quantity of a product in the warehouse's possession, including the allocated stock that is waiting for shipment.
+ Translated category slug.
- Requires one of the following permissions: MANAGE_PRODUCTS, MANAGE_ORDERS.
+ Added in Saleor 3.21.
"""
- quantity: Int!
+ slug: String
+
+ """Translated category name."""
+ name: String
"""
- Quantity allocated for orders.
+ Translated description of the category.
- Requires one of the following permissions: MANAGE_PRODUCTS, MANAGE_ORDERS.
+ Rich text format. For reference see https://editorjs.io/
"""
- quantityAllocated: Int!
+ description: JSONString
"""
- Quantity reserved for checkouts.
+ Translated description of the category.
- Requires one of the following permissions: MANAGE_PRODUCTS, MANAGE_ORDERS.
+ Rich text format. For reference see https://editorjs.io/
"""
- quantityReserved: Int!
+ descriptionJson: JSONString @deprecated(reason: "Use the `description` field instead.")
+
+ """Represents the category fields to translate."""
+ translatableContent: CategoryTranslatableContent
}
-"""Represents preorder settings for product variant."""
-type PreorderData @doc(category: "Products") {
+"""
+Represents category original translatable fields and related translations.
+"""
+type CategoryTranslatableContent implements Node @doc(category: "Products") {
+ """The ID of the category translatable content."""
+ id: ID!
+
+ """The ID of the category to translate."""
+ categoryId: ID!
+
+ """SEO title to translate."""
+ seoTitle: String
+
+ """SEO description to translate."""
+ seoDescription: String
+
+ """
+ Slug to translate.
+
+ Added in Saleor 3.21.
+ """
+ slug: String
+
+ """Name of the category translatable content."""
+ name: String!
+
"""
- The global preorder threshold for product variant.
+ Category description to translate.
- Requires one of the following permissions: MANAGE_PRODUCTS.
+ Rich text format. For reference see https://editorjs.io/
"""
- globalThreshold: Int
+ description: JSONString
"""
- Total number of sold product variant during preorder.
+ Description of the category.
- Requires one of the following permissions: MANAGE_PRODUCTS.
+ Rich text format. For reference see https://editorjs.io/
"""
- globalSoldUnits: Int!
+ descriptionJson: JSONString @deprecated(reason: "Use the `description` field instead.")
- """Preorder end date."""
- endDate: DateTime
+ """Returns translated category fields for the given language code."""
+ translation(
+ """A language code to return the translation for category."""
+ languageCode: LanguageCodeEnum!
+ ): CategoryTranslation
+
+ """Represents a single category of products."""
+ category: Category @deprecated(reason: "Get model fields from the root level queries.")
}
"""Represents availability of a product in the storefront."""
@@ -8168,248 +8452,22 @@ type CollectionTranslatableContent implements Node @doc(category: "Products") {
"""Represents collection channel listing."""
type CollectionChannelListing implements Node @doc(category: "Products") {
"""The ID of the collection channel listing."""
- id: ID!
- publicationDate: Date @deprecated(reason: "Use the `publishedAt` field to fetch the publication date.")
-
- """The collection publication date."""
- publishedAt: DateTime
-
- """Indicates if the collection is published in the channel."""
- isPublished: Boolean!
-
- """The channel to which the collection belongs."""
- channel: Channel!
-}
-
-"""Represents product translations."""
-type ProductTranslation implements Node @doc(category: "Products") {
- """The ID of the product translation."""
- id: ID!
-
- """Translation language."""
- language: LanguageDisplay!
-
- """Translated SEO title."""
- seoTitle: String
-
- """Translated SEO description."""
- seoDescription: String
-
- """
- Translated product slug.
-
- Added in Saleor 3.21.
- """
- slug: String
-
- """Translated product name."""
- name: String
-
- """
- Translated description of the product.
-
- Rich text format. For reference see https://editorjs.io/
- """
- description: JSONString
-
- """
- Translated description of the product.
-
- Rich text format. For reference see https://editorjs.io/
- """
- descriptionJson: JSONString @deprecated(reason: "Use the `description` field instead.")
-
- """Represents the product fields to translate."""
- translatableContent: ProductTranslatableContent
-}
-
-"""
-Represents product's original translatable fields and related translations.
-"""
-type ProductTranslatableContent implements Node @doc(category: "Products") {
- """The ID of the product translatable content."""
- id: ID!
-
- """The ID of the product to translate."""
- productId: ID!
-
- """SEO title to translate."""
- seoTitle: String
-
- """SEO description to translate."""
- seoDescription: String
-
- """
- Slug to translate.
-
- Added in Saleor 3.21.
- """
- slug: String
-
- """Product's name to translate."""
- name: String!
-
- """
- Product's description to translate.
-
- Rich text format. For reference see https://editorjs.io/
- """
- description: JSONString
-
- """
- Description of the product.
-
- Rich text format. For reference see https://editorjs.io/
- """
- descriptionJson: JSONString @deprecated(reason: "Use the `description` field instead.")
-
- """Returns translated product fields for the given language code."""
- translation(
- """A language code to return the translation for product."""
- languageCode: LanguageCodeEnum!
- ): ProductTranslation
-
- """Represents an individual item for sale in the storefront."""
- product: Product @deprecated(reason: "Get model fields from the root level queries.")
-
- """List of product attribute values that can be translated."""
- attributeValues: [AttributeValueTranslatableContent!]!
-}
-
-type StockCountableConnection @doc(category: "Products") {
- """Pagination data for this connection."""
- pageInfo: PageInfo!
- edges: [StockCountableEdge!]!
-
- """A total count of items in the collection."""
- totalCount: Int
-}
-
-type StockCountableEdge @doc(category: "Products") {
- """The item at the end of the edge."""
- node: Stock!
-
- """A cursor for use in pagination."""
- cursor: String!
-}
-
-type WarehouseCountableConnection @doc(category: "Products") {
- """Pagination data for this connection."""
- pageInfo: PageInfo!
- edges: [WarehouseCountableEdge!]!
-
- """A total count of items in the collection."""
- totalCount: Int
-}
-
-type WarehouseCountableEdge @doc(category: "Products") {
- """The item at the end of the edge."""
- node: Warehouse!
-
- """A cursor for use in pagination."""
- cursor: String!
-}
-
-input WarehouseFilterInput @doc(category: "Products") {
- clickAndCollectOption: WarehouseClickAndCollectOptionEnum
- metadata: [MetadataFilter!]
- search: String
- ids: [ID!]
- isPrivate: Boolean
- channels: [ID!]
- slugs: [String!]
-}
-
-input WarehouseSortingInput @doc(category: "Products") {
- """Specifies the direction in which to sort warehouses."""
- direction: OrderDirection!
-
- """Sort warehouses by the selected field."""
- field: WarehouseSortField!
-}
-
-enum WarehouseSortField @doc(category: "Products") {
- """Sort warehouses by name."""
- NAME
-}
-
-type TranslatableItemConnection {
- """Pagination data for this connection."""
- pageInfo: PageInfo!
- edges: [TranslatableItemEdge!]!
-
- """A total count of items in the collection."""
- totalCount: Int
-}
-
-type TranslatableItemEdge {
- """The item at the end of the edge."""
- node: TranslatableItem!
-
- """A cursor for use in pagination."""
- cursor: String!
-}
-
-union TranslatableItem = ProductTranslatableContent | CollectionTranslatableContent | CategoryTranslatableContent | AttributeTranslatableContent | AttributeValueTranslatableContent | ProductVariantTranslatableContent | PageTranslatableContent | ShippingMethodTranslatableContent | VoucherTranslatableContent | MenuItemTranslatableContent | PromotionTranslatableContent | PromotionRuleTranslatableContent | SaleTranslatableContent
-
-"""
-Represents page's original translatable fields and related translations.
-"""
-type PageTranslatableContent implements Node @doc(category: "Pages") {
- """The ID of the page translatable content."""
- id: ID!
-
- """The ID of the page to translate."""
- pageId: ID!
-
- """SEO title to translate."""
- seoTitle: String
-
- """SEO description to translate."""
- seoDescription: String
-
- """
- Slug to translate.
-
- Added in Saleor 3.21.
- """
- slug: String
-
- """Page title to translate."""
- title: String!
-
- """
- Content of the page to translate.
-
- Rich text format. For reference see https://editorjs.io/
- """
- content: JSONString
-
- """
- Content of the page.
-
- Rich text format. For reference see https://editorjs.io/
- """
- contentJson: JSONString @deprecated(reason: "Use the `content` field instead.")
-
- """Returns translated page fields for the given language code."""
- translation(
- """A language code to return the translation for page."""
- languageCode: LanguageCodeEnum!
- ): PageTranslation
+ id: ID!
+ publicationDate: Date @deprecated(reason: "Use the `publishedAt` field to fetch the publication date.")
- """
- A static page that can be manually added by a shop operator through the dashboard.
- """
- page: Page @deprecated(reason: "Get model fields from the root level queries.")
+ """The collection publication date."""
+ publishedAt: DateTime
- """List of page content attribute values that can be translated."""
- attributeValues: [AttributeValueTranslatableContent!]!
+ """Indicates if the collection is published in the channel."""
+ isPublished: Boolean!
+
+ """The channel to which the collection belongs."""
+ channel: Channel!
}
-"""Represents page translations."""
-type PageTranslation implements Node @doc(category: "Pages") {
- """The ID of the page translation."""
+"""Represents product translations."""
+type ProductTranslation implements Node @doc(category: "Products") {
+ """The ID of the product translation."""
id: ID!
"""Translation language."""
@@ -8422,211 +8480,162 @@ type PageTranslation implements Node @doc(category: "Pages") {
seoDescription: String
"""
- Translated page slug.
+ Translated product slug.
Added in Saleor 3.21.
"""
slug: String
- """Translated page title."""
- title: String
+ """Translated product name."""
+ name: String
"""
- Translated content of the page.
+ Translated description of the product.
Rich text format. For reference see https://editorjs.io/
"""
- content: JSONString
+ description: JSONString
"""
- Translated description of the page.
+ Translated description of the product.
Rich text format. For reference see https://editorjs.io/
"""
- contentJson: JSONString @deprecated(reason: "Use the `content` field instead.")
+ descriptionJson: JSONString @deprecated(reason: "Use the `description` field instead.")
- """Represents the page fields to translate."""
- translatableContent: PageTranslatableContent
+ """Represents the product fields to translate."""
+ translatableContent: ProductTranslatableContent
}
"""
-A static page that can be manually added by a shop operator through the dashboard.
+Represents product's original translatable fields and related translations.
"""
-type Page implements Node & ObjectWithMetadata @doc(category: "Pages") {
- """ID of the page."""
+type ProductTranslatableContent implements Node @doc(category: "Products") {
+ """The ID of the product translatable content."""
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
+ """The ID of the product to translate."""
+ productId: ID!
- """
- 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
+ """SEO title to translate."""
+ seoTitle: String
- """List of public metadata items. Can be accessed without permissions."""
- metadata: [MetadataItem!]!
+ """SEO description to translate."""
+ seoDescription: String
"""
- A single key from public metadata.
+ Slug to translate.
- 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.21.
"""
- metafields(keys: [String!]): Metadata
-
- """Title of the page for SEO."""
- seoTitle: String
-
- """Description of the page for SEO."""
- seoDescription: String
+ slug: String
- """Title of the page."""
- title: String!
+ """Product's name to translate."""
+ name: String!
"""
- Content of the page.
+ Product's description to translate.
Rich text format. For reference see https://editorjs.io/
"""
- content: JSONString
- publicationDate: Date @deprecated(reason: "Use the `publishedAt` field to fetch the publication date.")
-
- """The page publication date."""
- publishedAt: DateTime
-
- """Determines if the page is published."""
- isPublished: Boolean!
-
- """Slug of the page."""
- slug: String!
-
- """Determines the type of page"""
- pageType: PageType!
-
- """Date and time at which page was created."""
- created: DateTime!
+ description: JSONString
"""
- Content of the page.
+ Description of the product.
Rich text format. For reference see https://editorjs.io/
"""
- contentJson: JSONString! @deprecated(reason: "Use the `content` field instead.")
+ descriptionJson: JSONString @deprecated(reason: "Use the `description` field instead.")
- """Returns translated page fields for the given language code."""
+ """Returns translated product fields for the given language code."""
translation(
- """A language code to return the translation for page."""
+ """A language code to return the translation for product."""
languageCode: LanguageCodeEnum!
- ): PageTranslation
+ ): ProductTranslation
- """Get a single attribute attached to page by attribute slug."""
- attribute(
- """Slug of the attribute"""
- slug: String!
- ): SelectedAttribute
+ """Represents an individual item for sale in the storefront."""
+ product: Product @deprecated(reason: "Get model fields from the root level queries.")
- """List of attributes assigned to this page."""
- attributes: [SelectedAttribute!]!
+ """List of product attribute values that can be translated."""
+ attributeValues: [AttributeValueTranslatableContent!]!
}
-"""
-Represents a type of page. It defines what attributes are available to pages of this type.
-"""
-type PageType implements Node & ObjectWithMetadata @doc(category: "Pages") {
- """ID of the page 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
+type StockCountableConnection @doc(category: "Products") {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [StockCountableEdge!]!
- """
- 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
+ """A total count of items in the collection."""
+ totalCount: Int
+}
- """List of public metadata items. Can be accessed without permissions."""
- metadata: [MetadataItem!]!
+type StockCountableEdge @doc(category: "Products") {
+ """The item at the end of the edge."""
+ node: Stock!
- """
- A single key from public metadata.
-
- Tip: Use GraphQL aliases to fetch multiple keys.
- """
- metafield(key: String!): String
+ """A cursor for use in pagination."""
+ cursor: String!
+}
- """
- Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.
- """
- metafields(keys: [String!]): Metadata
+type WarehouseCountableConnection @doc(category: "Products") {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [WarehouseCountableEdge!]!
- """Name of the page type."""
- name: String!
+ """A total count of items in the collection."""
+ totalCount: Int
+}
- """Slug of the page type."""
- slug: String!
+type WarehouseCountableEdge @doc(category: "Products") {
+ """The item at the end of the edge."""
+ node: Warehouse!
- """Page attributes of that page type."""
- attributes: [Attribute!]
+ """A cursor for use in pagination."""
+ cursor: String!
+}
- """
- Attributes that can be assigned to the page type.
-
- Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES.
- """
- availableAttributes(
- """Filtering options for attributes."""
- filter: AttributeFilterInput @deprecated(reason: "Use `where` filter instead.")
+input WarehouseFilterInput @doc(category: "Products") {
+ clickAndCollectOption: WarehouseClickAndCollectOptionEnum
+ metadata: [MetadataFilter!]
+ search: String
+ ids: [ID!]
+ isPrivate: Boolean
+ channels: [ID!]
+ slugs: [String!]
+}
- """Where filtering options for attributes."""
- where: AttributeWhereInput
+input WarehouseSortingInput @doc(category: "Products") {
+ """Specifies the direction in which to sort warehouses."""
+ direction: OrderDirection!
- """Search attributes."""
- search: String
+ """Sort warehouses by the selected field."""
+ field: WarehouseSortField!
+}
- """Return the elements in the list that come before the specified cursor."""
- before: String
+enum WarehouseSortField @doc(category: "Products") {
+ """Sort warehouses by name."""
+ NAME
+}
- """Return the elements in the list that come after the specified cursor."""
- after: String
+type TranslatableItemConnection {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [TranslatableItemEdge!]!
- """
- 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
+ """A total count of items in the collection."""
+ totalCount: 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
+type TranslatableItemEdge {
+ """The item at the end of the edge."""
+ node: TranslatableItem!
- """
- Whether page type has pages assigned.
-
- Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES.
- """
- hasPages: Boolean
+ """A cursor for use in pagination."""
+ cursor: String!
}
+union TranslatableItem = ProductTranslatableContent | CollectionTranslatableContent | CategoryTranslatableContent | AttributeTranslatableContent | AttributeValueTranslatableContent | ProductVariantTranslatableContent | PageTranslatableContent | ShippingMethodTranslatableContent | VoucherTranslatableContent | MenuItemTranslatableContent | PromotionTranslatableContent | PromotionRuleTranslatableContent | SaleTranslatableContent
+
"""
Represents voucher's original translatable fields and related translations.
"""