Skip to content

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

Display only shippable countries for a channel (#10111)

Maciej Korycinski2ad76cc1ecb5
diff --git a/saleor/graphql/channel/resolvers.py b/saleor/graphql/channel/resolvers.py
index 7d8754fb92..8abdd4eaa9 100644
--- a/saleor/graphql/channel/resolvers.py
+++ b/saleor/graphql/channel/resolvers.py
@@ -1,8 +1,26 @@
+from typing import Optional
+
from ...channel import models
+from ...core.permissions import is_app, is_staff_user
+from ..core.utils import from_global_id_or_error
+from ..core.validators import validate_one_of_args_is_in_query
+from .types import Channel
+
+
+def resolve_channel(info, id: Optional[str], slug: Optional[str]):
+ validate_one_of_args_is_in_query("id", id, "slug", slug)
+ if id:
+ _, db_id = from_global_id_or_error(id, Channel)
+ channel = models.Channel.objects.filter(id=db_id).first()
+ else:
+ channel = models.Channel.objects.filter(slug=slug).first()
+ if channel and channel.is_active:
+ return channel
+ if is_staff_user(info.context) or is_app(info.context):
+ return channel
-def resolve_channel(id):
- return models.Channel.objects.filter(id=id).first()
+ return None
def resolve_channels():
diff --git a/saleor/graphql/channel/schema.py b/saleor/graphql/channel/schema.py
index d96adb77d3..7c73db3f46 100644
--- a/saleor/graphql/channel/schema.py
+++ b/saleor/graphql/channel/schema.py
@@ -1,9 +1,9 @@
import graphene
from ...core.permissions import AuthorizationFilters
+from ..core.descriptions import ADDED_IN_36, PREVIEW_FEATURE
from ..core.fields import PermissionsField
from ..core.types import NonNullList
-from ..core.utils import from_global_id_or_error
from .mutations import (
ChannelActivate,
ChannelCreate,
@@ -16,14 +16,17 @@ from .types import Channel
class ChannelQueries(graphene.ObjectType):
- channel = PermissionsField(
+ channel = graphene.Field(
Channel,
- id=graphene.Argument(graphene.ID, description="ID of the channel."),
- description="Look up a channel by ID.",
- permissions=[
- AuthorizationFilters.AUTHENTICATED_APP,
- AuthorizationFilters.AUTHENTICATED_STAFF_USER,
- ],
+ id=graphene.Argument(
+ graphene.ID, description="ID of the channel.", required=False
+ ),
+ slug=graphene.Argument(
+ graphene.String,
+ description="Slug of the channel." + ADDED_IN_36 + PREVIEW_FEATURE,
+ required=False,
+ ),
+ description="Look up a channel by ID or slug.",
)
channels = PermissionsField(
NonNullList(Channel),
@@ -35,9 +38,8 @@ class ChannelQueries(graphene.ObjectType):
)
@staticmethod
- def resolve_channel(_root, _info, *, id=None, **kwargs):
- _, id = from_global_id_or_error(id, Channel)
- return resolve_channel(id)
+ def resolve_channel(_root, info, *, id=None, slug=None, **kwargs):
+ return resolve_channel(info, id, slug)
@staticmethod
def resolve_channels(_root, _info, **kwargs):
diff --git a/saleor/graphql/channel/tests/test_channel_queries.py b/saleor/graphql/channel/tests/test_channel_queries.py
index 38db61eb75..29455d1186 100644
--- a/saleor/graphql/channel/tests/test_channel_queries.py
+++ b/saleor/graphql/channel/tests/test_channel_queries.py
@@ -1,5 +1,7 @@
import graphene
+from prices import Money
+from ....shipping.models import ShippingMethodChannelListing, ShippingZone
from ...tests.utils import (
assert_no_permission,
get_graphql_content,
@@ -156,7 +158,7 @@ def test_query_channels_with_has_orders_without_permission(
QUERY_CHANNEL = """
- query getChannel($id: ID!){
+ query getChannel($id: ID){
channel(id: $id){
id
name
@@ -240,3 +242,169 @@ def test_query_channel_with_invalid_object_type(staff_api_client, channel_USD):
response = staff_api_client.post_graphql(QUERY_CHANNEL, variables)
content = get_graphql_content(response)
assert content["data"]["channel"] is None
+
+
+PUBLIC_QUERY_CHANNEL = """
+ query getChannel(
+ $slug: String,
+ $countries: [CountryCode!]
+ ){
+ channel(slug: $slug){
+ id
+ slug
+ countries{
+ code
+ country
+ }
+ availableShippingMethodsPerCountry(countries: $countries){
+ countryCode
+ shippingMethods {
+ id
+ name
+ price {
+ amount
+ }
+ name
+ maximumDeliveryDays
+ minimumDeliveryDays
+ minimumOrderPrice {
+ amount
+ }
+ maximumOrderPrice {
+ amount
+ }
+ }
+ }
+ }
+ }
+"""
+
+
+def test_query_channel_return_public_data_as_anonymous(api_client, channel_USD):
+ # given
+ variables = {"slug": channel_USD.slug}
+
+ # when
+ response = api_client.post_graphql(PUBLIC_QUERY_CHANNEL, variables)
+
+ # then
+ content = get_graphql_content(response)
+ assert content["data"]["channel"]
+
+
+def test_query_channel_missing_id_and_slug_in_query(api_client, channel_USD):
+ # given
+ query = """{
+ channel{
+ id
+ }
+ }
+ """
+
+ # when
+ response = api_client.post_graphql(query)
+
+ # then
+ content = get_graphql_content_from_response(response)
+ assert len(content["errors"]) == 1
+ assert content["data"]["channel"] is None
+
+
+def test_query_channel_returns_countries_attached_to_shipping_zone(
+ api_client, channel_USD, channel_PLN, shipping_zone
+):
+ # given
+ variables = {"slug": channel_PLN.slug}
+ shipping_zone = ShippingZone.objects.create(
+ name="Europe", countries=["PL", "DE", "FR"]
+ )
+ shipping_zone.channels.add(channel_PLN)
+
+ # when
+ response = api_client.post_graphql(PUBLIC_QUERY_CHANNEL, variables)
+
+ # then
+ content = get_graphql_content(response)
+ channel_data = content["data"]["channel"]
+ assert set([country["code"] for country in channel_data["countries"]]) == set(
+ ["PL", "DE", "FR"]
+ )
+ assert set([country["country"] for country in channel_data["countries"]]) == set(
+ ["Poland", "Germany", "France"]
+ )
+
+
+def test_query_channel_returns_supported_shipping_methods(
+ api_client, channel_USD, channel_PLN, shipping_zone, shipping_method
+):
+ # given
+ variables = {"slug": channel_PLN.slug}
+ shipping_zone = ShippingZone.objects.create(
+ name="Europe", countries=["PL", "DE", "FR"]
+ )
+ shipping_zone.channels.add(channel_PLN)
+ shipping_method.shipping_zone = shipping_zone
+ shipping_method.save()
+
+ ShippingMethodChannelListing.objects.create(
+ shipping_method=shipping_method,
+ channel=channel_PLN,
+ minimum_order_price=Money(0, "USD"),
+ price=Money(10, "USD"),
+ )
+
+ # when
+ response = api_client.post_graphql(PUBLIC_QUERY_CHANNEL, variables)
+
+ # then
+ content = get_graphql_content(response)
+ channel_data = content["data"]["channel"]
+
+ assert len(channel_data["availableShippingMethodsPerCountry"]) == 3
+ sm_per_country = channel_data["availableShippingMethodsPerCountry"]
+ response_country_codes = [item["countryCode"] for item in sm_per_country]
+ assert {"PL", "DE", "FR"} == set(response_country_codes)
+ expected_shipping_method_id = graphene.Node.to_global_id(
+ "ShippingMethod", shipping_method.id
+ )
+
+ # each country uses the same shipping method
+ assert expected_shipping_method_id == sm_per_country[0]["shippingMethods"][0]["id"]
+ assert expected_shipping_method_id == sm_per_country[1]["shippingMethods"][0]["id"]
+ assert expected_shipping_method_id == sm_per_country[2]["shippingMethods"][0]["id"]
+
+
+def test_query_channel_returns_supported_shipping_methods_with_countries_input(
+ api_client, channel_USD, channel_PLN, shipping_zone, shipping_method
+):
+ # given
+ variables = {"slug": channel_PLN.slug, "countries": ["PL"]}
+ shipping_zone = ShippingZone.objects.create(
+ name="Europe", countries=["PL", "DE", "FR"]
+ )
+ shipping_zone.channels.add(channel_PLN)
+ shipping_method.shipping_zone = shipping_zone
+ shipping_method.save()
+
+ ShippingMethodChannelListing.objects.create(
+ shipping_method=shipping_method,
+ channel=channel_PLN,
+ minimum_order_price=Money(0, "USD"),
+ price=Money(10, "USD"),
+ )
+
+ # when
+ response = api_client.post_graphql(PUBLIC_QUERY_CHANNEL, variables)
+
+ # then
+ content = get_graphql_content(response)
+ channel_data = content["data"]["channel"]
+ sm_per_country = channel_data["availableShippingMethodsPerCountry"]
+
+ expected_shipping_method_id = graphene.Node.to_global_id(
+ "ShippingMethod", shipping_method.id
+ )
+ assert len(sm_per_country) == 1
+ assert sm_per_country[0]["countryCode"] == "PL"
+ assert len(sm_per_country[0]["shippingMethods"]) == 1
+ assert sm_per_country[0]["shippingMethods"][0]["id"] == expected_shipping_method_id
diff --git a/saleor/graphql/channel/types.py b/saleor/graphql/channel/types.py
index 96f95de0f3..7ba131c5a2 100644
--- a/saleor/graphql/channel/types.py
+++ b/saleor/graphql/channel/types.py
@@ -1,12 +1,16 @@
-from typing import Type, Union, cast
+import collections
+import itertools
+from typing import Dict, List, Type, Union, cast
import graphene
from django.db.models import Model
from graphene.types.resolver import get_default_resolver
+from promise import Promise
from ...channel import models
-from ...core.permissions import ChannelPermissions
-from ..core.descriptions import ADDED_IN_31, ADDED_IN_35, PREVIEW_FEATURE
+from ...core.permissions import AuthorizationFilters, ChannelPermissions
+from ..account.enums import CountryCodeEnum
+from ..core.descriptions import ADDED_IN_31, ADDED_IN_35, ADDED_IN_36, PREVIEW_FEATURE
from ..core.fields import PermissionsField
from ..core.types import CountryDisplay, ModelObjectType, NonNullList
from ..meta.types import ObjectWithMetadata
@@ -119,11 +123,38 @@ class ChannelContextTypeWithMetadata(
class Channel(ModelObjectType):
id = graphene.GlobalID(required=True)
- name = graphene.String(required=True)
- is_active = graphene.Boolean(required=True)
- slug = graphene.String(required=True)
- currency_code = graphene.String(required=True)
- slug = graphene.String(required=True)
+ slug = graphene.String(
+ required=True,
+ description="Slug of the channel.",
+ )
+
+ name = PermissionsField(
+ graphene.String,
+ description="Name of the channel.",
+ required=True,
+ permissions=[
+ AuthorizationFilters.AUTHENTICATED_APP,
+ AuthorizationFilters.AUTHENTICATED_STAFF_USER,
+ ],
+ )
+ is_active = PermissionsField(
+ graphene.Boolean,
+ description="Whether the channel is active.",
+ required=True,
+ permissions=[
+ AuthorizationFilters.AUTHENTICATED_APP,
+ AuthorizationFilters.AUTHENTICATED_STAFF_USER,
+ ],
+ )
+ currency_code = PermissionsField(
+ graphene.String,
+ description="A currency that is assigned to the channel.",
+ required=True,
+ permissions=[
+ AuthorizationFilters.AUTHENTICATED_APP,
+ AuthorizationFilters.AUTHENTICATED_STAFF_USER,
+ ],
+ )
has_orders = PermissionsField(
graphene.Boolean,
description="Whether a channel has associated orders.",
@@ -132,7 +163,7 @@ class Channel(ModelObjectType):
],
required=True,
)
- default_country = graphene.Field(
+ default_country = PermissionsField(
CountryDisplay,
description=(
"Default country for the channel. Default country can be "
@@ -140,13 +171,35 @@ class Channel(ModelObjectType):
"when the country was not explicitly provided." + ADDED_IN_31
),
required=True,
+ permissions=[
+ AuthorizationFilters.AUTHENTICATED_APP,
+ AuthorizationFilters.AUTHENTICATED_STAFF_USER,
+ ],
)
- warehouses = NonNullList(
- Warehouse,
+ warehouses = PermissionsField(
+ NonNullList(Warehouse),
description="List of warehouses assigned to this channel."
+ ADDED_IN_35
+ PREVIEW_FEATURE,
required=True,
+ permissions=[
+ AuthorizationFilters.AUTHENTICATED_APP,
+ AuthorizationFilters.AUTHENTICATED_STAFF_USER,
+ ],
+ )
+ countries = NonNullList(
+ CountryDisplay,
+ description="List of shippable countries for the channel."
+ + ADDED_IN_36
+ + PREVIEW_FEATURE,
+ )
+
+ available_shipping_methods_per_country = graphene.Field(
+ NonNullList("saleor.graphql.shipping.types.ShippingMethodsPerCountry"),
+ countries=graphene.Argument(NonNullList(CountryCodeEnum)),
+ description="Shipping methods that are available for the channel."
+ + ADDED_IN_36
+ + PREVIEW_FEATURE,
)
class Meta:
@@ -171,3 +224,106 @@ class Channel(ModelObjectType):
@staticmethod
def resolve_warehouses(root: models.Channel, info):
return WarehousesByChannelIdLoader(info.context).load(root.id)
+
+ @staticmethod
+ def resolve_countries(root: models.Channel, info):
+ from ..shipping.dataloaders import ShippingZonesByChannelIdLoader
+
+ def get_countries(shipping_zones):
+ countries = []
+ for s_zone in shipping_zones:
+ countries.extend(s_zone.countries)
+ sorted_countries = list(set(countries))
+ sorted_countries.sort(key=lambda country: country.name)
+ return [
+ CountryDisplay(code=country.code, country=country.name)
+ for country in sorted_countries
+ ]
+
+ return (
+ ShippingZonesByChannelIdLoader(info.context)
+ .load(root.id)
+ .then(get_countries)
+ )
+
+ @staticmethod
+ def resolve_available_shipping_methods_per_country(
+ root: models.Channel, info, **data
+ ):
+ from ...shipping.utils import convert_to_shipping_method_data
+ from ..shipping.dataloaders import (
+ ShippingMethodChannelListingByChannelSlugLoader,
+ ShippingMethodsByShippingZoneIdLoader,
+ ShippingZonesByChannelIdLoader,
+ )
+
+ shipping_zones_loader = ShippingZonesByChannelIdLoader(info.context).load(
+ root.id
+ )
+ shipping_zone_countries: Dict[int, List[str]] = collections.defaultdict(list)
+ requested_countries = data.get("countries", [])
+
+ def _group_shipping_methods_by_country(data):
+ shipping_methods, shipping_channel_listings = data
+ shipping_listing_map = {
+ listing.shipping_method_id: listing
+ for listing in shipping_channel_listings
+ }
+
+ shipping_methods_per_country = collections.defaultdict(list)
+ for shipping_method in shipping_methods:
+ countries = shipping_zone_countries.get(
+ shipping_method.shipping_zone_id, []
+ )
+ for country in countries:
+ shipping_method_dataclass = convert_to_shipping_method_data(
+ shipping_method, shipping_listing_map.get(shipping_method.id)
+ )
+ if not shipping_method_dataclass:
+ continue
+ shipping_methods_per_country[country.code].append(
+ shipping_method_dataclass
+ )
+
+ if requested_countries:
+ results = [
+ {
+ "country_code": code,
+ "shipping_methods": shipping_methods_per_country.get(code, []),
+ }
+ for code in requested_countries
+ if code in shipping_methods_per_country
+ ]
+ else:
+ results = [
+ {
+ "country_code": code,
+ "shipping_methods": shipping_methods_per_country[code],
+ }
+ for code in shipping_methods_per_country.keys()
+ ]
+ results.sort(key=lambda item: item["country_code"])
+
+ return results
+
+ def filter_shipping_methods(shipping_methods):
+ shipping_methods = list(itertools.chain.from_iterable(shipping_methods))
+ shipping_listings = ShippingMethodChannelListingByChannelSlugLoader(
+ info.context
+ ).load(root.slug)
+ return Promise.all([shipping_methods, shipping_listings]).then(
+ _group_shipping_methods_by_country
+ )
+
+ def get_shipping_methods(shipping_zones):
+ shipping_zones_keys = [shipping_zone.id for shipping_zone in shipping_zones]
+ for shipping_zone in shipping_zones:
+ shipping_zone_countries[shipping_zone.id] = shipping_zone.countries
+
+ return (
+ ShippingMethodsByShippingZoneIdLoader(info.context)
+ .load_many(shipping_zones_keys)
+ .then(filter_shipping_methods)
+ )
+
+ return shipping_zones_loader.then(get_shipping_methods)
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 4fbae15e79..816ed11424 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -1015,14 +1015,19 @@ type Query {
last: Int
): CheckoutLineCountableConnection
- """
- Look up a channel by ID.
-
- Requires one of the following permissions: AUTHENTICATED_APP, AUTHENTICATED_STAFF_USER.
- """
+ """Look up a channel by ID or slug."""
channel(
"""ID of the channel."""
id: ID
+
+ """
+ Slug of the channel.
+
+ Added in Saleor 3.6.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ slug: String
): Channel
"""
@@ -3787,408 +3792,355 @@ type ShippingMethodChannelListing implements Node {
"""Represents channel."""
type Channel implements Node {
id: ID!
- name: String!
- isActive: Boolean!
- currencyCode: String!
+
+ """Slug of the channel."""
slug: String!
"""
- Whether a channel has associated orders.
+ Name of the channel.
- Requires one of the following permissions: MANAGE_CHANNELS.
+ Requires one of the following permissions: AUTHENTICATED_APP, AUTHENTICATED_STAFF_USER.
"""
- hasOrders: Boolean!
+ name: String!
"""
- Default country for the channel. Default country can be used in checkout to determine the stock quantities or calculate taxes when the country was not explicitly provided.
+ Whether the channel is active.
- Added in Saleor 3.1.
+ Requires one of the following permissions: AUTHENTICATED_APP, AUTHENTICATED_STAFF_USER.
"""
- defaultCountry: CountryDisplay!
+ isActive: Boolean!
"""
- List of warehouses assigned to this channel.
+ A currency that is assigned to the channel.
- Added in Saleor 3.5.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ Requires one of the following permissions: AUTHENTICATED_APP, AUTHENTICATED_STAFF_USER.
"""
- warehouses: [Warehouse!]!
-}
-
-"""Represents shipping method postal code rule."""
-type ShippingMethodPostalCodeRule implements Node {
- """The ID of the object."""
- id: ID!
-
- """Start address range."""
- start: String
-
- """End address range."""
- end: String
-
- """Inclusion type of the postal code rule."""
- inclusionType: PostalCodeRuleInclusionTypeEnum
-}
-
-"""An enumeration."""
-enum PostalCodeRuleInclusionTypeEnum {
- INCLUDE
- EXCLUDE
-}
-
-type ProductCountableConnection {
- """Pagination data for this connection."""
- pageInfo: PageInfo!
- edges: [ProductCountableEdge!]!
-
- """A total count of items in the collection."""
- totalCount: Int
-}
-
-type ProductCountableEdge {
- """The item at the end of the edge."""
- node: Product!
-
- """A cursor for use in pagination."""
- cursor: String!
-}
-
-"""Represents an individual item for sale in the storefront."""
-type Product implements Node & ObjectWithMetadata {
- id: ID!
-
- """List of private metadata items. Requires staff permissions to access."""
- privateMetadata: [MetadataItem!]!
+ currencyCode: String!
"""
- A single key from private metadata. Requires staff permissions to access.
-
- Tip: Use GraphQL aliases to fetch multiple keys.
-
- Added in Saleor 3.3.
+ Whether a channel has associated orders.
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ Requires one of the following permissions: MANAGE_CHANNELS.
"""
- privateMetafield(key: String!): String
+ hasOrders: Boolean!
"""
- Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
+ Default country for the channel. Default country can be used in checkout to determine the stock quantities or calculate taxes when the country was not explicitly provided.
- Added in Saleor 3.3.
+ Added in Saleor 3.1.
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ Requires one of the following permissions: AUTHENTICATED_APP, AUTHENTICATED_STAFF_USER.
"""
- privateMetafields(keys: [String!]): Metadata
-
- """List of public metadata items. Can be accessed without permissions."""
- metadata: [MetadataItem!]!
+ defaultCountry: CountryDisplay!
"""
- A single key from public metadata.
-
- Tip: Use GraphQL aliases to fetch multiple keys.
+ List of warehouses assigned to this channel.
- Added in Saleor 3.3.
+ Added in Saleor 3.5.
Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+ Requires one of the following permissions: AUTHENTICATED_APP, AUTHENTICATED_STAFF_USER.
"""
- metafield(key: String!): String
+ warehouses: [Warehouse!]!
"""
- Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.
+ List of shippable countries for the channel.
- Added in Saleor 3.3.
+ Added in Saleor 3.6.
Note: this API is currently in Feature Preview and can be subject to changes at later point.
"""
- metafields(keys: [String!]): Metadata
- seoTitle: String
- seoDescription: String
- name: String!
-
- """
- Description of the product.
-
- Rich text format. For reference see https://editorjs.io/
- """
- description: JSONString
- productType: ProductType!
- slug: String!
- category: Category
- created: DateTime!
- updatedAt: DateTime!
- chargeTaxes: Boolean!
- weight: Weight
- defaultVariant: ProductVariant
- rating: Float
-
- """
- Channel given to retrieve this product. Also used by federation gateway to resolve this object in a federated query.
- """
- channel: String
+ countries: [CountryDisplay!]
"""
- Description of the product.
+ Shipping methods that are available for the channel.
- Rich text format. For reference see https://editorjs.io/
- """
- descriptionJson: JSONString @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `description` field instead.")
- thumbnail(
- """
- Size of the image. If not provided, the original image will be returned.
- """
- size: Int
-
- """
- The format of the image. When not provided, format of the original image will be used. Must be provided together with the size value, otherwise original image will be returned.
-
- Added in Saleor 3.6.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
- """
- format: ThumbnailFormatEnum
- ): Image
-
- """
- Lists the storefront product's pricing, the current price and discounts, only meant for displaying.
- """
- 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
- ): ProductPricingInfo
-
- """Whether the product is in stock and visible or not."""
- isAvailable(
- """
- 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
- ): Boolean
-
- """A type of tax. Assigned by enabled tax gateway"""
- taxType: TaxType
-
- """List of attributes assigned to this product."""
- attributes: [SelectedAttribute!]!
-
- """
- List of availability in channels for the product.
+ Added in Saleor 3.6.
- Requires one of the following permissions: MANAGE_PRODUCTS.
- """
- channelListings: [ProductChannelListing!]
-
- """Get a single product media by ID."""
- mediaById(
- """ID of a product media."""
- id: ID
- ): ProductMedia
-
- """Get a single product image by ID."""
- imageById(
- """ID of a product image."""
- id: ID
- ): ProductImage @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `mediaById` field instead.")
-
- """
- List of variants for the product. Requires the following permissions to include the unpublished items: MANAGE_ORDERS, MANAGE_DISCOUNTS, MANAGE_PRODUCTS.
- """
- variants: [ProductVariant!]
-
- """List of media for the product."""
- media: [ProductMedia!]
-
- """List of images for the product."""
- images: [ProductImage!] @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `media` field instead.")
-
- """
- List of collections for the product. Requires the following permissions to include the unpublished items: MANAGE_ORDERS, MANAGE_DISCOUNTS, MANAGE_PRODUCTS.
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
"""
- collections: [Collection!]
-
- """Returns translated product fields for the given language code."""
- translation(
- """A language code to return the translation for product."""
- languageCode: LanguageCodeEnum!
- ): ProductTranslation
-
- """Date when product is available for purchase."""
- availableForPurchase: Date @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `availableForPurchaseAt` field to fetch the available for purchase date.")
-
- """Date when product is available for purchase."""
- availableForPurchaseAt: DateTime
-
- """Whether the product is available for purchase."""
- isAvailableForPurchase: Boolean
+ availableShippingMethodsPerCountry(countries: [CountryCode!]): [ShippingMethodsPerCountry!]
}
"""
-Represents a type of product. It defines what attributes are available to products of this type.
-"""
-type ProductType implements Node & ObjectWithMetadata {
- id: ID!
+List of shipping methods available for the country.
- """List of private metadata items. Requires staff permissions to access."""
- privateMetadata: [MetadataItem!]!
+Added in Saleor 3.6.
- """
- A single key from private metadata. Requires staff permissions to access.
-
- Tip: Use GraphQL aliases to fetch multiple keys.
-
- Added in Saleor 3.3.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
- """
- privateMetafield(key: String!): String
+Note: this API is currently in Feature Preview and can be subject to changes at later point.
+"""
+type ShippingMethodsPerCountry {
+ """The country code."""
+ countryCode: CountryCode!
- """
- Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
-
- Added in Saleor 3.3.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
- """
- 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.
-
- Added in Saleor 3.3.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
- """
- 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.3.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
- """
- metafields(keys: [String!]): Metadata
- name: String!
- slug: String!
- hasVariants: Boolean!
- isShippingRequired: Boolean!
- isDigital: Boolean!
- weight: Weight
-
- """The product type kind."""
- kind: ProductTypeKindEnum!
-
- """List of products of this type."""
- products(
- """Slug of a channel for which the data should be returned."""
- channel: String
-
- """Return the elements in the list that come before the specified cursor."""
- before: String
-
- """Return the elements in the list that come after the specified cursor."""
- after: String
-
- """Return the first n elements from the list."""
- first: Int
-
- """Return the last n elements from the list."""
- last: Int
- ): ProductCountableConnection @deprecated(reason: "This field will be removed in Saleor 4.0. Use the top-level `products` query with the `productTypes` filter.")
-
- """A type of tax. Assigned by enabled tax gateway"""
- taxType: TaxType
-
- """Variant attributes of that product type."""
- variantAttributes(
- """Define scope of returned attributes."""
- variantSelection: VariantAttributeScope
- ): [Attribute!] @deprecated(reason: "This field will be removed in Saleor 4.0. Use `assignedVariantAttributes` instead.")
-
- """
- Variant attributes of that product type with attached variant selection.
-
- Added in Saleor 3.1.
- """
- assignedVariantAttributes(
- """Define scope of returned attributes."""
- variantSelection: VariantAttributeScope
- ): [AssignedVariantAttribute!]
-
- """Product attributes of that product type."""
- productAttributes: [Attribute!]
-
- """
- List of attributes which can be assigned to this product type.
-
- Requires one of the following permissions: MANAGE_PRODUCTS.
- """
- availableAttributes(
- filter: AttributeFilterInput
-
- """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
-
- """Return the first n elements from the list."""
- first: Int
-
- """Return the last n elements from the list."""
- last: Int
- ): AttributeCountableConnection
-}
-
-"""Represents weight value in a specific weight unit."""
-type Weight {
- """Weight unit."""
- unit: WeightUnitsEnum!
-
- """Weight value."""
- value: Float!
+ """List of available shipping methods."""
+ shippingMethods: [ShippingMethod!]
}
"""An enumeration."""
-enum WeightUnitsEnum {
- G
- LB
- OZ
+enum CountryCode {
+ AF
+ AX
+ AL
+ DZ
+ AS
+ AD
+ AO
+ AI
+ AQ
+ AG
+ AR
+ AM
+ AW
+ AU
+ AT
+ AZ
+ BS
+ BH
+ BD
+ BB
+ BY
+ BE
+ BZ
+ BJ
+ BM
+ BT
+ BO
+ BQ
+ BA
+ BW
+ BV
+ BR
+ IO
+ BN
+ BG
+ BF
+ BI
+ CV
+ KH
+ CM
+ CA
+ KY
+ CF
+ TD
+ CL
+ CN
+ CX
+ CC
+ CO
+ KM
+ CG
+ CD
+ CK
+ CR
+ CI
+ HR
+ CU
+ CW
+ CY
+ CZ
+ DK
+ DJ
+ DM
+ DO
+ EC
+ EG
+ SV
+ GQ
+ ER
+ EE
+ SZ
+ ET
+ EU
+ FK
+ FO
+ FJ
+ FI
+ FR
+ GF
+ PF
+ TF
+ GA
+ GM
+ GE
+ DE
+ GH
+ GI
+ GR
+ GL
+ GD
+ GP
+ GU
+ GT
+ GG
+ GN
+ GW
+ GY
+ HT
+ HM
+ VA
+ HN
+ HK
+ HU
+ IS
+ IN
+ ID
+ IR
+ IQ
+ IE
+ IM
+ IL
+ IT
+ JM
+ JP
+ JE
+ JO
+ KZ
+ KE
+ KI
+ KW
KG
- TONNE
-}
-
-"""An enumeration."""
-enum ProductTypeKindEnum {
- NORMAL
- GIFT_CARD
-}
-
-"""Representation of tax types fetched from tax gateway."""
-type TaxType {
- """Description of the tax type."""
- description: String
-
- """External tax code used to identify given tax group."""
- taxCode: String
-}
-
-"""
-Custom attribute of a product. Attributes can be assigned to products and variants at the product type level.
-"""
-type Attribute implements Node & ObjectWithMetadata {
- id: ID!
-
- """List of private metadata items. Requires staff permissions to access."""
- privateMetadata: [MetadataItem!]!
+ LA
+ LV
+ LB
+ LS
+ LR
+ LY
+ LI
+ LT
+ LU
+ MO
+ MG
+ MW
+ MY
+ MV
+ ML
+ MT
+ MH
+ MQ
+ MR
+ MU
+ YT
+ MX
+ FM
+ MD
+ MC
+ MN
+ ME
+ MS
+ MA
+ MZ
+ MM
+ NA
+ NR
+ NP
+ NL
+ NC
+ NZ
+ NI
+ NE
+ NG
+ NU
+ NF
+ KP
+ MK
+ MP
+ NO
+ OM
+ PK
+ PW
+ PS
+ PA
+ PG
+ PY
+ PE
+ PH
+ PN
+ PL
+ PT
+ PR
+ QA
+ RE
+ RO
+ RU
+ RW
+ BL
+ SH
+ KN
+ LC
+ MF
+ PM
+ VC
+ WS
+ SM
+ ST
+ SA
+ SN
+ RS
+ SC
+ SL
+ SG
+ SX
+ SK
+ SI
+ SB
+ SO
+ ZA
+ GS
+ KR
+ SS
+ ES
+ LK
+ SD
+ SR
+ SJ
+ SE
+ CH
+ SY
+ TW
+ TJ
+ TZ
+ TH
+ TL
+ TG
+ TK
+ TO
+ TT
+ TN
+ TR
+ TM
+ TC
+ TV
+ UG
+ UA
+ AE
+ GB
+ UM
+ US
+ UY
+ UZ
+ VU
+ VE
+ VN
+ VG
+ VI
+ WF
+ EH
+ YE
+ ZM
+ ZW
+}
+
+"""
+Shipping methods that can be used as means of shipping for orders and checkouts.
+"""
+type ShippingMethod implements Node & ObjectWithMetadata {
+ """Unique ID of ShippingMethod available for Order."""
+ 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.
@@ -4233,392 +4185,284 @@ type Attribute implements Node & ObjectWithMetadata {
"""
metafields(keys: [String!]): Metadata
- """The input type to use for entering attribute values in the dashboard."""
- inputType: AttributeInputTypeEnum
+ """Type of the shipping method."""
+ type: ShippingMethodTypeEnum @deprecated(reason: "This field will be removed in Saleor 4.0.")
- """The entity type which can be used as a reference."""
- entityType: AttributeEntityTypeEnum
+ """Shipping method name."""
+ name: String!
- """Name of an attribute displayed in the interface."""
- name: String
+ """
+ Shipping method description.
+
+ Rich text format. For reference see https://editorjs.io/
+ """
+ description: JSONString
- """Internal representation of an attribute name."""
- slug: String
+ """Maximum delivery days for this shipping method."""
+ maximumDeliveryDays: Int
- """The attribute type."""
- type: AttributeTypeEnum
+ """Minimum delivery days for this shipping method."""
+ minimumDeliveryDays: Int
- """The unit of attribute values."""
- unit: MeasurementUnitsEnum
+ """Maximum order weight for this shipping method."""
+ maximumOrderWeight: Weight @deprecated(reason: "This field will be removed in Saleor 4.0.")
- """List of attribute's values."""
- choices(
- """Sort attribute choices."""
- sortBy: AttributeChoicesSortingInput
+ """Minimum order weight for this shipping method."""
+ minimumOrderWeight: Weight @deprecated(reason: "This field will be removed in Saleor 4.0.")
- """Filtering options for attribute choices."""
- filter: AttributeValueFilterInput
+ """Returns translated shipping method fields for the given language code."""
+ translation(
+ """A language code to return the translation for shipping method."""
+ languageCode: LanguageCodeEnum!
+ ): ShippingMethodTranslation
- """Return the elements in the list that come before the specified cursor."""
- before: String
+ """The price of selected shipping method."""
+ price: Money!
- """Return the elements in the list that come after the specified cursor."""
- after: String
+ """Maximum order price for this shipping method."""
+ maximumOrderPrice: Money
- """Return the first n elements from the list."""
- first: Int
+ """Minimal order price for this shipping method."""
+ minimumOrderPrice: Money
- """Return the last n elements from the list."""
- last: Int
- ): AttributeValueCountableConnection
+ """Describes if this shipping method is active and can be selected."""
+ active: Boolean!
- """
- Whether the attribute requires values to be passed or not. Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.
- """
- valueRequired: Boolean!
+ """Message connected to this shipping method."""
+ message: String
+}
- """
- Whether the attribute should be visible or not in storefront. Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.
- """
- visibleInStorefront: Boolean!
+"""Represents weight value in a specific weight unit."""
+type Weight {
+ """Weight unit."""
+ unit: WeightUnitsEnum!
- """
- Whether the attribute can be filtered in storefront. Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.
- """
- filterableInStorefront: Boolean!
+ """Weight value."""
+ value: Float!
+}
- """
- Whether the attribute can be filtered in dashboard. Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.
- """
- filterableInDashboard: Boolean!
+"""An enumeration."""
+enum WeightUnitsEnum {
+ G
+ LB
+ OZ
+ KG
+ TONNE
+}
- """
- Whether the attribute can be displayed in the admin product list. Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.
- """
- availableInGrid: Boolean!
+"""Represents shipping method postal code rule."""
+type ShippingMethodPostalCodeRule implements Node {
+ """The ID of the object."""
+ id: ID!
- """
- The position of the attribute in the storefront navigation (0 by default). Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.
- """
- storefrontSearchPosition: Int!
+ """Start address range."""
+ start: String
- """Returns translated attribute fields for the given language code."""
- translation(
- """A language code to return the translation for attribute."""
- languageCode: LanguageCodeEnum!
- ): AttributeTranslation
+ """End address range."""
+ end: String
- """Flag indicating that attribute has predefined choices."""
- withChoices: Boolean!
- productTypes(
- """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
-
- """Return the first n elements from the list."""
- first: Int
-
- """Return the last n elements from the list."""
- last: Int
- ): ProductTypeCountableConnection!
- productVariantTypes(
- """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
-
- """Return the first n elements from the list."""
- first: Int
-
- """Return the last n elements from the list."""
- last: Int
- ): ProductTypeCountableConnection!
-}
-
-"""An enumeration."""
-enum AttributeInputTypeEnum {
- DROPDOWN
- MULTISELECT
- FILE
- REFERENCE
- NUMERIC
- RICH_TEXT
- PLAIN_TEXT
- SWATCH
- BOOLEAN
- DATE
- DATE_TIME
-}
-
-"""An enumeration."""
-enum AttributeEntityTypeEnum {
- PAGE
- PRODUCT
-}
-
-"""An enumeration."""
-enum AttributeTypeEnum {
- PRODUCT_TYPE
- PAGE_TYPE
+ """Inclusion type of the postal code rule."""
+ inclusionType: PostalCodeRuleInclusionTypeEnum
}
"""An enumeration."""
-enum MeasurementUnitsEnum {
- CM
- M
- KM
- FT
- YD
- INCH
- SQ_CM
- SQ_M
- SQ_KM
- SQ_FT
- SQ_YD
- SQ_INCH
- CUBIC_MILLIMETER
- CUBIC_CENTIMETER
- CUBIC_DECIMETER
- CUBIC_METER
- LITER
- CUBIC_FOOT
- CUBIC_INCH
- CUBIC_YARD
- QT
- PINT
- FL_OZ
- ACRE_IN
- ACRE_FT
- G
- LB
- OZ
- KG
- TONNE
+enum PostalCodeRuleInclusionTypeEnum {
+ INCLUDE
+ EXCLUDE
}
-type AttributeValueCountableConnection {
+type ProductCountableConnection {
"""Pagination data for this connection."""
pageInfo: PageInfo!
- edges: [AttributeValueCountableEdge!]!
+ edges: [ProductCountableEdge!]!
"""A total count of items in the collection."""
totalCount: Int
}
-type AttributeValueCountableEdge {
+type ProductCountableEdge {
"""The item at the end of the edge."""
- node: AttributeValue!
+ node: Product!
"""A cursor for use in pagination."""
cursor: String!
}
-"""Represents a value of an attribute."""
-type AttributeValue implements Node {
+"""Represents an individual item for sale in the storefront."""
+type Product implements Node & ObjectWithMetadata {
id: ID!
- """Name of a value displayed in the interface."""
- name: String
-
- """Internal representation of a value (unique per attribute)."""
- slug: String
+ """List of private metadata items. Requires staff permissions to access."""
+ privateMetadata: [MetadataItem!]!
"""
- Represent value of the attribute value (e.g. color values for swatch attributes).
+ A single key from private metadata. Requires staff permissions to access.
+
+ Tip: Use GraphQL aliases to fetch multiple keys.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
"""
- value: String
+ privateMetafield(key: String!): String
- """Returns translated attribute value fields for the given language code."""
- translation(
- """A language code to return the translation for attribute value."""
- languageCode: LanguageCodeEnum!
- ): AttributeValueTranslation
+ """
+ Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ privateMetafields(keys: [String!]): Metadata
- """The input type to use for entering attribute values in the dashboard."""
- inputType: AttributeInputTypeEnum
+ """List of public metadata items. Can be accessed without permissions."""
+ metadata: [MetadataItem!]!
- """The ID of the attribute reference."""
- reference: ID
+ """
+ A single key from public metadata.
+
+ Tip: Use GraphQL aliases to fetch multiple keys.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ metafield(key: String!): String
- """Represents file URL and content type (if attribute value is a file)."""
- file: File
+ """
+ Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ metafields(keys: [String!]): Metadata
+ seoTitle: String
+ seoDescription: String
+ name: String!
"""
- Represents the text of the attribute value, includes formatting.
+ Description of the product.
Rich text format. For reference see https://editorjs.io/
"""
- richText: JSONString
+ description: JSONString
+ productType: ProductType!
+ slug: String!
+ category: Category
+ created: DateTime!
+ updatedAt: DateTime!
+ chargeTaxes: Boolean!
+ weight: Weight
+ defaultVariant: ProductVariant
+ rating: Float
"""
- Represents the text of the attribute value, plain text without formating.
+ Channel given to retrieve this product. Also used by federation gateway to resolve this object in a federated query.
"""
- plainText: String
+ channel: String
- """Represents the boolean value of the attribute value."""
- boolean: Boolean
+ """
+ Description of the product.
+
+ Rich text format. For reference see https://editorjs.io/
+ """
+ descriptionJson: JSONString @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `description` field instead.")
+ thumbnail(
+ """
+ Size of the image. If not provided, the original image will be returned.
+ """
+ size: Int
- """Represents the date value of the attribute value."""
- date: Date
+ """
+ The format of the image. When not provided, format of the original image will be used. Must be provided together with the size value, otherwise original image will be returned.
+
+ Added in Saleor 3.6.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ format: ThumbnailFormatEnum
+ ): Image
- """Represents the date/time value of the attribute value."""
- dateTime: DateTime
-}
+ """
+ Lists the storefront product's pricing, the current price and discounts, only meant for displaying.
+ """
+ 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
+ ): ProductPricingInfo
-type AttributeValueTranslation implements Node {
- id: ID!
+ """Whether the product is in stock and visible or not."""
+ isAvailable(
+ """
+ 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
+ ): Boolean
- """Translation language."""
- language: LanguageDisplay!
- name: String!
+ """A type of tax. Assigned by enabled tax gateway"""
+ taxType: TaxType
+
+ """List of attributes assigned to this product."""
+ attributes: [SelectedAttribute!]!
"""
- Attribute value.
+ List of availability in channels for the product.
- Rich text format. For reference see https://editorjs.io/
+ Requires one of the following permissions: MANAGE_PRODUCTS.
"""
- richText: JSONString
-
- """Attribute plain text value."""
- plainText: String
-}
+ channelListings: [ProductChannelListing!]
-type File {
- """The URL of the file."""
- url: String!
+ """Get a single product media by ID."""
+ mediaById(
+ """ID of a product media."""
+ id: ID
+ ): ProductMedia
- """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 {
- """Specifies the direction in which to sort products."""
- direction: OrderDirection!
-
- """Sort attribute choices by the selected field."""
- field: AttributeChoicesSortField!
-}
-
-enum AttributeChoicesSortField {
- """Sort attribute choice by name."""
- NAME
-
- """Sort attribute choice by slug."""
- SLUG
-}
-
-input AttributeValueFilterInput {
- search: String
- ids: [ID!]
-}
-
-type AttributeTranslation implements Node {
- id: ID!
-
- """Translation language."""
- language: LanguageDisplay!
- name: String!
-}
-
-type ProductTypeCountableConnection {
- """Pagination data for this connection."""
- pageInfo: PageInfo!
- edges: [ProductTypeCountableEdge!]!
-
- """A total count of items in the collection."""
- totalCount: Int
-}
-
-type ProductTypeCountableEdge {
- """The item at the end of the edge."""
- node: ProductType!
-
- """A cursor for use in pagination."""
- cursor: String!
-}
-
-enum VariantAttributeScope {
- ALL
- VARIANT_SELECTION
- NOT_VARIANT_SELECTION
-}
-
-"""
-Represents assigned attribute to variant with variant selection attached.
-
-Added in Saleor 3.1.
-"""
-type AssignedVariantAttribute {
- """Attribute assigned to variant."""
- attribute: Attribute!
+ """Get a single product image by ID."""
+ imageById(
+ """ID of a product image."""
+ id: ID
+ ): ProductImage @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `mediaById` field instead.")
"""
- Determines, whether assigned attribute is allowed for variant selection. Supported variant types for variant selection are: ['dropdown', 'boolean', 'swatch', 'numeric']
+ List of variants for the product. Requires the following permissions to include the unpublished items: MANAGE_ORDERS, MANAGE_DISCOUNTS, MANAGE_PRODUCTS.
"""
- variantSelection: Boolean!
-}
-
-type AttributeCountableConnection {
- """Pagination data for this connection."""
- pageInfo: PageInfo!
- edges: [AttributeCountableEdge!]!
-
- """A total count of items in the collection."""
- totalCount: Int
-}
-
-type AttributeCountableEdge {
- """The item at the end of the edge."""
- node: Attribute!
+ variants: [ProductVariant!]
- """A cursor for use in pagination."""
- cursor: String!
-}
+ """List of media for the product."""
+ media: [ProductMedia!]
-input AttributeFilterInput {
- valueRequired: Boolean
- isVariantOnly: Boolean
- visibleInStorefront: Boolean
- filterableInStorefront: Boolean
- filterableInDashboard: Boolean
- availableInGrid: Boolean
- metadata: [MetadataFilter!]
- search: String
- ids: [ID!]
- type: AttributeTypeEnum
- inCollection: ID
- inCategory: ID
+ """List of images for the product."""
+ images: [ProductImage!] @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `media` field instead.")
"""
- Specifies the channel by which the data should be filtered.
-
- DEPRECATED: this field will be removed in Saleor 4.0. Use root-level channel argument instead.
+ List of collections for the product. Requires the following permissions to include the unpublished items: MANAGE_ORDERS, MANAGE_DISCOUNTS, MANAGE_PRODUCTS.
"""
- channel: String
-}
+ collections: [Collection!]
-input MetadataFilter {
- """Key of a metadata item."""
- key: String!
+ """Returns translated product fields for the given language code."""
+ translation(
+ """A language code to return the translation for product."""
+ languageCode: LanguageCodeEnum!
+ ): ProductTranslation
- """Value of a metadata item."""
- value: String
+ """Date when product is available for purchase."""
+ availableForPurchase: Date @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `availableForPurchaseAt` field to fetch the available for purchase date.")
+
+ """Date when product is available for purchase."""
+ availableForPurchaseAt: DateTime
+
+ """Whether the product is available for purchase."""
+ isAvailableForPurchase: 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.
+Represents a type of product. It defines what attributes are available to products of this type.
"""
-type Category implements Node & ObjectWithMetadata {
+type ProductType implements Node & ObjectWithMetadata {
id: ID!
"""List of private metadata items. Requires staff permissions to access."""
@@ -4666,29 +4510,21 @@ type Category implements Node & ObjectWithMetadata {
Note: this API is currently in Feature Preview and can be subject to changes at later point.
"""
metafields(keys: [String!]): Metadata
- seoTitle: String
- seoDescription: String
name: String!
-
- """
- Description of the category.
-
- Rich text format. For reference see https://editorjs.io/
- """
- description: JSONString
slug: String!
- parent: Category
- level: Int!
+ hasVariants: Boolean!
+ isShippingRequired: Boolean!
+ isDigital: Boolean!
+ weight: Weight
- """
- Description of the category.
-
- Rich text format. For reference see https://editorjs.io/
- """
- descriptionJson: JSONString @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `description` field instead.")
+ """The product type kind."""
+ kind: ProductTypeKindEnum!
+
+ """List of products of this type."""
+ products(
+ """Slug of a channel for which the data should be returned."""
+ channel: String
- """List of ancestors of the category."""
- ancestors(
"""Return the elements in the list that come before the specified cursor."""
before: String
@@ -4700,30 +4536,38 @@ type Category implements Node & ObjectWithMetadata {
"""Return the last n elements from the list."""
last: Int
- ): CategoryCountableConnection
+ ): ProductCountableConnection @deprecated(reason: "This field will be removed in Saleor 4.0. Use the top-level `products` query with the `productTypes` filter.")
- """
- List of products in the category. Requires the following permissions to include the unpublished items: MANAGE_ORDERS, MANAGE_DISCOUNTS, MANAGE_PRODUCTS.
- """
- products(
- """Slug of a channel for which the data should be returned."""
- channel: String
+ """A type of tax. Assigned by enabled tax gateway"""
+ taxType: TaxType
- """Return the elements in the list that come before the specified cursor."""
- before: String
+ """Variant attributes of that product type."""
+ variantAttributes(
+ """Define scope of returned attributes."""
+ variantSelection: VariantAttributeScope
+ ): [Attribute!] @deprecated(reason: "This field will be removed in Saleor 4.0. Use `assignedVariantAttributes` instead.")
- """Return the elements in the list that come after the specified cursor."""
- after: String
+ """
+ Variant attributes of that product type with attached variant selection.
+
+ Added in Saleor 3.1.
+ """
+ assignedVariantAttributes(
+ """Define scope of returned attributes."""
+ variantSelection: VariantAttributeScope
+ ): [AssignedVariantAttribute!]
- """Return the first n elements from the list."""
- first: Int
+ """Product attributes of that product type."""
+ productAttributes: [Attribute!]
- """Return the last n elements from the list."""
- last: Int
- ): ProductCountableConnection
+ """
+ List of attributes which can be assigned to this product type.
+
+ Requires one of the following permissions: MANAGE_PRODUCTS.
+ """
+ availableAttributes(
+ filter: AttributeFilterInput
- """List of children of the category."""
- children(
"""Return the elements in the list that come before the specified cursor."""
before: String
@@ -4735,87 +4579,28 @@ type Category implements Node & ObjectWithMetadata {
"""Return the last n elements from the list."""
last: Int
- ): CategoryCountableConnection
- backgroundImage(
- """
- Size of the image. If not provided, the original image will be returned.
- """
- size: Int
-
- """
- The format of the image. When not provided, format of the original image will be used. Must be provided together with the size value, otherwise original image will be returned.
-
- Added in Saleor 3.6.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
- """
- format: ThumbnailFormatEnum
- ): Image
-
- """Returns translated category fields for the given language code."""
- translation(
- """A language code to return the translation for category."""
- languageCode: LanguageCodeEnum!
- ): CategoryTranslation
+ ): AttributeCountableConnection
}
-type CategoryCountableConnection {
- """Pagination data for this connection."""
- pageInfo: PageInfo!
- edges: [CategoryCountableEdge!]!
-
- """A total count of items in the collection."""
- totalCount: Int
+"""An enumeration."""
+enum ProductTypeKindEnum {
+ NORMAL
+ GIFT_CARD
}
-type CategoryCountableEdge {
- """The item at the end of the edge."""
- node: Category!
+"""Representation of tax types fetched from tax gateway."""
+type TaxType {
+ """Description of the tax type."""
+ description: String
- """A cursor for use in pagination."""
- cursor: String!
+ """External tax code used to identify given tax group."""
+ taxCode: String
}
-"""Represents an image."""
-type Image {
- """The URL of the image."""
- url: String!
-
- """Alt text for an image."""
- alt: String
-}
-
-"""An enumeration."""
-enum ThumbnailFormatEnum {
- WEBP
-}
-
-type CategoryTranslation implements Node {
- id: ID!
-
- """Translation language."""
- language: LanguageDisplay!
- seoTitle: String
- seoDescription: String
- name: String
-
- """
- Translated description of the category.
-
- Rich text format. For reference see https://editorjs.io/
- """
- description: JSONString
-
- """
- Translated description of the category.
-
- Rich text format. For reference see https://editorjs.io/
- """
- descriptionJson: JSONString @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `description` field instead.")
-}
-
-"""Represents a version of a product such as different size or color."""
-type ProductVariant implements Node & ObjectWithMetadata {
+"""
+Custom attribute of a product. Attributes can be assigned to products and variants at the product type level.
+"""
+type Attribute implements Node & ObjectWithMetadata {
id: ID!
"""List of private metadata items. Requires staff permissions to access."""
@@ -4863,485 +4648,862 @@ type ProductVariant implements Node & ObjectWithMetadata {
Note: this API is currently in Feature Preview and can be subject to changes at later point.
"""
metafields(keys: [String!]): Metadata
- name: String!
- sku: String
- product: Product!
- trackInventory: Boolean!
- quantityLimitPerCustomer: Int
- weight: Weight
- """
- Channel given to retrieve this product variant. Also used by federation gateway to resolve this object in a federated query.
- """
- channel: String
+ """The input type to use for entering attribute values in the dashboard."""
+ inputType: AttributeInputTypeEnum
- """
- List of price information in channels for the product.
-
- Requires one of the following permissions: AUTHENTICATED_APP, AUTHENTICATED_STAFF_USER.
- """
- channelListings: [ProductVariantChannelListing!]
+ """The entity type which can be used as a reference."""
+ entityType: AttributeEntityTypeEnum
- """
- Lists the storefront variant's pricing, the current price and discounts, only meant for displaying.
- """
- 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
+ """Name of an attribute displayed in the interface."""
+ name: String
- """List of attributes assigned to this variant."""
- attributes(
- """Define scope of returned attributes."""
- variantSelection: VariantAttributeScope
- ): [SelectedAttribute!]!
+ """Internal representation of an attribute name."""
+ slug: String
- """Gross margin percentage value."""
- margin: Int
+ """The attribute type."""
+ type: AttributeTypeEnum
- """
- Total quantity ordered.
-
- Requires one of the following permissions: MANAGE_PRODUCTS.
- """
- quantityOrdered: Int
+ """The unit of attribute values."""
+ unit: MeasurementUnitsEnum
- """
- 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
+ """List of attribute's values."""
+ choices(
+ """Sort attribute choices."""
+ sortBy: AttributeChoicesSortingInput
- """List of images for the product variant."""
- images: [ProductImage!] @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `media` field instead.")
+ """Filtering options for attribute choices."""
+ filter: AttributeValueFilterInput
- """List of media for the product variant."""
- media: [ProductMedia!]
+ """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
+
+ """Return the first n elements from the list."""
+ first: Int
+
+ """Return the last n elements from the list."""
+ last: Int
+ ): AttributeValueCountableConnection
"""
- Digital content for the product variant.
-
- Requires one of the following permissions: MANAGE_PRODUCTS.
+ Whether the attribute requires values to be passed or not. Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.
"""
- digitalContent: DigitalContent
+ valueRequired: Boolean!
"""
- Stocks for the product variant.
-
- Requires one of the following permissions: MANAGE_PRODUCTS, MANAGE_ORDERS.
+ Whether the attribute should be visible or not in storefront. Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.
"""
- 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
-
- """
- Two-letter ISO 3166-1 country code.
-
- DEPRECATED: this field will be removed in Saleor 4.0. Use `address` argument instead.
- """
- countryCode: CountryCode
- ): [Stock!]
+ visibleInStorefront: Boolean!
"""
- 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.
+ Whether the attribute can be filtered in storefront. Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.
"""
- 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.
- """
- address: AddressInput
-
- """
- 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.
-
- DEPRECATED: this field will be removed in Saleor 4.0. Use `address` argument instead.
- """
- countryCode: CountryCode
- ): Int
+ filterableInStorefront: Boolean!
"""
- Preorder data for product variant.
-
- Added in Saleor 3.1.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ Whether the attribute can be filtered in dashboard. Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.
"""
- preorder: PreorderData
- created: DateTime!
- updatedAt: DateTime!
-}
-
-"""Represents product varaint channel listing."""
-type ProductVariantChannelListing implements Node {
- id: ID!
- channel: Channel!
- price: Money
-
- """Cost price of the variant."""
- costPrice: Money
+ filterableInDashboard: Boolean!
"""
- Gross margin percentage value.
-
- Requires one of the following permissions: MANAGE_PRODUCTS.
+ Whether the attribute can be displayed in the admin product list. Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.
"""
- margin: Int
+ availableInGrid: Boolean!
"""
- Preorder variant data.
-
- Added in Saleor 3.1.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ The position of the attribute in the storefront navigation (0 by default). Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.
"""
- preorderThreshold: PreorderThreshold
-}
+ storefrontSearchPosition: Int!
-"""Represents preorder variant data for channel."""
-type PreorderThreshold {
- """Preorder threshold for product variant in this channel."""
- quantity: Int
+ """Returns translated attribute fields for the given language code."""
+ translation(
+ """A language code to return the translation for attribute."""
+ languageCode: LanguageCodeEnum!
+ ): AttributeTranslation
- """Number of sold product variant in this channel."""
- soldUnits: Int!
-}
+ """Flag indicating that attribute has predefined choices."""
+ withChoices: Boolean!
+ productTypes(
+ """Return the elements in the list that come before the specified cursor."""
+ before: String
-"""Represents availability of a variant in the storefront."""
-type VariantPricingInfo {
- """Whether it is in sale or not."""
- onSale: Boolean
+ """Return the elements in the list that come after the specified cursor."""
+ after: String
- """The discount amount if in sale (null otherwise)."""
- discount: TaxedMoney
+ """Return the first n elements from the list."""
+ first: Int
- """The discount amount in the local currency."""
- discountLocalCurrency: TaxedMoney
+ """Return the last n elements from the list."""
+ last: Int
+ ): ProductTypeCountableConnection!
+ productVariantTypes(
+ """Return the elements in the list that come before the specified cursor."""
+ before: String
- """The price, with any discount subtracted."""
- price: TaxedMoney
+ """Return the elements in the list that come after the specified cursor."""
+ after: String
- """The price without any discount."""
- priceUndiscounted: TaxedMoney
+ """Return the first n elements from the list."""
+ first: Int
- """The discounted price in the local currency."""
- priceLocalCurrency: TaxedMoney
+ """Return the last n elements from the list."""
+ last: Int
+ ): ProductTypeCountableConnection!
}
-"""
-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!
-
- """Amount of money including taxes."""
- gross: Money!
-
- """Amount of money without taxes."""
- net: Money!
+"""An enumeration."""
+enum AttributeInputTypeEnum {
+ DROPDOWN
+ MULTISELECT
+ FILE
+ REFERENCE
+ NUMERIC
+ RICH_TEXT
+ PLAIN_TEXT
+ SWATCH
+ BOOLEAN
+ DATE
+ DATE_TIME
+}
- """Amount of taxes."""
- tax: Money!
+"""An enumeration."""
+enum AttributeEntityTypeEnum {
+ PAGE
+ PRODUCT
}
-input AddressInput {
- """Given name."""
- firstName: String
+"""An enumeration."""
+enum AttributeTypeEnum {
+ PRODUCT_TYPE
+ PAGE_TYPE
+}
- """Family name."""
- lastName: String
+"""An enumeration."""
+enum MeasurementUnitsEnum {
+ CM
+ M
+ KM
+ FT
+ YD
+ INCH
+ SQ_CM
+ SQ_M
+ SQ_KM
+ SQ_FT
+ SQ_YD
+ SQ_INCH
+ CUBIC_MILLIMETER
+ CUBIC_CENTIMETER
+ CUBIC_DECIMETER
+ CUBIC_METER
+ LITER
+ CUBIC_FOOT
+ CUBIC_INCH
+ CUBIC_YARD
+ QT
+ PINT
+ FL_OZ
+ ACRE_IN
+ ACRE_FT
+ G
+ LB
+ OZ
+ KG
+ TONNE
+}
- """Company or organization."""
- companyName: String
+type AttributeValueCountableConnection {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [AttributeValueCountableEdge!]!
- """Address."""
- streetAddress1: String
+ """A total count of items in the collection."""
+ totalCount: Int
+}
- """Address."""
- streetAddress2: String
+type AttributeValueCountableEdge {
+ """The item at the end of the edge."""
+ node: AttributeValue!
- """City."""
- city: String
+ """A cursor for use in pagination."""
+ cursor: String!
+}
- """District."""
- cityArea: String
+"""Represents a value of an attribute."""
+type AttributeValue implements Node {
+ id: ID!
- """Postal code."""
- postalCode: String
+ """Name of a value displayed in the interface."""
+ name: String
- """Country."""
- country: CountryCode
+ """Internal representation of a value (unique per attribute)."""
+ slug: String
- """State or province."""
- countryArea: String
+ """
+ Represent value of the attribute value (e.g. color values for swatch attributes).
+ """
+ value: String
- """Phone number."""
- phone: String
+ """Returns translated attribute value fields for the given language code."""
+ translation(
+ """A language code to return the translation for attribute value."""
+ languageCode: LanguageCodeEnum!
+ ): AttributeValueTranslation
+
+ """The input type to use for entering attribute values in the dashboard."""
+ inputType: AttributeInputTypeEnum
+
+ """The ID of the attribute reference."""
+ reference: ID
+
+ """Represents file URL and content type (if attribute value is a file)."""
+ file: File
+
+ """
+ Represents the text of the attribute value, includes formatting.
+
+ Rich text format. For reference see https://editorjs.io/
+ """
+ richText: JSONString
+
+ """
+ Represents the text of the attribute value, plain text without formating.
+ """
+ plainText: String
+
+ """Represents the boolean value of the attribute value."""
+ boolean: Boolean
+
+ """Represents the date value of the attribute value."""
+ date: Date
+
+ """Represents the date/time value of the attribute value."""
+ dateTime: DateTime
}
-"""An enumeration."""
-enum CountryCode {
- AF
- AX
- AL
- DZ
- AS
- AD
- AO
- AI
- AQ
- AG
- AR
- AM
- AW
- AU
- AT
- AZ
- BS
- BH
- BD
- BB
- BY
- BE
- BZ
- BJ
- BM
- BT
- BO
- BQ
- BA
- BW
- BV
- BR
- IO
- BN
- BG
- BF
- BI
- CV
- KH
- CM
- CA
- KY
- CF
- TD
- CL
- CN
- CX
- CC
- CO
- KM
- CG
- CD
- CK
- CR
- CI
- HR
- CU
- CW
- CY
- CZ
- DK
- DJ
- DM
- DO
- EC
- EG
- SV
- GQ
- ER
- EE
- SZ
- ET
- EU
- FK
- FO
- FJ
- FI
- FR
- GF
- PF
- TF
- GA
- GM
- GE
- DE
- GH
- GI
- GR
- GL
- GD
- GP
- GU
- GT
- GG
- GN
- GW
- GY
- HT
- HM
- VA
- HN
- HK
- HU
- IS
- IN
- ID
- IR
- IQ
- IE
- IM
- IL
- IT
- JM
- JP
- JE
- JO
- KZ
- KE
- KI
- KW
- KG
- LA
- LV
- LB
- LS
- LR
- LY
- LI
- LT
- LU
- MO
- MG
- MW
- MY
- MV
- ML
- MT
- MH
- MQ
- MR
- MU
- YT
- MX
- FM
- MD
- MC
- MN
- ME
- MS
- MA
- MZ
- MM
- NA
- NR
- NP
- NL
- NC
- NZ
- NI
- NE
- NG
- NU
- NF
- KP
- MK
- MP
- NO
- OM
- PK
- PW
- PS
- PA
- PG
- PY
- PE
- PH
- PN
- PL
- PT
- PR
- QA
- RE
- RO
- RU
- RW
- BL
- SH
- KN
- LC
- MF
- PM
- VC
- WS
- SM
- ST
- SA
- SN
- RS
- SC
- SL
- SG
- SX
- SK
- SI
- SB
- SO
- ZA
- GS
- KR
- SS
- ES
- LK
- SD
- SR
- SJ
- SE
- CH
- SY
- TW
- TJ
- TZ
- TH
- TL
- TG
- TK
- TO
- TT
- TN
- TR
- TM
- TC
- TV
- UG
- UA
- AE
- GB
- UM
- US
- UY
- UZ
- VU
- VE
- VN
- VG
- VI
- WF
- EH
- YE
- ZM
- ZW
+type AttributeValueTranslation implements Node {
+ id: ID!
+
+ """Translation language."""
+ language: LanguageDisplay!
+ name: String!
+
+ """
+ Attribute value.
+
+ Rich text format. For reference see https://editorjs.io/
+ """
+ richText: JSONString
+
+ """Attribute plain text value."""
+ plainText: String
+}
+
+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 {
+ """Specifies the direction in which to sort products."""
+ direction: OrderDirection!
+
+ """Sort attribute choices by the selected field."""
+ field: AttributeChoicesSortField!
+}
+
+enum AttributeChoicesSortField {
+ """Sort attribute choice by name."""
+ NAME
+
+ """Sort attribute choice by slug."""
+ SLUG
+}
+
+input AttributeValueFilterInput {
+ search: String
+ ids: [ID!]
+}
+
+type AttributeTranslation implements Node {
+ id: ID!
+
+ """Translation language."""
+ language: LanguageDisplay!
+ name: String!
+}
+
+type ProductTypeCountableConnection {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [ProductTypeCountableEdge!]!
+
+ """A total count of items in the collection."""
+ totalCount: Int
+}
+
+type ProductTypeCountableEdge {
+ """The item at the end of the edge."""
+ node: ProductType!
+
+ """A cursor for use in pagination."""
+ cursor: String!
+}
+
+enum VariantAttributeScope {
+ ALL
+ VARIANT_SELECTION
+ NOT_VARIANT_SELECTION
+}
+
+"""
+Represents assigned attribute to variant with variant selection attached.
+
+Added in Saleor 3.1.
+"""
+type AssignedVariantAttribute {
+ """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 {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [AttributeCountableEdge!]!
+
+ """A total count of items in the collection."""
+ totalCount: Int
+}
+
+type AttributeCountableEdge {
+ """The item at the end of the edge."""
+ node: Attribute!
+
+ """A cursor for use in pagination."""
+ cursor: String!
+}
+
+input AttributeFilterInput {
+ valueRequired: Boolean
+ isVariantOnly: Boolean
+ visibleInStorefront: Boolean
+ filterableInStorefront: Boolean
+ filterableInDashboard: Boolean
+ availableInGrid: Boolean
+ metadata: [MetadataFilter!]
+ search: String
+ ids: [ID!]
+ type: AttributeTypeEnum
+ inCollection: ID
+ inCategory: ID
+
+ """
+ Specifies the channel by which the data should be filtered.
+
+ DEPRECATED: this field will be removed in Saleor 4.0. Use root-level channel argument instead.
+ """
+ channel: String
+}
+
+input MetadataFilter {
+ """Key of a metadata item."""
+ key: String!
+
+ """Value of a metadata item."""
+ value: String
+}
+
+"""
+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 {
+ 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.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ privateMetafield(key: String!): String
+
+ """
+ Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ 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.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ 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.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ metafields(keys: [String!]): Metadata
+ seoTitle: String
+ seoDescription: String
+ name: String!
+
+ """
+ Description of the category.
+
+ Rich text format. For reference see https://editorjs.io/
+ """
+ description: JSONString
+ slug: String!
+ parent: Category
+ level: Int!
+
+ """
+ Description of the category.
+
+ Rich text format. For reference see https://editorjs.io/
+ """
+ descriptionJson: JSONString @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `description` field instead.")
+
+ """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
+
+ """Return the first n elements from the list."""
+ first: Int
+
+ """Return the last n elements from the list."""
+ last: Int
+ ): CategoryCountableConnection
+
+ """
+ List of products in the category. Requires the following permissions to include the unpublished items: MANAGE_ORDERS, MANAGE_DISCOUNTS, MANAGE_PRODUCTS.
+ """
+ products(
+ """Slug of a channel for which the data should be returned."""
+ channel: String
+
+ """Return the elements in the list that come before the specified cursor."""
+ before: String
+
+ """Return the elements in the list that come after the specified cursor."""
+ after: String
+
+ """Return the first n elements from the list."""
+ first: Int
+
+ """Return the last n elements from the list."""
+ last: Int
+ ): ProductCountableConnection
+
+ """List of children of the category."""
+ children(
+ """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
+
+ """Return the first n elements from the list."""
+ first: Int
+
+ """Return the last n elements from the list."""
+ last: Int
+ ): CategoryCountableConnection
+ backgroundImage(
+ """
+ Size of the image. If not provided, the original image will be returned.
+ """
+ size: Int
+
+ """
+ The format of the image. When not provided, format of the original image will be used. Must be provided together with the size value, otherwise original image will be returned.
+
+ Added in Saleor 3.6.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ format: ThumbnailFormatEnum
+ ): Image
+
+ """Returns translated category fields for the given language code."""
+ translation(
+ """A language code to return the translation for category."""
+ languageCode: LanguageCodeEnum!
+ ): CategoryTranslation
+}
+
+type CategoryCountableConnection {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [CategoryCountableEdge!]!
+
+ """A total count of items in the collection."""
+ totalCount: Int
+}
+
+type CategoryCountableEdge {
+ """The item at the end of the edge."""
+ node: Category!
+
+ """A cursor for use in pagination."""
+ cursor: String!
+}
+
+"""Represents an image."""
+type Image {
+ """The URL of the image."""
+ url: String!
+
+ """Alt text for an image."""
+ alt: String
+}
+
+"""An enumeration."""
+enum ThumbnailFormatEnum {
+ WEBP
+}
+
+type CategoryTranslation implements Node {
+ id: ID!
+
+ """Translation language."""
+ language: LanguageDisplay!
+ seoTitle: String
+ seoDescription: String
+ name: String
+
+ """
+ Translated description of the category.
+
+ Rich text format. For reference see https://editorjs.io/
+ """
+ description: JSONString
+
+ """
+ Translated description of the category.
+
+ Rich text format. For reference see https://editorjs.io/
+ """
+ descriptionJson: JSONString @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `description` field instead.")
+}
+
+"""Represents a version of a product such as different size or color."""
+type ProductVariant implements Node & ObjectWithMetadata {
+ 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.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ privateMetafield(key: String!): String
+
+ """
+ Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ 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.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ 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.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ metafields(keys: [String!]): Metadata
+ name: String!
+ sku: String
+ product: Product!
+ trackInventory: Boolean!
+ quantityLimitPerCustomer: Int
+ weight: Weight
+
+ """
+ Channel given to retrieve this product variant. Also used by federation gateway to resolve this object in a federated query.
+ """
+ channel: String
+
+ """
+ List of price information in channels for the product.
+
+ Requires one of the following permissions: AUTHENTICATED_APP, AUTHENTICATED_STAFF_USER.
+ """
+ channelListings: [ProductVariantChannelListing!]
+
+ """
+ Lists the storefront variant's pricing, the current price and discounts, only meant for displaying.
+ """
+ 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!]!
+
+ """Gross margin percentage value."""
+ margin: Int
+
+ """
+ Total quantity ordered.
+
+ Requires one of the following permissions: MANAGE_PRODUCTS.
+ """
+ quantityOrdered: Int
+
+ """
+ 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
+
+ """List of images for the product variant."""
+ images: [ProductImage!] @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `media` field instead.")
+
+ """List of media for the product variant."""
+ media: [ProductMedia!]
+
+ """Returns translated product variant fields for the given language code."""
+ translation(
+ """A language code to return the translation for product variant."""
+ languageCode: LanguageCodeEnum!
+ ): ProductVariantTranslation
+
+ """
+ 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(
+ """
+ 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
+
+ """
+ Two-letter ISO 3166-1 country code.
+
+ DEPRECATED: this field will be removed in Saleor 4.0. Use `address` argument instead.
+ """
+ countryCode: CountryCode
+ ): [Stock!]
+
+ """
+ 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.
+ """
+ address: AddressInput
+
+ """
+ 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.
+
+ DEPRECATED: this field will be removed in Saleor 4.0. Use `address` argument instead.
+ """
+ countryCode: CountryCode
+ ): Int
+
+ """
+ Preorder data for product variant.
+
+ Added in Saleor 3.1.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ preorder: PreorderData
+ created: DateTime!
+ updatedAt: DateTime!
+}
+
+"""Represents product varaint channel listing."""
+type ProductVariantChannelListing implements Node {
+ id: ID!
+ channel: Channel!
+ price: Money
+
+ """Cost price of the variant."""
+ costPrice: Money
+
+ """
+ Gross margin percentage value.
+
+ Requires one of the following permissions: MANAGE_PRODUCTS.
+ """
+ margin: Int
+
+ """
+ Preorder variant data.
+
+ Added in Saleor 3.1.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ preorderThreshold: PreorderThreshold
+}
+
+"""Represents preorder variant data for channel."""
+type PreorderThreshold {
+ """Preorder threshold for product variant in this channel."""
+ quantity: Int
+
+ """Number of sold product variant in this channel."""
+ soldUnits: Int!
+}
+
+"""Represents availability of a variant in the storefront."""
+type VariantPricingInfo {
+ """Whether it is in sale or not."""
+ onSale: Boolean
+
+ """The discount amount if in sale (null otherwise)."""
+ discount: TaxedMoney
+
+ """The discount amount in the local currency."""
+ discountLocalCurrency: TaxedMoney
+
+ """The price, with any discount subtracted."""
+ price: TaxedMoney
+
+ """The price without any discount."""
+ priceUndiscounted: TaxedMoney
+
+ """The discounted price in the local currency."""
+ priceLocalCurrency: TaxedMoney
+}
+
+"""
+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!
+
+ """Amount of money including taxes."""
+ gross: Money!
+
+ """Amount of money without taxes."""
+ net: Money!
+
+ """Amount of taxes."""
+ tax: Money!
+}
+
+input AddressInput {
+ """Given name."""
+ firstName: String
+
+ """Family name."""
+ lastName: String
+
+ """Company or organization."""
+ companyName: String
+
+ """Address."""
+ streetAddress1: String
+
+ """Address."""
+ streetAddress2: String
+
+ """City."""
+ city: String
+
+ """District."""
+ cityArea: String
+
+ """Postal code."""
+ postalCode: String
+
+ """Country."""
+ country: CountryCode
+
+ """State or province."""
+ countryArea: String
+
+ """Phone number."""
+ phone: String
}
"""Represents a custom attribute."""
@@ -7340,106 +7502,6 @@ type ExternalAuthentication {
name: String
}
-"""
-Shipping methods that can be used as means of shipping for orders and checkouts.
-"""
-type ShippingMethod implements Node & ObjectWithMetadata {
- """Unique ID of ShippingMethod available for Order."""
- 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.
-
- Added in Saleor 3.3.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
- """
- privateMetafield(key: String!): String
-
- """
- Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
-
- Added in Saleor 3.3.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
- """
- 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.
-
- Added in Saleor 3.3.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
- """
- 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.3.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
- """
- metafields(keys: [String!]): Metadata
-
- """Type of the shipping method."""
- type: ShippingMethodTypeEnum @deprecated(reason: "This field will be removed in Saleor 4.0.")
-
- """Shipping method name."""
- name: String!
-
- """
- Shipping method description.
-
- Rich text format. For reference see https://editorjs.io/
- """
- description: JSONString
-
- """Maximum delivery days for this shipping method."""
- maximumDeliveryDays: Int
-
- """Minimum delivery days for this shipping method."""
- minimumDeliveryDays: Int
-
- """Maximum order weight for this shipping method."""
- maximumOrderWeight: Weight @deprecated(reason: "This field will be removed in Saleor 4.0.")
-
- """Minimum order weight for this shipping method."""
- minimumOrderWeight: Weight @deprecated(reason: "This field will be removed in Saleor 4.0.")
-
- """Returns translated shipping method fields for the given language code."""
- translation(
- """A language code to return the translation for shipping method."""
- languageCode: LanguageCodeEnum!
- ): ShippingMethodTranslation
-
- """The price of selected shipping method."""
- price: Money!
-
- """Maximum order price for this shipping method."""
- maximumOrderPrice: Money
-
- """Minimal order price for this shipping method."""
- minimumOrderPrice: Money
-
- """Describes if this shipping method is active and can be selected."""
- active: Boolean!
-
- """Message connected to this shipping method."""
- message: String
-}
-
input CountryFilterInput {
"""
Boolean for filtering countries by having shipping zone assigned.If 'true', return countries with shipping zone assigned.If 'false', return countries without any shipping zone assigned.If the argument is not provided (null), return all countries.
diff --git a/saleor/graphql/shipping/dataloaders.py b/saleor/graphql/shipping/dataloaders.py
index 874ab11534..65c1acadb9 100644
--- a/saleor/graphql/shipping/dataloaders.py
+++ b/saleor/graphql/shipping/dataloaders.py
@@ -1,6 +1,6 @@
from collections import defaultdict
-from django.db.models import F
+from django.db.models import Exists, F, OuterRef
from ...channel.models import Channel
from ...shipping.models import (
@@ -32,6 +32,33 @@ class ShippingZoneByIdLoader(DataLoader):
return [shipping_zones.get(shipping_zone_id) for shipping_zone_id in keys]
+class ShippingZonesByChannelIdLoader(DataLoader):
+ context_key = "shippingzone_by_channel_id"
+
+ def batch_load(self, keys):
+ shipping_zones_channel = ShippingZone.channels.through.objects.using(
+ self.database_connection_name
+ ).filter(channel_id__in=keys)
+ shipping_zones_map = (
+ ShippingZone.objects.using(self.database_connection_name)
+ .filter(
+ Exists(shipping_zones_channel.filter(shippingzone_id=OuterRef("pk")))
+ )
+ .in_bulk()
+ )
+
+ shipping_zones_by_channel_map = defaultdict(list)
+ for shipping_zone_id, channel_id in shipping_zones_channel.values_list(
+ "shippingzone_id", "channel_id"
+ ):
+ shipping_zones_by_channel_map[channel_id].append(
+ shipping_zones_map[shipping_zone_id]
+ )
+ return [
+ shipping_zones_by_channel_map.get(channel_id, []) for channel_id in keys
+ ]
+
+
class ShippingMethodsByShippingZoneIdLoader(DataLoader):
context_key = "shippingmethod_by_shippingzone"
diff --git a/saleor/graphql/shipping/types.py b/saleor/graphql/shipping/types.py
index 03eaa2ba5f..212f58b924 100644
--- a/saleor/graphql/shipping/types.py
+++ b/saleor/graphql/shipping/types.py
@@ -7,6 +7,7 @@ from ...core.weight import convert_weight_to_default_weight_unit
from ...product import models as product_models
from ...shipping import models
from ...shipping.interface import ShippingMethodData
+from ..account.enums import CountryCodeEnum
from ..channel import ChannelQsContext
from ..channel.dataloaders import ChannelByIdLoader
from ..channel.types import (
@@ -17,7 +18,12 @@ from ..channel.types import (
ChannelContextTypeWithMetadataForObjectType,
)
from ..core.connection import CountableConnection, create_connection_slice
-from ..core.descriptions import DEPRECATED_IN_3X_FIELD, RICH_CONTENT
+from ..core.descriptions import (
+ ADDED_IN_36,
+ DEPRECATED_IN_3X_FIELD,
+ PREVIEW_FEATURE,
+ RICH_CONTENT,
+)
from ..core.fields import ConnectionField, JSONString, PermissionsField
from ..core.types import (
CountryDisplay,
@@ -365,3 +371,19 @@ class ShippingMethod(graphene.ObjectType):
class ShippingZoneCountableConnection(CountableConnection):
class Meta:
node = ShippingZone
+
+
+class ShippingMethodsPerCountry(graphene.ObjectType):
+ country_code = graphene.Field(
+ CountryCodeEnum, required=True, description="The country code."
+ )
+ shipping_methods = NonNullList(
+ ShippingMethod, description="List of available shipping methods."
+ )
+
+ class Meta:
+ description = (
+ "List of shipping methods available for the country."
+ + ADDED_IN_36
+ + PREVIEW_FEATURE
+ )