Skip to content

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

Drop top-level checkoutLine query with related resolver (#7623)

Dawid Matuszczyk7b87f1aef1e5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1481ea3fae..b405f9a2a0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -226,6 +226,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Unify checkout identifier in checkout mutations and queries - #7511 by @IKarbowiak
- Use root level channel argument for filtering and sorting - #7374 by @IKarbowiak
- drop `channel` field from filters and sorters
+- Drop top-level `checkoutLine` query from the schema with related resolver, use `checkout` query instead - #7623 by @dexon44
### Other
diff --git a/saleor/graphql/checkout/resolvers.py b/saleor/graphql/checkout/resolvers.py
index 8efd8234db..00058f003a 100644
--- a/saleor/graphql/checkout/resolvers.py
+++ b/saleor/graphql/checkout/resolvers.py
@@ -4,10 +4,6 @@ from ...core.tracing import traced_resolver
from ..utils import get_user_or_app_from_context
-def resolve_checkout_line(id):
- return models.CheckoutLine.objects.filter(id=id).first()
-
-
def resolve_checkout_lines():
queryset = models.CheckoutLine.objects.all()
return queryset
diff --git a/saleor/graphql/checkout/schema.py b/saleor/graphql/checkout/schema.py
index 8abf652179..318a02f3cb 100644
--- a/saleor/graphql/checkout/schema.py
+++ b/saleor/graphql/checkout/schema.py
@@ -4,7 +4,6 @@ from ...core.permissions import CheckoutPermissions
from ...core.tracing import traced_resolver
from ..core.fields import BaseDjangoConnectionField, PrefetchingConnectionField
from ..core.scalars import UUID
-from ..core.utils import from_global_id_or_error
from ..decorators import permission_required
from ..payment.mutations import CheckoutPaymentCreate
from .mutations import (
@@ -23,12 +22,7 @@ from .mutations import (
CheckoutShippingAddressUpdate,
CheckoutShippingMethodUpdate,
)
-from .resolvers import (
- resolve_checkout,
- resolve_checkout_line,
- resolve_checkout_lines,
- resolve_checkouts,
-)
+from .resolvers import resolve_checkout, resolve_checkout_lines, resolve_checkouts
from .types import Checkout, CheckoutLine
@@ -46,11 +40,6 @@ class CheckoutQueries(graphene.ObjectType):
description="Slug of a channel for which the data should be returned."
),
)
- checkout_line = graphene.Field(
- CheckoutLine,
- id=graphene.Argument(graphene.ID, description="ID of the checkout line."),
- description="Look up a checkout line by ID.",
- )
checkout_lines = PrefetchingConnectionField(
CheckoutLine, description="List of checkout lines."
)
@@ -63,10 +52,6 @@ class CheckoutQueries(graphene.ObjectType):
def resolve_checkouts(self, *_args, channel=None, **_kwargs):
return resolve_checkouts(channel)
- def resolve_checkout_line(self, info, id):
- _, id = from_global_id_or_error(id, CheckoutLine)
- return resolve_checkout_line(id)
-
@permission_required(CheckoutPermissions.MANAGE_CHECKOUTS)
@traced_resolver
def resolve_checkout_lines(self, *_args, **_kwargs):
diff --git a/saleor/graphql/checkout/tests/test_checkout.py b/saleor/graphql/checkout/tests/test_checkout.py
index f8bb28ee20..76500b7ed3 100644
--- a/saleor/graphql/checkout/tests/test_checkout.py
+++ b/saleor/graphql/checkout/tests/test_checkout.py
@@ -32,11 +32,7 @@ from ....plugins.tests.sample_plugins import ActiveDummyPaymentGateway
from ....product.models import ProductChannelListing, ProductVariant
from ....shipping import models as shipping_models
from ....warehouse.models import Stock
-from ...tests.utils import (
- assert_no_permission,
- get_graphql_content,
- get_graphql_content_from_response,
-)
+from ...tests.utils import assert_no_permission, get_graphql_content
from ..mutations import (
clean_shipping_method,
update_checkout_shipping_method_if_invalid,
@@ -2365,44 +2361,6 @@ def test_checkout_shipping_method_update_shipping_zone_with_channel(
assert checkout.shipping_method == shipping_method
-QUERY_CHECKOUT_LINE_BY_ID = """
- query checkoutLine($id: ID) {
- checkoutLine(id: $id) {
- id
- }
- }
-"""
-
-
-def test_query_checkout_line(checkout_with_item, user_api_client):
- query = QUERY_CHECKOUT_LINE_BY_ID
- checkout = checkout_with_item
- line = checkout.lines.first()
- line_id = graphene.Node.to_global_id("CheckoutLine", line.pk)
- variables = {"id": line_id}
- response = user_api_client.post_graphql(query, variables)
- content = get_graphql_content(response)
- received_id = content["data"]["checkoutLine"]["id"]
- assert received_id == line_id
-
-
-def test_query_checkout_line_by_invalid_id(staff_api_client, page_type):
- id = "bh/"
- variables = {"id": id}
- response = staff_api_client.post_graphql(QUERY_CHECKOUT_LINE_BY_ID, variables)
- content = get_graphql_content_from_response(response)
- assert len(content["errors"]) == 1
- assert content["errors"][0]["message"] == f"Couldn't resolve id: {id}."
- assert content["data"]["checkoutLine"] is None
-
-
-def test_query_checkout_line_with_invalid_object_type(staff_api_client, page_type):
- variables = {"id": graphene.Node.to_global_id("Order", page_type.pk)}
- response = staff_api_client.post_graphql(QUERY_CHECKOUT_LINE_BY_ID, variables)
- content = get_graphql_content(response)
- assert content["data"]["checkoutLine"] is None
-
-
def test_query_checkouts(
checkout_with_item, staff_api_client, permission_manage_checkouts
):
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 3b53598114..d8fe7db5d8 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -4776,7 +4776,6 @@ type Query {
taxTypes: [TaxType]
checkout(token: UUID): Checkout
checkouts(channel: String, before: String, after: String, first: Int, last: Int): CheckoutCountableConnection
- checkoutLine(id: ID): CheckoutLine
checkoutLines(before: String, after: String, first: Int, last: Int): CheckoutLineCountableConnection
channel(id: ID): Channel
channels: [Channel!]