prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Add query to fetch draft orders
  In the Dashboard 2.0 we want to have separate links to view draft orders and confirmed ones. For that reason we need to add a separate resolver to return only draft orders. Exiting `orders` resolver should be changed to return confirmed orders.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `saleor/graphql/order/resolvers.py`
  Content:
  ```
  1 import graphene
  2 import graphene_django_optimizer as gql_optimizer
  3 
  4 from ...order import OrderEvents, OrderStatus, models
  5 from ...order.utils import sum_order_totals
  6 from ..utils import filter_by_period, filter_by_query_param
  7 from .enums import OrderStatusFilter
  8 from .types import Order
  9 from .utils import applicable_shipping_methods
  10 
  11 ORDER_SEARCH_FIELDS = (
  12     'id', 'discount_name', 'token', 'user_email', 'user__email')
  13 
  14 
  15 def resolve_orders(info, created, status, query):
  16     user = info.context.user
  17     if user.has_perm('order.manage_orders'):
  18         qs = models.Order.objects.all()
  19     else:
  20         qs = user.orders.confirmed()
  21     qs = filter_by_query_param(qs, query, ORDER_SEARCH_FIELDS)
  22 
  23     # filter orders by status
  24     if status is not None:
  25         if status == OrderStatusFilter.READY_TO_FULFILL:
  26             qs = qs.ready_to_fulfill()
  27         elif status == OrderStatusFilter.READY_TO_CAPTURE:
  28             qs = qs.ready_to_capture()
  29 
  30     # filter orders by creation date
  31     if created is not None:
  32         qs = filter_by_period(qs, created, 'created')
  33 
  34     return gql_optimizer.query(qs, info)
  35 
  36 
  37 def resolve_orders_total(info, period):
  38     qs = models.Order.objects.confirmed().exclude(status=OrderStatus.CANCELED)
  39     qs = filter_by_period(qs, period, 'created')
  40     return sum_order_totals(qs)
  41 
  42 
  43 def resolve_order(info, id):
  44     """Return order only for user assigned to it or proper staff user."""
  45     user = info.context.user
  46     order = graphene.Node.get_node_from_global_id(info, id, Order)
  47     if user.has_perm('order.manage_orders') or order.user == user:
  48         return order
  49     return None
  50 
  51 
  52 def resolve_shipping_methods(obj, info, price):
  53     return applicable_shipping_methods(obj, info, price)
  54 
  55 
  56 def resolve_homepage_events(info):
  57     # Filter only selected events to be displayed on homepage.
  58     types = [
  59         OrderEvents.PLACED.value, OrderEvents.PLACED_FROM_DRAFT.value,
  60         OrderEvents.ORDER_FULLY_PAID.value]
  61     return models.OrderEvent.objects.filter(type__in=types)
  62 
  63 
  64 def resolve_order_by_token(info, token):
  65     return models.Order.objects.filter(token=token).first()
  66
  ```
  
  Path: `saleor/graphql/order/schema.py`
  Content:
  ```
  1 from textwrap import dedent
  2 
  3 import graphene
  4 from graphql_jwt.decorators import login_required, permission_required
  5 
  6 from ..core.enums import ReportingPeriod
  7 from ..core.fields import PrefetchingConnectionField
  8 from ..core.types import TaxedMoney
  9 from ..descriptions import DESCRIPTIONS
  10 from .bulk_mutations.draft_orders import DraftOrderBulkDelete
  11 from .enums import OrderStatusFilter
  12 from .mutations.draft_orders import (
  13     DraftOrderComplete, DraftOrderCreate, DraftOrderDelete,
  14     DraftOrderLineDelete, DraftOrderLinesCreate, DraftOrderLineUpdate,
  15     DraftOrderUpdate)
  16 from .mutations.fulfillments import (
  17     FulfillmentCancel, FulfillmentCreate, FulfillmentUpdateTracking)
  18 from .mutations.orders import (
  19     OrderAddNote, OrderCancel, OrderCapture, OrderMarkAsPaid, OrderRefund,
  20     OrderUpdate, OrderUpdateShipping, OrderVoid)
  21 from .resolvers import (
  22     resolve_homepage_events, resolve_order, resolve_order_by_token,
  23     resolve_orders, resolve_orders_total)
  24 from .types import Order, OrderEvent
  25 
  26 
  27 class OrderQueries(graphene.ObjectType):
  28     homepage_events = PrefetchingConnectionField(
  29         OrderEvent, description=dedent('''List of activity events to display on
  30         homepage (at the moment it only contains order-events).'''))
  31     order = graphene.Field(
  32         Order, description='Lookup an order by ID.',
  33         id=graphene.Argument(graphene.ID, required=True))
  34     orders = PrefetchingConnectionField(
  35         Order,
  36         query=graphene.String(description=DESCRIPTIONS['order']),
  37         created=graphene.Argument(
  38             ReportingPeriod,
  39             description='Filter orders from a selected timespan.'),
  40         status=graphene.Argument(
  41             OrderStatusFilter, description='Filter order by status'),
  42         description='List of the shop\'s orders.')
  43     orders_total = graphene.Field(
  44         TaxedMoney, description='Total sales.',
  45         period=graphene.Argument(
  46             ReportingPeriod,
  47             description='Get total sales for selected span of time.'))
  48     order_by_token = graphene.Field(
  49         Order, description='Lookup an order by token.',
  50         token=graphene.Argument(graphene.String, required=True))
  51 
  52     @permission_required('order.manage_orders')
  53     def resolve_homepage_events(self, info, **kwargs):
  54         return resolve_homepage_events(info)
  55 
  56     @login_required
  57     def resolve_order(self, info, id):
  58         return resolve_order(info, id)
  59 
  60     @login_required
  61     def resolve_orders(
  62             self, info, created=None, status=None, query=None, **kwargs):
  63         return resolve_orders(info, created, status, query)
  64 
  65     @permission_required('order.manage_orders')
  66     def resolve_orders_total(self, info, period, **kwargs):
  67         return resolve_orders_total(info, period)
  68 
  69     def resolve_order_by_token(self, info, token):
  70         return resolve_order_by_token(info, token)
  71 
  72 
  73 class OrderMutations(graphene.ObjectType):
  74     draft_order_complete = DraftOrderComplete.Field()
  75     draft_order_create = DraftOrderCreate.Field()
  76     draft_order_delete = DraftOrderDelete.Field()
  77     draft_order_bulk_delete = DraftOrderBulkDelete.Field()
  78     draft_order_lines_create = DraftOrderLinesCreate.Field()
  79     draft_order_line_delete = DraftOrderLineDelete.Field()
  80     draft_order_line_update = DraftOrderLineUpdate.Field()
  81     draft_order_update = DraftOrderUpdate.Field()
  82 
  83     order_add_note = OrderAddNote.Field()
  84     order_cancel = OrderCancel.Field()
  85     order_capture = OrderCapture.Field()
  86     order_fulfillment_cancel = FulfillmentCancel.Field()
  87     order_fulfillment_create = FulfillmentCreate.Field()
  88     order_fulfillment_update_tracking = FulfillmentUpdateTracking.Field()
  89     order_mark_as_paid = OrderMarkAsPaid.Field()
  90     order_refund = OrderRefund.Field()
  91     order_update = OrderUpdate.Field()
  92     order_update_shipping = OrderUpdateShipping.Field()
  93     order_void = OrderVoid.Field()
  94
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/saleor/graphql/order/resolvers.py b/saleor/graphql/order/resolvers.py
  --- a/saleor/graphql/order/resolvers.py
  +++ b/saleor/graphql/order/resolvers.py
  @@ -12,12 +12,7 @@
       'id', 'discount_name', 'token', 'user_email', 'user__email')
   
   
  -def resolve_orders(info, created, status, query):
  -    user = info.context.user
  -    if user.has_perm('order.manage_orders'):
  -        qs = models.Order.objects.all()
  -    else:
  -        qs = user.orders.confirmed()
  +def filter_orders(qs, info, created, status, query):
       qs = filter_by_query_param(qs, query, ORDER_SEARCH_FIELDS)
   
       # filter orders by status
  @@ -34,6 +29,20 @@
       return gql_optimizer.query(qs, info)
   
   
  +def resolve_orders(info, created, status, query):
  +    user = info.context.user
  +    if user.has_perm('order.manage_orders'):
  +        qs = models.Order.objects.confirmed()
  +    else:
  +        qs = user.orders.confirmed()
  +    return filter_orders(qs, info, created, status, query)
  +
  +
  +def resolve_draft_orders(info, created, query):
  +    qs = models.Order.objects.drafts()
  +    return filter_orders(qs, info, created, None, query)
  +
  +
   def resolve_orders_total(info, period):
       qs = models.Order.objects.confirmed().exclude(status=OrderStatus.CANCELED)
       qs = filter_by_period(qs, period, 'created')
  diff --git a/saleor/graphql/order/schema.py b/saleor/graphql/order/schema.py
  --- a/saleor/graphql/order/schema.py
  +++ b/saleor/graphql/order/schema.py
  @@ -19,8 +19,8 @@
       OrderAddNote, OrderCancel, OrderCapture, OrderMarkAsPaid, OrderRefund,
       OrderUpdate, OrderUpdateShipping, OrderVoid)
   from .resolvers import (
  -    resolve_homepage_events, resolve_order, resolve_order_by_token,
  -    resolve_orders, resolve_orders_total)
  +    resolve_draft_orders, resolve_homepage_events, resolve_order,
  +    resolve_order_by_token, resolve_orders, resolve_orders_total)
   from .types import Order, OrderEvent
   
   
  @@ -40,6 +40,13 @@
           status=graphene.Argument(
               OrderStatusFilter, description='Filter order by status'),
           description='List of the shop\'s orders.')
  +    draft_orders = PrefetchingConnectionField(
  +        Order,
  +        query=graphene.String(description=DESCRIPTIONS['order']),
  +        created=graphene.Argument(
  +            ReportingPeriod,
  +            description='Filter draft orders from a selected timespan.'),
  +        description='List of the shop\'s draft orders.')
       orders_total = graphene.Field(
           TaxedMoney, description='Total sales.',
           period=graphene.Argument(
  @@ -62,6 +69,10 @@
               self, info, created=None, status=None, query=None, **kwargs):
           return resolve_orders(info, created, status, query)
   
  +    @permission_required('order.manage_orders')
  +    def resolve_draft_orders(self, info, created=None, query=None, **kwargs):
  +        return resolve_draft_orders(info, created, query)
  +
       @permission_required('order.manage_orders')
       def resolve_orders_total(self, info, period, **kwargs):
           return resolve_orders_total(info, period)
  
verification_info: {"golden_diff": "diff --git a/saleor/graphql/order/resolvers.py b/saleor/graphql/order/resolvers.py\n--- a/saleor/graphql/order/resolvers.py\n+++ b/saleor/graphql/order/resolvers.py\n@@ -12,12 +12,7 @@\n     'id', 'discount_name', 'token', 'user_email', 'user__email')\n \n \n-def resolve_orders(info, created, status, query):\n-    user = info.context.user\n-    if user.has_perm('order.manage_orders'):\n-        qs = models.Order.objects.all()\n-    else:\n-        qs = user.orders.confirmed()\n+def filter_orders(qs, info, created, status, query):\n     qs = filter_by_query_param(qs, query, ORDER_SEARCH_FIELDS)\n \n     # filter orders by status\n@@ -34,6 +29,20 @@\n     return gql_optimizer.query(qs, info)\n \n \n+def resolve_orders(info, created, status, query):\n+    user = info.context.user\n+    if user.has_perm('order.manage_orders'):\n+        qs = models.Order.objects.confirmed()\n+    else:\n+        qs = user.orders.confirmed()\n+    return filter_orders(qs, info, created, status, query)\n+\n+\n+def resolve_draft_orders(info, created, query):\n+    qs = models.Order.objects.drafts()\n+    return filter_orders(qs, info, created, None, query)\n+\n+\n def resolve_orders_total(info, period):\n     qs = models.Order.objects.confirmed().exclude(status=OrderStatus.CANCELED)\n     qs = filter_by_period(qs, period, 'created')\ndiff --git a/saleor/graphql/order/schema.py b/saleor/graphql/order/schema.py\n--- a/saleor/graphql/order/schema.py\n+++ b/saleor/graphql/order/schema.py\n@@ -19,8 +19,8 @@\n     OrderAddNote, OrderCancel, OrderCapture, OrderMarkAsPaid, OrderRefund,\n     OrderUpdate, OrderUpdateShipping, OrderVoid)\n from .resolvers import (\n-    resolve_homepage_events, resolve_order, resolve_order_by_token,\n-    resolve_orders, resolve_orders_total)\n+    resolve_draft_orders, resolve_homepage_events, resolve_order,\n+    resolve_order_by_token, resolve_orders, resolve_orders_total)\n from .types import Order, OrderEvent\n \n \n@@ -40,6 +40,13 @@\n         status=graphene.Argument(\n             OrderStatusFilter, description='Filter order by status'),\n         description='List of the shop\\'s orders.')\n+    draft_orders = PrefetchingConnectionField(\n+        Order,\n+        query=graphene.String(description=DESCRIPTIONS['order']),\n+        created=graphene.Argument(\n+            ReportingPeriod,\n+            description='Filter draft orders from a selected timespan.'),\n+        description='List of the shop\\'s draft orders.')\n     orders_total = graphene.Field(\n         TaxedMoney, description='Total sales.',\n         period=graphene.Argument(\n@@ -62,6 +69,10 @@\n             self, info, created=None, status=None, query=None, **kwargs):\n         return resolve_orders(info, created, status, query)\n \n+    @permission_required('order.manage_orders')\n+    def resolve_draft_orders(self, info, created=None, query=None, **kwargs):\n+        return resolve_draft_orders(info, created, query)\n+\n     @permission_required('order.manage_orders')\n     def resolve_orders_total(self, info, period, **kwargs):\n         return resolve_orders_total(info, period)\n", "issue": "Add query to fetch draft orders\nIn the Dashboard 2.0 we want to have separate links to view draft orders and confirmed ones. For that reason we need to add a separate resolver to return only draft orders. Exiting `orders` resolver should be changed to return confirmed orders.\n", "before_files": [{"content": "import graphene\nimport graphene_django_optimizer as gql_optimizer\n\nfrom ...order import OrderEvents, OrderStatus, models\nfrom ...order.utils import sum_order_totals\nfrom ..utils import filter_by_period, filter_by_query_param\nfrom .enums import OrderStatusFilter\nfrom .types import Order\nfrom .utils import applicable_shipping_methods\n\nORDER_SEARCH_FIELDS = (\n    'id', 'discount_name', 'token', 'user_email', 'user__email')\n\n\ndef resolve_orders(info, created, status, query):\n    user = info.context.user\n    if user.has_perm('order.manage_orders'):\n        qs = models.Order.objects.all()\n    else:\n        qs = user.orders.confirmed()\n    qs = filter_by_query_param(qs, query, ORDER_SEARCH_FIELDS)\n\n    # filter orders by status\n    if status is not None:\n        if status == OrderStatusFilter.READY_TO_FULFILL:\n            qs = qs.ready_to_fulfill()\n        elif status == OrderStatusFilter.READY_TO_CAPTURE:\n            qs = qs.ready_to_capture()\n\n    # filter orders by creation date\n    if created is not None:\n        qs = filter_by_period(qs, created, 'created')\n\n    return gql_optimizer.query(qs, info)\n\n\ndef resolve_orders_total(info, period):\n    qs = models.Order.objects.confirmed().exclude(status=OrderStatus.CANCELED)\n    qs = filter_by_period(qs, period, 'created')\n    return sum_order_totals(qs)\n\n\ndef resolve_order(info, id):\n    \"\"\"Return order only for user assigned to it or proper staff user.\"\"\"\n    user = info.context.user\n    order = graphene.Node.get_node_from_global_id(info, id, Order)\n    if user.has_perm('order.manage_orders') or order.user == user:\n        return order\n    return None\n\n\ndef resolve_shipping_methods(obj, info, price):\n    return applicable_shipping_methods(obj, info, price)\n\n\ndef resolve_homepage_events(info):\n    # Filter only selected events to be displayed on homepage.\n    types = [\n        OrderEvents.PLACED.value, OrderEvents.PLACED_FROM_DRAFT.value,\n        OrderEvents.ORDER_FULLY_PAID.value]\n    return models.OrderEvent.objects.filter(type__in=types)\n\n\ndef resolve_order_by_token(info, token):\n    return models.Order.objects.filter(token=token).first()\n", "path": "saleor/graphql/order/resolvers.py"}, {"content": "from textwrap import dedent\n\nimport graphene\nfrom graphql_jwt.decorators import login_required, permission_required\n\nfrom ..core.enums import ReportingPeriod\nfrom ..core.fields import PrefetchingConnectionField\nfrom ..core.types import TaxedMoney\nfrom ..descriptions import DESCRIPTIONS\nfrom .bulk_mutations.draft_orders import DraftOrderBulkDelete\nfrom .enums import OrderStatusFilter\nfrom .mutations.draft_orders import (\n    DraftOrderComplete, DraftOrderCreate, DraftOrderDelete,\n    DraftOrderLineDelete, DraftOrderLinesCreate, DraftOrderLineUpdate,\n    DraftOrderUpdate)\nfrom .mutations.fulfillments import (\n    FulfillmentCancel, FulfillmentCreate, FulfillmentUpdateTracking)\nfrom .mutations.orders import (\n    OrderAddNote, OrderCancel, OrderCapture, OrderMarkAsPaid, OrderRefund,\n    OrderUpdate, OrderUpdateShipping, OrderVoid)\nfrom .resolvers import (\n    resolve_homepage_events, resolve_order, resolve_order_by_token,\n    resolve_orders, resolve_orders_total)\nfrom .types import Order, OrderEvent\n\n\nclass OrderQueries(graphene.ObjectType):\n    homepage_events = PrefetchingConnectionField(\n        OrderEvent, description=dedent('''List of activity events to display on\n        homepage (at the moment it only contains order-events).'''))\n    order = graphene.Field(\n        Order, description='Lookup an order by ID.',\n        id=graphene.Argument(graphene.ID, required=True))\n    orders = PrefetchingConnectionField(\n        Order,\n        query=graphene.String(description=DESCRIPTIONS['order']),\n        created=graphene.Argument(\n            ReportingPeriod,\n            description='Filter orders from a selected timespan.'),\n        status=graphene.Argument(\n            OrderStatusFilter, description='Filter order by status'),\n        description='List of the shop\\'s orders.')\n    orders_total = graphene.Field(\n        TaxedMoney, description='Total sales.',\n        period=graphene.Argument(\n            ReportingPeriod,\n            description='Get total sales for selected span of time.'))\n    order_by_token = graphene.Field(\n        Order, description='Lookup an order by token.',\n        token=graphene.Argument(graphene.String, required=True))\n\n    @permission_required('order.manage_orders')\n    def resolve_homepage_events(self, info, **kwargs):\n        return resolve_homepage_events(info)\n\n    @login_required\n    def resolve_order(self, info, id):\n        return resolve_order(info, id)\n\n    @login_required\n    def resolve_orders(\n            self, info, created=None, status=None, query=None, **kwargs):\n        return resolve_orders(info, created, status, query)\n\n    @permission_required('order.manage_orders')\n    def resolve_orders_total(self, info, period, **kwargs):\n        return resolve_orders_total(info, period)\n\n    def resolve_order_by_token(self, info, token):\n        return resolve_order_by_token(info, token)\n\n\nclass OrderMutations(graphene.ObjectType):\n    draft_order_complete = DraftOrderComplete.Field()\n    draft_order_create = DraftOrderCreate.Field()\n    draft_order_delete = DraftOrderDelete.Field()\n    draft_order_bulk_delete = DraftOrderBulkDelete.Field()\n    draft_order_lines_create = DraftOrderLinesCreate.Field()\n    draft_order_line_delete = DraftOrderLineDelete.Field()\n    draft_order_line_update = DraftOrderLineUpdate.Field()\n    draft_order_update = DraftOrderUpdate.Field()\n\n    order_add_note = OrderAddNote.Field()\n    order_cancel = OrderCancel.Field()\n    order_capture = OrderCapture.Field()\n    order_fulfillment_cancel = FulfillmentCancel.Field()\n    order_fulfillment_create = FulfillmentCreate.Field()\n    order_fulfillment_update_tracking = FulfillmentUpdateTracking.Field()\n    order_mark_as_paid = OrderMarkAsPaid.Field()\n    order_refund = OrderRefund.Field()\n    order_update = OrderUpdate.Field()\n    order_update_shipping = OrderUpdateShipping.Field()\n    order_void = OrderVoid.Field()\n", "path": "saleor/graphql/order/schema.py"}], "after_files": [{"content": "import graphene\nimport graphene_django_optimizer as gql_optimizer\n\nfrom ...order import OrderEvents, OrderStatus, models\nfrom ...order.utils import sum_order_totals\nfrom ..utils import filter_by_period, filter_by_query_param\nfrom .enums import OrderStatusFilter\nfrom .types import Order\nfrom .utils import applicable_shipping_methods\n\nORDER_SEARCH_FIELDS = (\n    'id', 'discount_name', 'token', 'user_email', 'user__email')\n\n\ndef filter_orders(qs, info, created, status, query):\n    qs = filter_by_query_param(qs, query, ORDER_SEARCH_FIELDS)\n\n    # filter orders by status\n    if status is not None:\n        if status == OrderStatusFilter.READY_TO_FULFILL:\n            qs = qs.ready_to_fulfill()\n        elif status == OrderStatusFilter.READY_TO_CAPTURE:\n            qs = qs.ready_to_capture()\n\n    # filter orders by creation date\n    if created is not None:\n        qs = filter_by_period(qs, created, 'created')\n\n    return gql_optimizer.query(qs, info)\n\n\ndef resolve_orders(info, created, status, query):\n    user = info.context.user\n    if user.has_perm('order.manage_orders'):\n        qs = models.Order.objects.confirmed()\n    else:\n        qs = user.orders.confirmed()\n    return filter_orders(qs, info, created, status, query)\n\n\ndef resolve_draft_orders(info, created, query):\n    qs = models.Order.objects.drafts()\n    return filter_orders(qs, info, created, None, query)\n\n\ndef resolve_orders_total(info, period):\n    qs = models.Order.objects.confirmed().exclude(status=OrderStatus.CANCELED)\n    qs = filter_by_period(qs, period, 'created')\n    return sum_order_totals(qs)\n\n\ndef resolve_order(info, id):\n    \"\"\"Return order only for user assigned to it or proper staff user.\"\"\"\n    user = info.context.user\n    order = graphene.Node.get_node_from_global_id(info, id, Order)\n    if user.has_perm('order.manage_orders') or order.user == user:\n        return order\n    return None\n\n\ndef resolve_shipping_methods(obj, info, price):\n    return applicable_shipping_methods(obj, info, price)\n\n\ndef resolve_homepage_events(info):\n    # Filter only selected events to be displayed on homepage.\n    types = [\n        OrderEvents.PLACED.value, OrderEvents.PLACED_FROM_DRAFT.value,\n        OrderEvents.ORDER_FULLY_PAID.value]\n    return models.OrderEvent.objects.filter(type__in=types)\n\n\ndef resolve_order_by_token(info, token):\n    return models.Order.objects.filter(token=token).first()\n", "path": "saleor/graphql/order/resolvers.py"}, {"content": "from textwrap import dedent\n\nimport graphene\nfrom graphql_jwt.decorators import login_required, permission_required\n\nfrom ..core.enums import ReportingPeriod\nfrom ..core.fields import PrefetchingConnectionField\nfrom ..core.types import TaxedMoney\nfrom ..descriptions import DESCRIPTIONS\nfrom .bulk_mutations.draft_orders import DraftOrderBulkDelete\nfrom .enums import OrderStatusFilter\nfrom .mutations.draft_orders import (\n    DraftOrderComplete, DraftOrderCreate, DraftOrderDelete,\n    DraftOrderLineDelete, DraftOrderLinesCreate, DraftOrderLineUpdate,\n    DraftOrderUpdate)\nfrom .mutations.fulfillments import (\n    FulfillmentCancel, FulfillmentCreate, FulfillmentUpdateTracking)\nfrom .mutations.orders import (\n    OrderAddNote, OrderCancel, OrderCapture, OrderMarkAsPaid, OrderRefund,\n    OrderUpdate, OrderUpdateShipping, OrderVoid)\nfrom .resolvers import (\n    resolve_draft_orders, resolve_homepage_events, resolve_order,\n    resolve_order_by_token, resolve_orders, resolve_orders_total)\nfrom .types import Order, OrderEvent\n\n\nclass OrderQueries(graphene.ObjectType):\n    homepage_events = PrefetchingConnectionField(\n        OrderEvent, description=dedent('''List of activity events to display on\n        homepage (at the moment it only contains order-events).'''))\n    order = graphene.Field(\n        Order, description='Lookup an order by ID.',\n        id=graphene.Argument(graphene.ID, required=True))\n    orders = PrefetchingConnectionField(\n        Order,\n        query=graphene.String(description=DESCRIPTIONS['order']),\n        created=graphene.Argument(\n            ReportingPeriod,\n            description='Filter orders from a selected timespan.'),\n        status=graphene.Argument(\n            OrderStatusFilter, description='Filter order by status'),\n        description='List of the shop\\'s orders.')\n    draft_orders = PrefetchingConnectionField(\n        Order,\n        query=graphene.String(description=DESCRIPTIONS['order']),\n        created=graphene.Argument(\n            ReportingPeriod,\n            description='Filter draft orders from a selected timespan.'),\n        description='List of the shop\\'s draft orders.')\n    orders_total = graphene.Field(\n        TaxedMoney, description='Total sales.',\n        period=graphene.Argument(\n            ReportingPeriod,\n            description='Get total sales for selected span of time.'))\n    order_by_token = graphene.Field(\n        Order, description='Lookup an order by token.',\n        token=graphene.Argument(graphene.String, required=True))\n\n    @permission_required('order.manage_orders')\n    def resolve_homepage_events(self, info, **kwargs):\n        return resolve_homepage_events(info)\n\n    @login_required\n    def resolve_order(self, info, id):\n        return resolve_order(info, id)\n\n    @login_required\n    def resolve_orders(\n            self, info, created=None, status=None, query=None, **kwargs):\n        return resolve_orders(info, created, status, query)\n\n    @permission_required('order.manage_orders')\n    def resolve_draft_orders(self, info, created=None, query=None, **kwargs):\n        return resolve_draft_orders(info, created, query)\n\n    @permission_required('order.manage_orders')\n    def resolve_orders_total(self, info, period, **kwargs):\n        return resolve_orders_total(info, period)\n\n    def resolve_order_by_token(self, info, token):\n        return resolve_order_by_token(info, token)\n\n\nclass OrderMutations(graphene.ObjectType):\n    draft_order_complete = DraftOrderComplete.Field()\n    draft_order_create = DraftOrderCreate.Field()\n    draft_order_delete = DraftOrderDelete.Field()\n    draft_order_bulk_delete = DraftOrderBulkDelete.Field()\n    draft_order_lines_create = DraftOrderLinesCreate.Field()\n    draft_order_line_delete = DraftOrderLineDelete.Field()\n    draft_order_line_update = DraftOrderLineUpdate.Field()\n    draft_order_update = DraftOrderUpdate.Field()\n\n    order_add_note = OrderAddNote.Field()\n    order_cancel = OrderCancel.Field()\n    order_capture = OrderCapture.Field()\n    order_fulfillment_cancel = FulfillmentCancel.Field()\n    order_fulfillment_create = FulfillmentCreate.Field()\n    order_fulfillment_update_tracking = FulfillmentUpdateTracking.Field()\n    order_mark_as_paid = OrderMarkAsPaid.Field()\n    order_refund = OrderRefund.Field()\n    order_update = OrderUpdate.Field()\n    order_update_shipping = OrderUpdateShipping.Field()\n    order_void = OrderVoid.Field()\n", "path": "saleor/graphql/order/schema.py"}]}