Skip to content

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

Remove deprecated code from payment and product schema

IKarbowiakf228f93c0021
diff --git a/saleor/graphql/payment/schema.py b/saleor/graphql/payment/schema.py
index 3bb2faee9d..d1813986ef 100644
--- a/saleor/graphql/payment/schema.py
+++ b/saleor/graphql/payment/schema.py
@@ -4,7 +4,7 @@ from ...core.permissions import OrderPermissions
from ..core.fields import PrefetchingConnectionField
from ..decorators import permission_required
from .mutations import PaymentCapture, PaymentRefund, PaymentSecureConfirm, PaymentVoid
-from .resolvers import resolve_client_token, resolve_payments
+from .resolvers import resolve_payments
from .types import Payment
@@ -17,14 +17,6 @@ class PaymentQueries(graphene.ObjectType):
),
)
payments = PrefetchingConnectionField(Payment, description="List of payments.")
- payment_client_token = graphene.Field(
- graphene.String,
- gateway=graphene.String(required=True, description="A payment gateway."),
- deprecation_reason=(
- "DEPRECATED: Will be removed in Saleor 2.10, "
- "use payment gateway config instead in availablePaymentGateways."
- ),
- )
@permission_required(OrderPermissions.MANAGE_ORDERS)
def resolve_payment(self, info, **data):
@@ -34,9 +26,6 @@ class PaymentQueries(graphene.ObjectType):
def resolve_payments(self, info, query=None, **_kwargs):
return resolve_payments(info, query)
- def resolve_payment_client_token(self, info, gateway, **_kwargs):
- return resolve_client_token(info.context.user, gateway)
-
class PaymentMutations(graphene.ObjectType):
payment_capture = PaymentCapture.Field()
diff --git a/saleor/graphql/product/schema.py b/saleor/graphql/product/schema.py
index 9c2a51629c..09f4b204fd 100644
--- a/saleor/graphql/product/schema.py
+++ b/saleor/graphql/product/schema.py
@@ -111,7 +111,6 @@ from .resolvers import (
resolve_products,
resolve_report_product_sales,
)
-from .scalars import AttributeScalar
from .sorters import (
AttributeSortingInput,
CategorySortingInput,
@@ -197,27 +196,6 @@ class ProductQueries(graphene.ObjectType):
products = FilterInputConnectionField(
Product,
filter=ProductFilterInput(description="Filtering options for products."),
- attributes=graphene.List(
- AttributeScalar,
- description=(
- "Filter products by attributes. DEPRECATED: Will be removed in "
- "Saleor 2.10, use the `filter` field instead."
- ),
- ),
- categories=graphene.List(
- graphene.ID,
- description=(
- "Filter products by category. DEPRECATED: Will be removed in "
- "Saleor 2.10, use the `filter` field instead."
- ),
- ),
- collections=graphene.List(
- graphene.ID,
- description=(
- "Filter products by collections. DEPRECATED: Will be removed in "
- "Saleor 2.10, use the `filter` field instead."
- ),
- ),
sort_by=ProductOrder(description="Sort products."),
stock_availability=graphene.Argument(
StockAvailability, description="Filter products by stock availability."
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 14fe2a5fc3..6b8303b3d1 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -301,8 +301,6 @@ type AttributeReorderValues {
productErrors: [ProductError!]
}
-scalar AttributeScalar
-
enum AttributeSortField {
NAME
SLUG
@@ -3495,7 +3493,7 @@ type Query {
collection(id: ID!): Collection
collections(filter: CollectionFilterInput, sortBy: CollectionSortingInput, query: String, before: String, after: String, first: Int, last: Int): CollectionCountableConnection
product(id: ID!): Product
- products(filter: ProductFilterInput, attributes: [AttributeScalar], categories: [ID], collections: [ID], sortBy: ProductOrder, stockAvailability: StockAvailability, query: String, before: String, after: String, first: Int, last: Int): ProductCountableConnection
+ products(filter: ProductFilterInput, sortBy: ProductOrder, stockAvailability: StockAvailability, query: String, before: String, after: String, first: Int, last: Int): ProductCountableConnection
productType(id: ID!): ProductType
productTypes(filter: ProductTypeFilterInput, query: String, sortBy: ProductTypeSortingInput, before: String, after: String, first: Int, last: Int): ProductTypeCountableConnection
productVariant(id: ID!): ProductVariant
@@ -3503,7 +3501,6 @@ type Query {
reportProductSales(period: ReportingPeriod!, before: String, after: String, first: Int, last: Int): ProductVariantCountableConnection
payment(id: ID!): Payment
payments(before: String, after: String, first: Int, last: Int): PaymentCountableConnection
- paymentClientToken(gateway: String!): String @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.10, use payment gateway config instead in availablePaymentGateways.")
page(id: ID, slug: String): Page
pages(query: String, sortBy: PageSortingInput, filter: PageFilterInput, before: String, after: String, first: Int, last: Int): PageCountableConnection
homepageEvents(before: String, after: String, first: Int, last: Int): OrderEventCountableConnection
diff --git a/tests/api/test_graphql.py b/tests/api/test_graphql.py
index 00471a0f67..94f4998a43 100644
--- a/tests/api/test_graphql.py
+++ b/tests/api/test_graphql.py
@@ -80,18 +80,16 @@ def test_real_query(user_api_client, product):
product_attr = product.product_type.product_attributes.first()
category = product.category
attr_value = product_attr.values.first()
- filter_by = "%s:%s" % (product_attr.slug, attr_value.slug)
query = """
query Root($categoryId: ID!, $sortBy: ProductOrder, $first: Int,
- $attributesFilter: [AttributeScalar], $minPrice: Float, $maxPrice: Float) {
+ $attributesFilter: [AttributeInput], $minPrice: Float, $maxPrice: Float) {
category(id: $categoryId) {
...CategoryPageFragmentQuery
__typename
}
- products(first: $first, sortBy: $sortBy, categories:[$categoryId],
- attributes: $attributesFilter,
- filter: {price: {gte: $minPrice, lte: $maxPrice}}) {
+ products(first: $first, sortBy: $sortBy, filter: {categories: [$categoryId],
+ attributes: $attributesFilter, price: {gte: $minPrice, lte: $maxPrice}}) {
...ProductListFragmentQuery
__typename
@@ -219,7 +217,9 @@ def test_real_query(user_api_client, product):
"categoryId": graphene.Node.to_global_id("Category", category.id),
"sortBy": {"field": "NAME", "direction": "ASC"},
"first": 1,
- "attributesFilter": [filter_by],
+ "attributesFilter": [
+ {"slug": f"{product_attr.slug}", "value": f"{attr_value.slug}"}
+ ],
}
response = user_api_client.post_graphql(query, variables)
get_graphql_content(response)
diff --git a/tests/api/test_product.py b/tests/api/test_product.py
index 0a30f54b8f..7c21ca1192 100644
--- a/tests/api/test_product.py
+++ b/tests/api/test_product.py
@@ -517,7 +517,7 @@ def test_filter_product_by_category(user_api_client, product):
category = product.category
query = """
query getProducts($categoryId: ID) {
- products(categories: [$categoryId], first: 1) {
+ products(filter: {categories: [$categoryId]}, first: 1) {
edges {
node {
name
@@ -588,10 +588,10 @@ def test_fetch_unpublished_product_anonymous_user(api_client, unavailable_produc
def test_filter_products_by_attributes(user_api_client, product):
product_attr = product.product_type.product_attributes.first()
attr_value = product_attr.values.first()
- filter_by = "%s:%s" % (product_attr.slug, attr_value.slug)
query = """
query {
- products(attributes: ["%(filter_by)s"], first: 1) {
+ products(filter:
+ {attributes: {slug: "%(slug)s", value: "%(value)s"}}, first: 1) {
edges {
node {
name
@@ -600,7 +600,8 @@ def test_filter_products_by_attributes(user_api_client, product):
}
}
""" % {
- "filter_by": filter_by
+ "slug": product_attr.slug,
+ "value": attr_value.slug,
}
response = user_api_client.post_graphql(query)
@@ -616,10 +617,10 @@ def test_filter_products_by_wrong_attributes(user_api_client, product):
attr_value = (
product.product_type.variant_attributes.get(slug="size").values.first().id
)
- filter_by = "%s:%s" % (product_attr.slug, attr_value)
query = """
query {
- products(attributes: ["%(filter_by)s"], first: 1) {
+ products(filter:
+ {attributes: {slug: "%(slug)s", value: "%(value)s"}}, first: 1) {
edges {
node {
name
@@ -628,7 +629,8 @@ def test_filter_products_by_wrong_attributes(user_api_client, product):
}
}
""" % {
- "filter_by": filter_by
+ "slug": product_attr.slug,
+ "value": attr_value,
}
response = user_api_client.post_graphql(query)
@@ -644,7 +646,7 @@ def test_filter_products_by_categories(user_api_client, categories_tree, product
product.save()
query = """
query {
- products(categories: ["%(category_id)s"], first: 1) {
+ products(filter: {categories: ["%(category_id)s"]}, first: 1) {
edges {
node {
name
@@ -665,7 +667,7 @@ def test_filter_products_by_collections(user_api_client, collection, product):
collection.products.add(product)
query = """
query {
- products(collections: ["%(collection_id)s"], first: 1) {
+ products(filter: {collections: ["%(collection_id)s"]}, first: 1) {
edges {
node {
name