Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Drop uneeded union type (#18110)
Maciej Korycinski39b4138e8550
diff --git a/saleor/graphql/api.py b/saleor/graphql/api.pyindex 63891f01a8..d1322bc736 100644--- a/saleor/graphql/api.py+++ b/saleor/graphql/api.py@@ -33,7 +33,7 @@ from .menu.schema import MenuMutations, MenuQueriesfrom .meta.schema import MetaMutationsfrom .order.schema import OrderMutations, OrderQueriesfrom .page.schema import PageMutations, PageQueries-from .payment.schema import PaymentMutations, PaymentQueries+from .payment.schema import PAYMENT_ADDITIONAL_TYPES, PaymentMutations, PaymentQueriesfrom .plugins.schema import PluginsMutations, PluginsQueriesfrom .product.schema import ProductMutations, ProductQueriesfrom .shipping.schema import ShippingMutations, ShippingQueries@@ -176,7 +176,7 @@ GraphQLWebhookEventsInfoDirective = graphql.GraphQLDirective(schema = build_federated_schema(Query,mutation=Mutation,- types=unit_enums + list(WEBHOOK_TYPES_MAP.values()),+ types=unit_enums + list(WEBHOOK_TYPES_MAP.values()) + PAYMENT_ADDITIONAL_TYPES,subscription=Subscription,directives=graphql.specified_directives+ [GraphQLDocDirective, GraphQLWebhookEventsInfoDirective],diff --git a/saleor/graphql/payment/schema.py b/saleor/graphql/payment/schema.pyindex 4bc51b4aba..5e03c42118 100644--- a/saleor/graphql/payment/schema.py+++ b/saleor/graphql/payment/schema.py@@ -28,7 +28,18 @@ from .mutations import (TransactionUpdate,)from .resolvers import resolve_payment_by_id, resolve_payments, resolve_transaction-from .types import Payment, PaymentCountableConnection, TransactionItem+from .types import (+ CardPaymentMethodDetails,+ OtherPaymentMethodDetails,+ Payment,+ PaymentCountableConnection,+ TransactionItem,+)++PAYMENT_ADDITIONAL_TYPES = [+ CardPaymentMethodDetails,+ OtherPaymentMethodDetails,+]class PaymentQueries(graphene.ObjectType):diff --git a/saleor/graphql/payment/tests/queries/test_transaction.py b/saleor/graphql/payment/tests/queries/test_transaction.pyindex b7f172b282..4d5dc49d3f 100644--- a/saleor/graphql/payment/tests/queries/test_transaction.py+++ b/saleor/graphql/payment/tests/queries/test_transaction.py@@ -94,9 +94,7 @@ TRANSACTION_QUERY = """}paymentMethodDetails{__typename- ...on GenericPaymentMethodDetails{- name- }+ name...on CardPaymentMethodDetails{namebranddiff --git a/saleor/graphql/payment/types.py b/saleor/graphql/payment/types.pyindex f636304fc8..cb30c81fbb 100644--- a/saleor/graphql/payment/types.py+++ b/saleor/graphql/payment/types.py@@ -430,7 +430,7 @@ class TransactionEvent(ModelObjectType[models.TransactionEvent]):return None-class GenericPaymentMethodDetails(graphene.Interface):+class PaymentMethodDetails(graphene.Interface):name = graphene.String(required=True, description="Name of the payment method.")class Meta:@@ -438,6 +438,13 @@ class GenericPaymentMethodDetails(graphene.Interface):"Represents a payment method used for a transaction." + ADDED_IN_322)+ @classmethod+ def resolve_type(cls, instance, info: graphene.ResolveInfo):+ if instance.payment_method_type == PaymentMethodType.CARD:+ return CardPaymentMethodDetails+ return OtherPaymentMethodDetails++ @staticmethoddef resolve_name(root: models.TransactionItem, _info):return root.payment_method_name or ""@@ -464,7 +471,7 @@ class CardPaymentMethodDetails(BaseObjectType):description = ("Represents a card payment method used for a transaction." + ADDED_IN_322)- interfaces = [GenericPaymentMethodDetails]+ interfaces = [PaymentMethodDetails]@staticmethoddef resolve_brand(root: models.TransactionItem, _info):@@ -494,18 +501,7 @@ class OtherPaymentMethodDetails(BaseObjectType):description = ("Represents a payment method used for a transaction." + ADDED_IN_322)- interfaces = [GenericPaymentMethodDetails]---class PaymentMethodDetails(graphene.Union):- class Meta:- types = (CardPaymentMethodDetails, OtherPaymentMethodDetails)-- @classmethod- def resolve_type(cls, instance, info: graphene.ResolveInfo):- if instance.payment_method_type == PaymentMethodType.CARD:- return CardPaymentMethodDetails- return OtherPaymentMethodDetails+ interfaces = [PaymentMethodDetails]class TransactionItem(ModelObjectType[models.TransactionItem]):diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex ac891ff3b0..45879866e3 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -12409,49 +12409,12 @@ enum TransactionEventTypeEnum @doc(category: "Payments") {union UserOrApp = User | App-union PaymentMethodDetails = CardPaymentMethodDetails | OtherPaymentMethodDetails--"""-Represents a card payment method used for a transaction.--Added in Saleor 3.22.-"""-type CardPaymentMethodDetails implements GenericPaymentMethodDetails {- """Name of the payment method."""- name: String!-- """Card brand."""- brand: String-- """First 4 digits of the card number."""- firstDigits: String-- """Last 4 digits of the card number."""- lastDigits: String-- """Two-digit number representing the card’s expiration month."""- expMonth: Int-- """Four-digit number representing the card’s expiration year."""- expYear: Int-}--"""-Represents a payment method used for a transaction.--Added in Saleor 3.22.-"""-interface GenericPaymentMethodDetails {- """Name of the payment method."""- name: String!-}-"""Represents a payment method used for a transaction.Added in Saleor 3.22."""-type OtherPaymentMethodDetails implements GenericPaymentMethodDetails {+interface PaymentMethodDetails {"""Name of the payment method."""name: String!}@@ -34468,6 +34431,41 @@ type PaymentMethodProcessTokenizationSession implements Event @doc(category: "Paid: String!}+"""+Represents a card payment method used for a transaction.++Added in Saleor 3.22.+"""+type CardPaymentMethodDetails implements PaymentMethodDetails {+ """Name of the payment method."""+ name: String!++ """Card brand."""+ brand: String++ """First 4 digits of the card number."""+ firstDigits: String++ """Last 4 digits of the card number."""+ lastDigits: String++ """Two-digit number representing the card’s expiration month."""+ expMonth: Int++ """Four-digit number representing the card’s expiration year."""+ expYear: Int+}++"""+Represents a payment method used for a transaction.++Added in Saleor 3.22.+"""+type OtherPaymentMethodDetails implements PaymentMethodDetails {+ """Name of the payment method."""+ name: String!+}+"""_Any value scalar as defined by Federation spec."""scalar _Any