Skip to content

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

Initial setup

Adam Janikadc38234db07
diff --git a/saleor/graphql/api.py b/saleor/graphql/api.py
index 78b3d22d4c..a2f57c2454 100644
--- a/saleor/graphql/api.py
+++ b/saleor/graphql/api.py
@@ -29,6 +29,7 @@ from .core.types import Shop
from .order.filters import OrderFilter
from .order.resolvers import resolve_order, resolve_orders
from .order.types import Order
+from .order.mutations import DraftOrderCreate
from .page.resolvers import resolve_pages, resolve_page
from .page.types import Page
from .page.mutations import PageCreate, PageDelete, PageUpdate
@@ -276,6 +277,8 @@ class Mutations(graphene.ObjectType):
menu_item_delete = MenuItemDelete.Field()
menu_item_update = MenuItemUpdate.Field()
+ draft_order_create = DraftOrderCreate.Field()
+
page_create = PageCreate.Field()
page_delete = PageDelete.Field()
page_update = PageUpdate.Field()
diff --git a/saleor/graphql/order/mutations.py b/saleor/graphql/order/mutations.py
new file mode 100644
index 0000000000..20ec455695
--- /dev/null
+++ b/saleor/graphql/order/mutations.py
@@ -0,0 +1,56 @@
+import graphene
+from graphene.types import InputObjectType
+
+from ..core.mutations import BaseMutation
+from ..core.types import Decimal
+
+
+class AddressInput(graphene.InputObjectType):
+ first_name = graphene.String(description='Given name.')
+ last_name = graphene.String(description='Family name.')
+ company_name = graphene.String(description='Company or organization.')
+ street_address_1 = graphene.String(description='Address.')
+ street_address_2 = graphene.String(description='Address.')
+ city = graphene.String(description='City.')
+ city_area = graphene.String(description='District.')
+ postal_code = graphene.String(description='Postal code.')
+ country = graphene.String(description='Country.')
+ country_area = graphene.String(description='State or province.')
+ phone = graphene.String(description='Phone number.')
+ email = graphene.String(description='Email address.')
+
+
+class LineInput(graphene.InputObjectType):
+ variant_id = graphene.ID(description='Product variant ID.')
+ quantity = graphene.Int(
+ description='The number of products in the order.')
+
+ class Meta:
+ description = 'Represents a permission object in a friendly form.'
+
+class DraftOrderInput(InputObjectType):
+ billing_address = AddressInput(
+ description='Address associated with the payment.')
+ customer_id = graphene.ID(
+ descripton='Customer associated with the draft order.')
+ email = graphene.String(description='Email address of the customer.')
+ discount = Decimal(description='Discount amount for the order.')
+ lines = graphene.List(
+ LineInput,
+ description="""Variant line input consisting of variant ID
+ and quantity of products.""")
+ shipping_address = AddressInput(
+ description='Address to where the order will be shipped.')
+ shipping_method_id = graphene.ID('ID of a selected shipping method.')
+ voucher = graphene.ID(
+ description='ID of the voucher associated with the order')
+
+
+class DraftOrderCreate(BaseMutation):
+ class Arguments:
+ input = DraftOrderInput(required=True)
+
+
+ @classmethod
+ def mutate(cls, root, info, input):
+ pass