prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Support forward references
  See: https://www.python.org/dev/peps/pep-0563/#forward-references
  
  Right now the following code would break:
  
  ```python
  from __future__ import annotations
  
  import strawberry
  import typing
  
  @strawberry.type
  class User:
      name: str
      friend: typing.Optional[User]
  ```
  
  This is the error we get:
  
  ```
    File "/Users/patrickarminio/Documents/personal/temp/stra/app.py", line 7, in <module>
      from schema import schema
    File "/Users/patrickarminio/Documents/personal/temp/stra/schema.py", line 10, in <module>
      @strawberry.type
    File "/Users/patrickarminio/.virtualenvs/stra-so-aNvo2/lib/python3.7/site-packages/strawberry/type.py", line 60, in type
      return wrap()
    File "/Users/patrickarminio/.virtualenvs/stra-so-aNvo2/lib/python3.7/site-packages/strawberry/type.py", line 55, in wrap
      cls._fields = _get_fields(cls)
    File "/Users/patrickarminio/.virtualenvs/stra-so-aNvo2/lib/python3.7/site-packages/strawberry/type.py", line 27, in _get_fields
      cls_annotations = typing.get_type_hints(cls)
    File "/Users/patrickarminio/.pyenv/versions/3.7.0/lib/python3.7/typing.py", line 973, in get_type_hints
      value = _eval_type(value, base_globals, localns)
    File "/Users/patrickarminio/.pyenv/versions/3.7.0/lib/python3.7/typing.py", line 260, in _eval_type
      return t._evaluate(globalns, localns)
    File "/Users/patrickarminio/.pyenv/versions/3.7.0/lib/python3.7/typing.py", line 464, in _evaluate
      eval(self.__forward_code__, globalns, localns),
    File "<string>", line 1, in <module>
  NameError: name 'User' is not defined
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `strawberry/type.py`
  Content:
  ```
  1 import typing
  2 
  3 from dataclasses import dataclass
  4 from graphql import GraphQLField, GraphQLObjectType
  5 from graphql.utilities.schema_printer import print_type
  6 
  7 from .constants import IS_STRAWBERRY_FIELD
  8 from .type_converter import get_graphql_type_for_annotation
  9 
  10 
  11 def _get_resolver(cls, field_name):
  12     def _resolver(obj, info):
  13         # TODO: can we make this nicer?
  14         # does it work in all the cases?
  15 
  16         field_resolver = getattr(cls(**(obj.__dict__ if obj else {})), field_name)
  17 
  18         if getattr(field_resolver, IS_STRAWBERRY_FIELD, False):
  19             return field_resolver(obj, info)
  20 
  21         return field_resolver
  22 
  23     return _resolver
  24 
  25 
  26 def _get_fields(cls):
  27     cls_annotations = typing.get_type_hints(cls)
  28 
  29     fields = {
  30         key: GraphQLField(
  31             get_graphql_type_for_annotation(value, field_name=key),
  32             resolve=_get_resolver(cls, key),
  33         )
  34         for key, value in cls_annotations.items()
  35     }
  36 
  37     fields.update(
  38         {
  39             key: value.field
  40             for key, value in cls.__dict__.items()
  41             if getattr(value, IS_STRAWBERRY_FIELD, False)
  42         }
  43     )
  44 
  45     return fields
  46 
  47 
  48 def type(cls):
  49     def wrap():
  50         def repr_(self):
  51             return print_type(self.field)
  52 
  53         setattr(cls, "__repr__", repr_)
  54 
  55         cls._fields = _get_fields(cls)
  56         cls.field = GraphQLObjectType(name=cls.__name__, fields=cls._fields)
  57 
  58         return dataclass(cls, repr=False)
  59 
  60     return wrap()
  61
  ```
  
  Path: `strawberry/type_converter.py`
  Content:
  ```
  1 from graphql import (
  2     GraphQLBoolean,
  3     GraphQLFloat,
  4     GraphQLID,
  5     GraphQLInt,
  6     GraphQLList,
  7     GraphQLNonNull,
  8     GraphQLString,
  9     GraphQLUnionType,
  10 )
  11 
  12 from .scalars import ID
  13 
  14 
  15 TYPE_MAP = {
  16     str: GraphQLString,
  17     int: GraphQLInt,
  18     float: GraphQLFloat,
  19     bool: GraphQLBoolean,
  20     ID: GraphQLID,
  21 }
  22 
  23 
  24 # TODO: make so that we don't pass force optional
  25 # we use that when trying to get the type for a
  26 # option field (which can either be a scalar or an object type)
  27 def get_graphql_type_for_annotation(
  28     annotation, field_name: str, force_optional: bool = False
  29 ):
  30     # TODO: nice error
  31 
  32     is_optional = False
  33 
  34     # TODO: this might lead to issues with types that have a field value
  35     if hasattr(annotation, "field"):
  36         graphql_type = annotation.field
  37     else:
  38         annotation_name = getattr(annotation, "_name", None)
  39 
  40         if annotation_name == "List":
  41             list_of_type = get_graphql_type_for_annotation(
  42                 annotation.__args__[0], field_name
  43             )
  44 
  45             return GraphQLList(list_of_type)
  46 
  47         # for some reason _name is None for Optional and Union types, so we check if we
  48         # have __args__ populated, there might be some edge cases where __args__ is
  49         # populated but the type is not an Union, like in the above case with Lists
  50         if hasattr(annotation, "__args__"):
  51             types = annotation.__args__
  52             non_none_types = [x for x in types if x != type(None)]  # noqa:E721
  53 
  54             # optionals are represented as Union[type, None]
  55             if len(non_none_types) == 1:
  56                 is_optional = True
  57                 graphql_type = get_graphql_type_for_annotation(
  58                     non_none_types[0], field_name, force_optional=True
  59                 )
  60             else:
  61                 is_optional = type(None) in types
  62 
  63                 # TODO: union types don't work with scalar types
  64                 # so we want to return a nice error
  65                 # also we want to make sure we have been passed
  66                 # strawberry types
  67                 graphql_type = GraphQLUnionType(
  68                     field_name, [type.field for type in types]
  69                 )
  70         else:
  71             graphql_type = TYPE_MAP.get(annotation)
  72 
  73     if not graphql_type:
  74         raise ValueError(f"Unable to get GraphQL type for {annotation}")
  75 
  76     if is_optional or force_optional:
  77         return graphql_type
  78 
  79     return GraphQLNonNull(graphql_type)
  80
  ```
  --- 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/strawberry/type.py b/strawberry/type.py
  --- a/strawberry/type.py
  +++ b/strawberry/type.py
  @@ -5,7 +5,7 @@
   from graphql.utilities.schema_printer import print_type
   
   from .constants import IS_STRAWBERRY_FIELD
  -from .type_converter import get_graphql_type_for_annotation
  +from .type_converter import REGISTRY, get_graphql_type_for_annotation
   
   
   def _get_resolver(cls, field_name):
  @@ -23,37 +23,39 @@
       return _resolver
   
   
  -def _get_fields(cls):
  -    cls_annotations = typing.get_type_hints(cls)
  -
  -    fields = {
  -        key: GraphQLField(
  -            get_graphql_type_for_annotation(value, field_name=key),
  -            resolve=_get_resolver(cls, key),
  -        )
  -        for key, value in cls_annotations.items()
  -    }
  -
  -    fields.update(
  -        {
  -            key: value.field
  -            for key, value in cls.__dict__.items()
  -            if getattr(value, IS_STRAWBERRY_FIELD, False)
  -        }
  -    )
  -
  -    return fields
  -
  -
   def type(cls):
       def wrap():
  +        name = cls.__name__
  +        REGISTRY[name] = cls
  +
           def repr_(self):
               return print_type(self.field)
   
           setattr(cls, "__repr__", repr_)
   
  -        cls._fields = _get_fields(cls)
  -        cls.field = GraphQLObjectType(name=cls.__name__, fields=cls._fields)
  +        annotations = typing.get_type_hints(cls, None, REGISTRY)
  +
  +        def _get_fields():
  +
  +            fields = {
  +                key: GraphQLField(
  +                    get_graphql_type_for_annotation(value, key),
  +                    resolve=_get_resolver(cls, key),
  +                )
  +                for key, value in annotations.items()
  +            }
  +
  +            fields.update(
  +                {
  +                    key: value.field
  +                    for key, value in cls.__dict__.items()
  +                    if getattr(value, IS_STRAWBERRY_FIELD, False)
  +                }
  +            )
  +
  +            return fields
  +
  +        cls.field = GraphQLObjectType(name, lambda: _get_fields())
   
           return dataclass(cls, repr=False)
   
  diff --git a/strawberry/type_converter.py b/strawberry/type_converter.py
  --- a/strawberry/type_converter.py
  +++ b/strawberry/type_converter.py
  @@ -12,7 +12,7 @@
   from .scalars import ID
   
   
  -TYPE_MAP = {
  +REGISTRY = {
       str: GraphQLString,
       int: GraphQLInt,
       float: GraphQLFloat,
  @@ -27,11 +27,9 @@
   def get_graphql_type_for_annotation(
       annotation, field_name: str, force_optional: bool = False
   ):
  -    # TODO: nice error
  -
  -    is_optional = False
  -
       # TODO: this might lead to issues with types that have a field value
  +    is_optional = force_optional
  +
       if hasattr(annotation, "field"):
           graphql_type = annotation.field
       else:
  @@ -49,7 +47,7 @@
           # populated but the type is not an Union, like in the above case with Lists
           if hasattr(annotation, "__args__"):
               types = annotation.__args__
  -            non_none_types = [x for x in types if x != type(None)]  # noqa:E721
  +            non_none_types = [x for x in types if x != None.__class__]  # noqa:E721
   
               # optionals are represented as Union[type, None]
               if len(non_none_types) == 1:
  @@ -58,7 +56,7 @@
                       non_none_types[0], field_name, force_optional=True
                   )
               else:
  -                is_optional = type(None) in types
  +                is_optional = None.__class__ in types
   
                   # TODO: union types don't work with scalar types
                   # so we want to return a nice error
  @@ -68,12 +66,12 @@
                       field_name, [type.field for type in types]
                   )
           else:
  -            graphql_type = TYPE_MAP.get(annotation)
  +            graphql_type = REGISTRY.get(annotation)
   
       if not graphql_type:
           raise ValueError(f"Unable to get GraphQL type for {annotation}")
   
  -    if is_optional or force_optional:
  +    if is_optional:
           return graphql_type
   
       return GraphQLNonNull(graphql_type)
  
verification_info: {"golden_diff": "diff --git a/strawberry/type.py b/strawberry/type.py\n--- a/strawberry/type.py\n+++ b/strawberry/type.py\n@@ -5,7 +5,7 @@\n from graphql.utilities.schema_printer import print_type\n \n from .constants import IS_STRAWBERRY_FIELD\n-from .type_converter import get_graphql_type_for_annotation\n+from .type_converter import REGISTRY, get_graphql_type_for_annotation\n \n \n def _get_resolver(cls, field_name):\n@@ -23,37 +23,39 @@\n     return _resolver\n \n \n-def _get_fields(cls):\n-    cls_annotations = typing.get_type_hints(cls)\n-\n-    fields = {\n-        key: GraphQLField(\n-            get_graphql_type_for_annotation(value, field_name=key),\n-            resolve=_get_resolver(cls, key),\n-        )\n-        for key, value in cls_annotations.items()\n-    }\n-\n-    fields.update(\n-        {\n-            key: value.field\n-            for key, value in cls.__dict__.items()\n-            if getattr(value, IS_STRAWBERRY_FIELD, False)\n-        }\n-    )\n-\n-    return fields\n-\n-\n def type(cls):\n     def wrap():\n+        name = cls.__name__\n+        REGISTRY[name] = cls\n+\n         def repr_(self):\n             return print_type(self.field)\n \n         setattr(cls, \"__repr__\", repr_)\n \n-        cls._fields = _get_fields(cls)\n-        cls.field = GraphQLObjectType(name=cls.__name__, fields=cls._fields)\n+        annotations = typing.get_type_hints(cls, None, REGISTRY)\n+\n+        def _get_fields():\n+\n+            fields = {\n+                key: GraphQLField(\n+                    get_graphql_type_for_annotation(value, key),\n+                    resolve=_get_resolver(cls, key),\n+                )\n+                for key, value in annotations.items()\n+            }\n+\n+            fields.update(\n+                {\n+                    key: value.field\n+                    for key, value in cls.__dict__.items()\n+                    if getattr(value, IS_STRAWBERRY_FIELD, False)\n+                }\n+            )\n+\n+            return fields\n+\n+        cls.field = GraphQLObjectType(name, lambda: _get_fields())\n \n         return dataclass(cls, repr=False)\n \ndiff --git a/strawberry/type_converter.py b/strawberry/type_converter.py\n--- a/strawberry/type_converter.py\n+++ b/strawberry/type_converter.py\n@@ -12,7 +12,7 @@\n from .scalars import ID\n \n \n-TYPE_MAP = {\n+REGISTRY = {\n     str: GraphQLString,\n     int: GraphQLInt,\n     float: GraphQLFloat,\n@@ -27,11 +27,9 @@\n def get_graphql_type_for_annotation(\n     annotation, field_name: str, force_optional: bool = False\n ):\n-    # TODO: nice error\n-\n-    is_optional = False\n-\n     # TODO: this might lead to issues with types that have a field value\n+    is_optional = force_optional\n+\n     if hasattr(annotation, \"field\"):\n         graphql_type = annotation.field\n     else:\n@@ -49,7 +47,7 @@\n         # populated but the type is not an Union, like in the above case with Lists\n         if hasattr(annotation, \"__args__\"):\n             types = annotation.__args__\n-            non_none_types = [x for x in types if x != type(None)]  # noqa:E721\n+            non_none_types = [x for x in types if x != None.__class__]  # noqa:E721\n \n             # optionals are represented as Union[type, None]\n             if len(non_none_types) == 1:\n@@ -58,7 +56,7 @@\n                     non_none_types[0], field_name, force_optional=True\n                 )\n             else:\n-                is_optional = type(None) in types\n+                is_optional = None.__class__ in types\n \n                 # TODO: union types don't work with scalar types\n                 # so we want to return a nice error\n@@ -68,12 +66,12 @@\n                     field_name, [type.field for type in types]\n                 )\n         else:\n-            graphql_type = TYPE_MAP.get(annotation)\n+            graphql_type = REGISTRY.get(annotation)\n \n     if not graphql_type:\n         raise ValueError(f\"Unable to get GraphQL type for {annotation}\")\n \n-    if is_optional or force_optional:\n+    if is_optional:\n         return graphql_type\n \n     return GraphQLNonNull(graphql_type)\n", "issue": "Support forward references\nSee: https://www.python.org/dev/peps/pep-0563/#forward-references\r\n\r\nRight now the following code would break:\r\n\r\n```python\r\nfrom __future__ import annotations\r\n\r\nimport strawberry\r\nimport typing\r\n\r\n@strawberry.type\r\nclass User:\r\n    name: str\r\n    friend: typing.Optional[User]\r\n```\r\n\r\nThis is the error we get:\r\n\r\n```\r\n  File \"/Users/patrickarminio/Documents/personal/temp/stra/app.py\", line 7, in <module>\r\n    from schema import schema\r\n  File \"/Users/patrickarminio/Documents/personal/temp/stra/schema.py\", line 10, in <module>\r\n    @strawberry.type\r\n  File \"/Users/patrickarminio/.virtualenvs/stra-so-aNvo2/lib/python3.7/site-packages/strawberry/type.py\", line 60, in type\r\n    return wrap()\r\n  File \"/Users/patrickarminio/.virtualenvs/stra-so-aNvo2/lib/python3.7/site-packages/strawberry/type.py\", line 55, in wrap\r\n    cls._fields = _get_fields(cls)\r\n  File \"/Users/patrickarminio/.virtualenvs/stra-so-aNvo2/lib/python3.7/site-packages/strawberry/type.py\", line 27, in _get_fields\r\n    cls_annotations = typing.get_type_hints(cls)\r\n  File \"/Users/patrickarminio/.pyenv/versions/3.7.0/lib/python3.7/typing.py\", line 973, in get_type_hints\r\n    value = _eval_type(value, base_globals, localns)\r\n  File \"/Users/patrickarminio/.pyenv/versions/3.7.0/lib/python3.7/typing.py\", line 260, in _eval_type\r\n    return t._evaluate(globalns, localns)\r\n  File \"/Users/patrickarminio/.pyenv/versions/3.7.0/lib/python3.7/typing.py\", line 464, in _evaluate\r\n    eval(self.__forward_code__, globalns, localns),\r\n  File \"<string>\", line 1, in <module>\r\nNameError: name 'User' is not defined\r\n```\n", "before_files": [{"content": "import typing\n\nfrom dataclasses import dataclass\nfrom graphql import GraphQLField, GraphQLObjectType\nfrom graphql.utilities.schema_printer import print_type\n\nfrom .constants import IS_STRAWBERRY_FIELD\nfrom .type_converter import get_graphql_type_for_annotation\n\n\ndef _get_resolver(cls, field_name):\n    def _resolver(obj, info):\n        # TODO: can we make this nicer?\n        # does it work in all the cases?\n\n        field_resolver = getattr(cls(**(obj.__dict__ if obj else {})), field_name)\n\n        if getattr(field_resolver, IS_STRAWBERRY_FIELD, False):\n            return field_resolver(obj, info)\n\n        return field_resolver\n\n    return _resolver\n\n\ndef _get_fields(cls):\n    cls_annotations = typing.get_type_hints(cls)\n\n    fields = {\n        key: GraphQLField(\n            get_graphql_type_for_annotation(value, field_name=key),\n            resolve=_get_resolver(cls, key),\n        )\n        for key, value in cls_annotations.items()\n    }\n\n    fields.update(\n        {\n            key: value.field\n            for key, value in cls.__dict__.items()\n            if getattr(value, IS_STRAWBERRY_FIELD, False)\n        }\n    )\n\n    return fields\n\n\ndef type(cls):\n    def wrap():\n        def repr_(self):\n            return print_type(self.field)\n\n        setattr(cls, \"__repr__\", repr_)\n\n        cls._fields = _get_fields(cls)\n        cls.field = GraphQLObjectType(name=cls.__name__, fields=cls._fields)\n\n        return dataclass(cls, repr=False)\n\n    return wrap()\n", "path": "strawberry/type.py"}, {"content": "from graphql import (\n    GraphQLBoolean,\n    GraphQLFloat,\n    GraphQLID,\n    GraphQLInt,\n    GraphQLList,\n    GraphQLNonNull,\n    GraphQLString,\n    GraphQLUnionType,\n)\n\nfrom .scalars import ID\n\n\nTYPE_MAP = {\n    str: GraphQLString,\n    int: GraphQLInt,\n    float: GraphQLFloat,\n    bool: GraphQLBoolean,\n    ID: GraphQLID,\n}\n\n\n# TODO: make so that we don't pass force optional\n# we use that when trying to get the type for a\n# option field (which can either be a scalar or an object type)\ndef get_graphql_type_for_annotation(\n    annotation, field_name: str, force_optional: bool = False\n):\n    # TODO: nice error\n\n    is_optional = False\n\n    # TODO: this might lead to issues with types that have a field value\n    if hasattr(annotation, \"field\"):\n        graphql_type = annotation.field\n    else:\n        annotation_name = getattr(annotation, \"_name\", None)\n\n        if annotation_name == \"List\":\n            list_of_type = get_graphql_type_for_annotation(\n                annotation.__args__[0], field_name\n            )\n\n            return GraphQLList(list_of_type)\n\n        # for some reason _name is None for Optional and Union types, so we check if we\n        # have __args__ populated, there might be some edge cases where __args__ is\n        # populated but the type is not an Union, like in the above case with Lists\n        if hasattr(annotation, \"__args__\"):\n            types = annotation.__args__\n            non_none_types = [x for x in types if x != type(None)]  # noqa:E721\n\n            # optionals are represented as Union[type, None]\n            if len(non_none_types) == 1:\n                is_optional = True\n                graphql_type = get_graphql_type_for_annotation(\n                    non_none_types[0], field_name, force_optional=True\n                )\n            else:\n                is_optional = type(None) in types\n\n                # TODO: union types don't work with scalar types\n                # so we want to return a nice error\n                # also we want to make sure we have been passed\n                # strawberry types\n                graphql_type = GraphQLUnionType(\n                    field_name, [type.field for type in types]\n                )\n        else:\n            graphql_type = TYPE_MAP.get(annotation)\n\n    if not graphql_type:\n        raise ValueError(f\"Unable to get GraphQL type for {annotation}\")\n\n    if is_optional or force_optional:\n        return graphql_type\n\n    return GraphQLNonNull(graphql_type)\n", "path": "strawberry/type_converter.py"}], "after_files": [{"content": "import typing\n\nfrom dataclasses import dataclass\nfrom graphql import GraphQLField, GraphQLObjectType\nfrom graphql.utilities.schema_printer import print_type\n\nfrom .constants import IS_STRAWBERRY_FIELD\nfrom .type_converter import REGISTRY, get_graphql_type_for_annotation\n\n\ndef _get_resolver(cls, field_name):\n    def _resolver(obj, info):\n        # TODO: can we make this nicer?\n        # does it work in all the cases?\n\n        field_resolver = getattr(cls(**(obj.__dict__ if obj else {})), field_name)\n\n        if getattr(field_resolver, IS_STRAWBERRY_FIELD, False):\n            return field_resolver(obj, info)\n\n        return field_resolver\n\n    return _resolver\n\n\ndef type(cls):\n    def wrap():\n        name = cls.__name__\n        REGISTRY[name] = cls\n\n        def repr_(self):\n            return print_type(self.field)\n\n        setattr(cls, \"__repr__\", repr_)\n\n        annotations = typing.get_type_hints(cls, None, REGISTRY)\n\n        def _get_fields():\n\n            fields = {\n                key: GraphQLField(\n                    get_graphql_type_for_annotation(value, key),\n                    resolve=_get_resolver(cls, key),\n                )\n                for key, value in annotations.items()\n            }\n\n            fields.update(\n                {\n                    key: value.field\n                    for key, value in cls.__dict__.items()\n                    if getattr(value, IS_STRAWBERRY_FIELD, False)\n                }\n            )\n\n            return fields\n\n        cls.field = GraphQLObjectType(name, lambda: _get_fields())\n\n        return dataclass(cls, repr=False)\n\n    return wrap()\n", "path": "strawberry/type.py"}, {"content": "from graphql import (\n    GraphQLBoolean,\n    GraphQLFloat,\n    GraphQLID,\n    GraphQLInt,\n    GraphQLList,\n    GraphQLNonNull,\n    GraphQLString,\n    GraphQLUnionType,\n)\n\nfrom .scalars import ID\n\n\nREGISTRY = {\n    str: GraphQLString,\n    int: GraphQLInt,\n    float: GraphQLFloat,\n    bool: GraphQLBoolean,\n    ID: GraphQLID,\n}\n\n\n# TODO: make so that we don't pass force optional\n# we use that when trying to get the type for a\n# option field (which can either be a scalar or an object type)\ndef get_graphql_type_for_annotation(\n    annotation, field_name: str, force_optional: bool = False\n):\n    # TODO: this might lead to issues with types that have a field value\n    is_optional = force_optional\n\n    if hasattr(annotation, \"field\"):\n        graphql_type = annotation.field\n    else:\n        annotation_name = getattr(annotation, \"_name\", None)\n\n        if annotation_name == \"List\":\n            list_of_type = get_graphql_type_for_annotation(\n                annotation.__args__[0], field_name\n            )\n\n            return GraphQLList(list_of_type)\n\n        # for some reason _name is None for Optional and Union types, so we check if we\n        # have __args__ populated, there might be some edge cases where __args__ is\n        # populated but the type is not an Union, like in the above case with Lists\n        if hasattr(annotation, \"__args__\"):\n            types = annotation.__args__\n            non_none_types = [x for x in types if x != None.__class__]  # noqa:E721\n\n            # optionals are represented as Union[type, None]\n            if len(non_none_types) == 1:\n                is_optional = True\n                graphql_type = get_graphql_type_for_annotation(\n                    non_none_types[0], field_name, force_optional=True\n                )\n            else:\n                is_optional = None.__class__ in types\n\n                # TODO: union types don't work with scalar types\n                # so we want to return a nice error\n                # also we want to make sure we have been passed\n                # strawberry types\n                graphql_type = GraphQLUnionType(\n                    field_name, [type.field for type in types]\n                )\n        else:\n            graphql_type = REGISTRY.get(annotation)\n\n    if not graphql_type:\n        raise ValueError(f\"Unable to get GraphQL type for {annotation}\")\n\n    if is_optional:\n        return graphql_type\n\n    return GraphQLNonNull(graphql_type)\n", "path": "strawberry/type_converter.py"}]}