We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Creating empty order draft causes API to explode
### What I'm trying to achieve
To get order draft details from API.

### Steps to reproduce the problem
Execute this query
```
{
  orders {
    edges {
      node {
        id
        userEmail
      }
    }
  }
}
```

### What I expected to happen
Definitely not to throw an error.

--- 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/types.py`
Content:
```
1 import graphene
2 from graphene import relay
3 
4 from ...order import OrderEvents, models
5 from ..account.types import User
6 from ..core.types.common import CountableDjangoObjectType
7 from ..core.types.money import Money, TaxedMoney
8 from decimal import Decimal
9 
10 OrderEventsEnum = graphene.Enum.from_enum(OrderEvents)
11 
12 
13 class OrderEvent(CountableDjangoObjectType):
14     date = graphene.types.datetime.DateTime(
15         description='Date when event happened at in ISO 8601 format.')
16     type = OrderEventsEnum(description='Order event type')
17     user = graphene.Field(
18         User, id=graphene.Argument(graphene.ID),
19         description='User who performed the action.')
20     message = graphene.String(
21         description='Content of a note added to the order.')
22     email = graphene.String(description='Email of the customer')
23     email_type = graphene.String(
24         description='Type of an email sent to the customer')
25     amount = graphene.Float(description='Amount of money.')
26     quantity = graphene.Int(description='Number of items.')
27     composed_id = graphene.String(
28         description='Composed id of the Fulfillment.')
29 
30     class Meta:
31         description = 'History log of the order.'
32         model = models.OrderEvent
33         interfaces = [relay.Node]
34         exclude_fields = ['order', 'parameters']
35 
36     def resolve_email(self, info):
37         return self.parameters.get('email', None)
38 
39     def resolve_email_type(self, info):
40         return self.parameters.get('email_type', None)
41 
42     def resolve_amount(self, info):
43         amount = self.parameters.get('amount', None)
44         return Decimal(amount) if amount else None
45 
46     def resolve_quantity(self, info):
47         quantity = self.parameters.get('quantity', None)
48         return int(quantity) if quantity else None
49 
50     def resolve_message(self, info):
51         return self.parameters.get('message', None)
52 
53     def resolve_composed_id(self, info):
54         return self.parameters.get('composed_id', None)
55 
56 
57 class Fulfillment(CountableDjangoObjectType):
58     status_display = graphene.String(
59         description='User-friendly fulfillment status.')
60 
61     class Meta:
62         description = 'Represents order fulfillment.'
63         interfaces = [relay.Node]
64         model = models.Fulfillment
65         exclude_fields = ['order']
66 
67     def resolve_status_display(self, info):
68         return self.get_status_display()
69 
70 
71 class FulfillmentLine(CountableDjangoObjectType):
72     class Meta:
73         description = 'Represents line of the fulfillment.'
74         interfaces = [relay.Node]
75         model = models.FulfillmentLine
76         exclude_fields = ['fulfillment']
77 
78 
79 class Order(CountableDjangoObjectType):
80     fulfillments = graphene.List(
81         Fulfillment,
82         required=True,
83         description='List of shipments for the order.')
84     is_paid = graphene.Boolean(
85         description='Informs if an order is fully paid.')
86     number = graphene.String(description='User-friendly number of an order.')
87     payment_status = graphene.String(description='Internal payment status.')
88     payment_status_display = graphene.String(
89         description='User-friendly payment status.')
90     subtotal = graphene.Field(
91         TaxedMoney,
92         description='The sum of line prices not including shipping.')
93     status_display = graphene.String(description='User-friendly order status.')
94     total_authorized = graphene.Field(
95         Money, description='Amount authorized for the order.')
96     total_captured = graphene.Field(
97         Money, description='Amount captured by payment.')
98     events = graphene.List(
99         OrderEvent,
100         description='List of events associated with the order.')
101 
102     class Meta:
103         description = 'Represents an order in the shop.'
104         interfaces = [relay.Node]
105         model = models.Order
106         exclude_fields = [
107             'shipping_price_gross', 'shipping_price_net', 'total_gross',
108             'total_net']
109 
110     @staticmethod
111     def resolve_subtotal(obj, info):
112         return obj.get_subtotal()
113 
114     @staticmethod
115     def resolve_total_authorized(obj, info):
116         payment = obj.get_last_payment()
117         if payment:
118             return payment.get_total_price().gross
119 
120     @staticmethod
121     def resolve_total_captured(obj, info):
122         payment = obj.get_last_payment()
123         if payment:
124             return payment.get_captured_price()
125 
126     @staticmethod
127     def resolve_fulfillments(obj, info):
128         return obj.fulfillments.all()
129 
130     @staticmethod
131     def resolve_events(obj, info):
132         return obj.events.all()
133 
134     @staticmethod
135     def resolve_is_paid(obj, info):
136         return obj.is_fully_paid()
137 
138     @staticmethod
139     def resolve_number(obj, info):
140         return str(obj.pk)
141 
142     @staticmethod
143     def resolve_payment_status(obj, info):
144         return obj.get_last_payment_status()
145 
146     @staticmethod
147     def resolve_payment_status_display(obj, info):
148         return obj.get_last_payment_status_display()
149 
150     @staticmethod
151     def resolve_status_display(obj, info):
152         return obj.get_status_display()
153 
154     @staticmethod
155     def resolve_user_email(obj, info):
156         if obj.user_email:
157             return obj.user_email
158         if obj.user_id:
159             return obj.user.email
160 
161 
162 class OrderLine(CountableDjangoObjectType):
163     class Meta:
164         description = 'Represents order line of particular order.'
165         model = models.OrderLine
166         interfaces = [relay.Node]
167         exclude_fields = [
168             'order', 'unit_price_gross', 'unit_price_net', 'variant']
169
```
--- 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()

```

diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.py
--- a/saleor/graphql/order/types.py
+++ b/saleor/graphql/order/types.py
@@ -98,6 +98,8 @@
     events = graphene.List(
         OrderEvent,
         description='List of events associated with the order.')
+    user_email = graphene.String(
+        required=False, description='Email address of the customer.')
 
     class Meta:
         description = 'Represents an order in the shop.'
@@ -157,6 +159,7 @@
             return obj.user_email
         if obj.user_id:
             return obj.user.email
+        return None
 
 
 class OrderLine(CountableDjangoObjectType):

{"golden_diff": "diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.py\n--- a/saleor/graphql/order/types.py\n+++ b/saleor/graphql/order/types.py\n@@ -98,6 +98,8 @@\n     events = graphene.List(\n         OrderEvent,\n         description='List of events associated with the order.')\n+    user_email = graphene.String(\n+        required=False, description='Email address of the customer.')\n \n     class Meta:\n         description = 'Represents an order in the shop.'\n@@ -157,6 +159,7 @@\n             return obj.user_email\n         if obj.user_id:\n             return obj.user.email\n+        return None\n \n \n class OrderLine(CountableDjangoObjectType):\n", "issue": "Creating empty order draft causes API to explode\n### What I'm trying to achieve\r\nTo get order draft details from API.\r\n\r\n### Steps to reproduce the problem\r\nExecute this query\r\n```\r\n{\r\n  orders {\r\n    edges {\r\n      node {\r\n        id\r\n        userEmail\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### What I expected to happen\r\nDefinitely not to throw an error.\n", "before_files": [{"content": "import graphene\nfrom graphene import relay\n\nfrom ...order import OrderEvents, models\nfrom ..account.types import User\nfrom ..core.types.common import CountableDjangoObjectType\nfrom ..core.types.money import Money, TaxedMoney\nfrom decimal import Decimal\n\nOrderEventsEnum = graphene.Enum.from_enum(OrderEvents)\n\n\nclass OrderEvent(CountableDjangoObjectType):\n    date = graphene.types.datetime.DateTime(\n        description='Date when event happened at in ISO 8601 format.')\n    type = OrderEventsEnum(description='Order event type')\n    user = graphene.Field(\n        User, id=graphene.Argument(graphene.ID),\n        description='User who performed the action.')\n    message = graphene.String(\n        description='Content of a note added to the order.')\n    email = graphene.String(description='Email of the customer')\n    email_type = graphene.String(\n        description='Type of an email sent to the customer')\n    amount = graphene.Float(description='Amount of money.')\n    quantity = graphene.Int(description='Number of items.')\n    composed_id = graphene.String(\n        description='Composed id of the Fulfillment.')\n\n    class Meta:\n        description = 'History log of the order.'\n        model = models.OrderEvent\n        interfaces = [relay.Node]\n        exclude_fields = ['order', 'parameters']\n\n    def resolve_email(self, info):\n        return self.parameters.get('email', None)\n\n    def resolve_email_type(self, info):\n        return self.parameters.get('email_type', None)\n\n    def resolve_amount(self, info):\n        amount = self.parameters.get('amount', None)\n        return Decimal(amount) if amount else None\n\n    def resolve_quantity(self, info):\n        quantity = self.parameters.get('quantity', None)\n        return int(quantity) if quantity else None\n\n    def resolve_message(self, info):\n        return self.parameters.get('message', None)\n\n    def resolve_composed_id(self, info):\n        return self.parameters.get('composed_id', None)\n\n\nclass Fulfillment(CountableDjangoObjectType):\n    status_display = graphene.String(\n        description='User-friendly fulfillment status.')\n\n    class Meta:\n        description = 'Represents order fulfillment.'\n        interfaces = [relay.Node]\n        model = models.Fulfillment\n        exclude_fields = ['order']\n\n    def resolve_status_display(self, info):\n        return self.get_status_display()\n\n\nclass FulfillmentLine(CountableDjangoObjectType):\n    class Meta:\n        description = 'Represents line of the fulfillment.'\n        interfaces = [relay.Node]\n        model = models.FulfillmentLine\n        exclude_fields = ['fulfillment']\n\n\nclass Order(CountableDjangoObjectType):\n    fulfillments = graphene.List(\n        Fulfillment,\n        required=True,\n        description='List of shipments for the order.')\n    is_paid = graphene.Boolean(\n        description='Informs if an order is fully paid.')\n    number = graphene.String(description='User-friendly number of an order.')\n    payment_status = graphene.String(description='Internal payment status.')\n    payment_status_display = graphene.String(\n        description='User-friendly payment status.')\n    subtotal = graphene.Field(\n        TaxedMoney,\n        description='The sum of line prices not including shipping.')\n    status_display = graphene.String(description='User-friendly order status.')\n    total_authorized = graphene.Field(\n        Money, description='Amount authorized for the order.')\n    total_captured = graphene.Field(\n        Money, description='Amount captured by payment.')\n    events = graphene.List(\n        OrderEvent,\n        description='List of events associated with the order.')\n\n    class Meta:\n        description = 'Represents an order in the shop.'\n        interfaces = [relay.Node]\n        model = models.Order\n        exclude_fields = [\n            'shipping_price_gross', 'shipping_price_net', 'total_gross',\n            'total_net']\n\n    @staticmethod\n    def resolve_subtotal(obj, info):\n        return obj.get_subtotal()\n\n    @staticmethod\n    def resolve_total_authorized(obj, info):\n        payment = obj.get_last_payment()\n        if payment:\n            return payment.get_total_price().gross\n\n    @staticmethod\n    def resolve_total_captured(obj, info):\n        payment = obj.get_last_payment()\n        if payment:\n            return payment.get_captured_price()\n\n    @staticmethod\n    def resolve_fulfillments(obj, info):\n        return obj.fulfillments.all()\n\n    @staticmethod\n    def resolve_events(obj, info):\n        return obj.events.all()\n\n    @staticmethod\n    def resolve_is_paid(obj, info):\n        return obj.is_fully_paid()\n\n    @staticmethod\n    def resolve_number(obj, info):\n        return str(obj.pk)\n\n    @staticmethod\n    def resolve_payment_status(obj, info):\n        return obj.get_last_payment_status()\n\n    @staticmethod\n    def resolve_payment_status_display(obj, info):\n        return obj.get_last_payment_status_display()\n\n    @staticmethod\n    def resolve_status_display(obj, info):\n        return obj.get_status_display()\n\n    @staticmethod\n    def resolve_user_email(obj, info):\n        if obj.user_email:\n            return obj.user_email\n        if obj.user_id:\n            return obj.user.email\n\n\nclass OrderLine(CountableDjangoObjectType):\n    class Meta:\n        description = 'Represents order line of particular order.'\n        model = models.OrderLine\n        interfaces = [relay.Node]\n        exclude_fields = [\n            'order', 'unit_price_gross', 'unit_price_net', 'variant']\n", "path": "saleor/graphql/order/types.py"}], "after_files": [{"content": "import graphene\nfrom graphene import relay\n\nfrom ...order import OrderEvents, models\nfrom ..account.types import User\nfrom ..core.types.common import CountableDjangoObjectType\nfrom ..core.types.money import Money, TaxedMoney\nfrom decimal import Decimal\n\nOrderEventsEnum = graphene.Enum.from_enum(OrderEvents)\n\n\nclass OrderEvent(CountableDjangoObjectType):\n    date = graphene.types.datetime.DateTime(\n        description='Date when event happened at in ISO 8601 format.')\n    type = OrderEventsEnum(description='Order event type')\n    user = graphene.Field(\n        User, id=graphene.Argument(graphene.ID),\n        description='User who performed the action.')\n    message = graphene.String(\n        description='Content of a note added to the order.')\n    email = graphene.String(description='Email of the customer')\n    email_type = graphene.String(\n        description='Type of an email sent to the customer')\n    amount = graphene.Float(description='Amount of money.')\n    quantity = graphene.Int(description='Number of items.')\n    composed_id = graphene.String(\n        description='Composed id of the Fulfillment.')\n\n    class Meta:\n        description = 'History log of the order.'\n        model = models.OrderEvent\n        interfaces = [relay.Node]\n        exclude_fields = ['order', 'parameters']\n\n    def resolve_email(self, info):\n        return self.parameters.get('email', None)\n\n    def resolve_email_type(self, info):\n        return self.parameters.get('email_type', None)\n\n    def resolve_amount(self, info):\n        amount = self.parameters.get('amount', None)\n        return Decimal(amount) if amount else None\n\n    def resolve_quantity(self, info):\n        quantity = self.parameters.get('quantity', None)\n        return int(quantity) if quantity else None\n\n    def resolve_message(self, info):\n        return self.parameters.get('message', None)\n\n    def resolve_composed_id(self, info):\n        return self.parameters.get('composed_id', None)\n\n\nclass Fulfillment(CountableDjangoObjectType):\n    status_display = graphene.String(\n        description='User-friendly fulfillment status.')\n\n    class Meta:\n        description = 'Represents order fulfillment.'\n        interfaces = [relay.Node]\n        model = models.Fulfillment\n        exclude_fields = ['order']\n\n    def resolve_status_display(self, info):\n        return self.get_status_display()\n\n\nclass FulfillmentLine(CountableDjangoObjectType):\n    class Meta:\n        description = 'Represents line of the fulfillment.'\n        interfaces = [relay.Node]\n        model = models.FulfillmentLine\n        exclude_fields = ['fulfillment']\n\n\nclass Order(CountableDjangoObjectType):\n    fulfillments = graphene.List(\n        Fulfillment,\n        required=True,\n        description='List of shipments for the order.')\n    is_paid = graphene.Boolean(\n        description='Informs if an order is fully paid.')\n    number = graphene.String(description='User-friendly number of an order.')\n    payment_status = graphene.String(description='Internal payment status.')\n    payment_status_display = graphene.String(\n        description='User-friendly payment status.')\n    subtotal = graphene.Field(\n        TaxedMoney,\n        description='The sum of line prices not including shipping.')\n    status_display = graphene.String(description='User-friendly order status.')\n    total_authorized = graphene.Field(\n        Money, description='Amount authorized for the order.')\n    total_captured = graphene.Field(\n        Money, description='Amount captured by payment.')\n    events = graphene.List(\n        OrderEvent,\n        description='List of events associated with the order.')\n    user_email = graphene.String(\n        required=False, description='Email address of the customer.')\n\n    class Meta:\n        description = 'Represents an order in the shop.'\n        interfaces = [relay.Node]\n        model = models.Order\n        exclude_fields = [\n            'shipping_price_gross', 'shipping_price_net', 'total_gross',\n            'total_net']\n\n    @staticmethod\n    def resolve_subtotal(obj, info):\n        return obj.get_subtotal()\n\n    @staticmethod\n    def resolve_total_authorized(obj, info):\n        payment = obj.get_last_payment()\n        if payment:\n            return payment.get_total_price().gross\n\n    @staticmethod\n    def resolve_total_captured(obj, info):\n        payment = obj.get_last_payment()\n        if payment:\n            return payment.get_captured_price()\n\n    @staticmethod\n    def resolve_fulfillments(obj, info):\n        return obj.fulfillments.all()\n\n    @staticmethod\n    def resolve_events(obj, info):\n        return obj.events.all()\n\n    @staticmethod\n    def resolve_is_paid(obj, info):\n        return obj.is_fully_paid()\n\n    @staticmethod\n    def resolve_number(obj, info):\n        return str(obj.pk)\n\n    @staticmethod\n    def resolve_payment_status(obj, info):\n        return obj.get_last_payment_status()\n\n    @staticmethod\n    def resolve_payment_status_display(obj, info):\n        return obj.get_last_payment_status_display()\n\n    @staticmethod\n    def resolve_status_display(obj, info):\n        return obj.get_status_display()\n\n    @staticmethod\n    def resolve_user_email(obj, info):\n        if obj.user_email:\n            return obj.user_email\n        if obj.user_id:\n            return obj.user.email\n        return None\n\n\nclass OrderLine(CountableDjangoObjectType):\n    class Meta:\n        description = 'Represents order line of particular order.'\n        model = models.OrderLine\n        interfaces = [relay.Node]\n        exclude_fields = [\n            'order', 'unit_price_gross', 'unit_price_net', 'variant']\n", "path": "saleor/graphql/order/types.py"}]}