Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add orders resolving to invoiceRequest mutation
Tomasz Szymanski5f5605732649
diff --git a/saleor/graphql/invoice/mutations.py b/saleor/graphql/invoice/mutations.pyindex 068756af22..b7b84c25d4 100644--- a/saleor/graphql/invoice/mutations.py+++ b/saleor/graphql/invoice/mutations.py@@ -14,6 +14,8 @@ from ..order.types import Orderclass InvoiceRequest(ModelMutation):+ order = graphene.Field(Order, description="Order related to an invoice.")+class Meta:description = "Request an invoice for the order using plugin."model = models.Invoice@@ -68,7 +70,7 @@ class InvoiceRequest(ModelMutation):user=info.context.user, order=order, number=data.get("number"))invoice.refresh_from_db()- return InvoiceRequest(invoice=invoice)+ return InvoiceRequest(invoice=invoice, order=order)class InvoiceCreateInput(graphene.InputObjectType):diff --git a/saleor/graphql/invoice/tests/test_invoice_request.py b/saleor/graphql/invoice/tests/test_invoice_request.pyindex 09478dacb1..7180e7fae9 100644--- a/saleor/graphql/invoice/tests/test_invoice_request.py+++ b/saleor/graphql/invoice/tests/test_invoice_request.py@@ -14,6 +14,9 @@ INVOICE_REQUEST_MUTATION = """orderId: $orderIdnumber: $number) {+ order {+ id+ }invoice {statusnumber@@ -33,8 +36,9 @@ def test_invoice_request(plugin_mock, staff_api_client, permission_manage_orders, order):number = "01/12/2020/TEST"+ graphene_order_id = graphene.Node.to_global_id("Order", order.pk)variables = {- "orderId": graphene.Node.to_global_id("Order", order.pk),+ "orderId": graphene_order_id,"number": number,}response = staff_api_client.post_graphql(@@ -56,6 +60,7 @@ def test_invoice_request(content["data"]["invoiceRequest"]["invoice"]["status"]== JobStatus.PENDING.upper())+ assert content["data"]["invoiceRequest"]["order"]["id"] == graphene_order_iddef test_invoice_request_draft_order(staff_api_client, permission_manage_orders, order):diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 7d77bac539..bcf407000c 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -2006,6 +2006,7 @@ enum InvoiceErrorCode {type InvoiceRequest {errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")+ order: OrderinvoiceErrors: [InvoiceError!]!invoice: Invoice}