prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Add support for interfaces
  We should be able to define interfaces with strawberry, something like this:
  
  ```python
  
  @strawberry.interface
  class Node:
      id: strawberry.ID
  ```
  
  </issue>
  <code>
  [start of strawberry/type.py]
  1 import typing
  2 from functools import partial
  3 
  4 from dataclasses import dataclass
  5 from graphql import (
  6     GraphQLField,
  7     GraphQLInputField,
  8     GraphQLInputObjectType,
  9     GraphQLObjectType,
  10 )
  11 from graphql.utilities.schema_printer import print_type
  12 
  13 from .constants import IS_STRAWBERRY_FIELD, IS_STRAWBERRY_INPUT
  14 from .type_converter import REGISTRY, get_graphql_type_for_annotation
  15 from .utils.str_converters import to_camel_case
  16 
  17 
  18 def _get_resolver(cls, field_name):
  19     def _resolver(obj, info):
  20         # TODO: can we make this nicer?
  21         # does it work in all the cases?
  22 
  23         field_resolver = getattr(cls(**(obj.__dict__ if obj else {})), field_name)
  24 
  25         if getattr(field_resolver, IS_STRAWBERRY_FIELD, False):
  26             return field_resolver(obj, info)
  27 
  28         return field_resolver
  29 
  30     return _resolver
  31 
  32 
  33 def _convert_annotations_fields(cls, *, is_input=False):
  34     FieldClass = GraphQLInputField if is_input else GraphQLField
  35     annotations = typing.get_type_hints(cls, None, REGISTRY)
  36 
  37     fields = {}
  38 
  39     for key, annotation in annotations.items():
  40         field_name = to_camel_case(key)
  41         class_field = getattr(cls, key, None)
  42 
  43         description = getattr(class_field, "description", None)
  44 
  45         fields[field_name] = FieldClass(
  46             get_graphql_type_for_annotation(annotation, key),
  47             description=description,
  48             **({} if is_input else {"resolve": _get_resolver(cls, key)})
  49         )
  50 
  51     return fields
  52 
  53 
  54 def _process_type(cls, *, is_input=False, description=None):
  55     name = cls.__name__
  56     REGISTRY[name] = cls
  57 
  58     def repr_(self):
  59         return print_type(self.field)
  60 
  61     setattr(cls, "__repr__", repr_)
  62 
  63     def _get_fields():
  64         fields = _convert_annotations_fields(cls, is_input=is_input)
  65 
  66         fields.update(
  67             {
  68                 to_camel_case(key): value.field
  69                 for key, value in cls.__dict__.items()
  70                 if getattr(value, IS_STRAWBERRY_FIELD, False)
  71             }
  72         )
  73 
  74         return fields
  75 
  76     if is_input:
  77         setattr(cls, IS_STRAWBERRY_INPUT, True)
  78 
  79     extra_kwargs = {"description": description or cls.__doc__}
  80 
  81     TypeClass = GraphQLInputObjectType if is_input else GraphQLObjectType
  82     cls.field = TypeClass(name, lambda: _get_fields(), **extra_kwargs)
  83 
  84     return dataclass(cls, repr=False)
  85 
  86 
  87 def type(cls=None, *, is_input=False, description=None):
  88     """Annotates a class as a GraphQL type.
  89 
  90     Example usage:
  91 
  92     >>> @strawberry.type:
  93     >>> class X:
  94     >>>     field_abc: str = "ABC"
  95     """
  96 
  97     def wrap(cls):
  98         return _process_type(cls, is_input=is_input, description=description)
  99 
  100     if cls is None:
  101         return wrap
  102 
  103     return wrap(cls)
  104 
  105 
  106 input = partial(type, is_input=True)
  107
  [end of strawberry/type.py]
  [start of strawberry/constants.py]
  1 IS_STRAWBERRY_FIELD = "_is_strawberry_field"
  2 IS_STRAWBERRY_INPUT = "_is_strawberry_input"
  3
  [end of strawberry/constants.py]
  [start of strawberry/__init__.py]
  1 __version__ = "0.1.0"
  2 
  3 
  4 from .enum import enum  # noqa
  5 from .field import field  # noqa
  6 from .mutation import mutation, subscription  # noqa
  7 from .scalars import ID  # noqa
  8 from .schema import Schema  # noqa
  9 from .type import input, type  # noqa
  10
  [end of strawberry/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/strawberry/__init__.py b/strawberry/__init__.py
  --- a/strawberry/__init__.py
  +++ b/strawberry/__init__.py
  @@ -6,4 +6,4 @@
   from .mutation import mutation, subscription  # noqa
   from .scalars import ID  # noqa
   from .schema import Schema  # noqa
  -from .type import input, type  # noqa
  +from .type import input, type, interface  # noqa
  diff --git a/strawberry/constants.py b/strawberry/constants.py
  --- a/strawberry/constants.py
  +++ b/strawberry/constants.py
  @@ -1,2 +1,3 @@
   IS_STRAWBERRY_FIELD = "_is_strawberry_field"
   IS_STRAWBERRY_INPUT = "_is_strawberry_input"
  +IS_STRAWBERRY_INTERFACE = "_is_strawberry_interface"
  diff --git a/strawberry/type.py b/strawberry/type.py
  --- a/strawberry/type.py
  +++ b/strawberry/type.py
  @@ -6,11 +6,12 @@
       GraphQLField,
       GraphQLInputField,
       GraphQLInputObjectType,
  +    GraphQLInterfaceType,
       GraphQLObjectType,
   )
   from graphql.utilities.schema_printer import print_type
   
  -from .constants import IS_STRAWBERRY_FIELD, IS_STRAWBERRY_INPUT
  +from .constants import IS_STRAWBERRY_FIELD, IS_STRAWBERRY_INPUT, IS_STRAWBERRY_INTERFACE
   from .type_converter import REGISTRY, get_graphql_type_for_annotation
   from .utils.str_converters import to_camel_case
   
  @@ -51,7 +52,7 @@
       return fields
   
   
  -def _process_type(cls, *, is_input=False, description=None):
  +def _process_type(cls, *, is_input=False, is_interface=False, description=None):
       name = cls.__name__
       REGISTRY[name] = cls
   
  @@ -75,16 +76,30 @@
   
       if is_input:
           setattr(cls, IS_STRAWBERRY_INPUT, True)
  +    elif is_interface:
  +        setattr(cls, IS_STRAWBERRY_INTERFACE, True)
   
       extra_kwargs = {"description": description or cls.__doc__}
   
  -    TypeClass = GraphQLInputObjectType if is_input else GraphQLObjectType
  +    if is_input:
  +        TypeClass = GraphQLInputObjectType
  +    elif is_interface:
  +        TypeClass = GraphQLInterfaceType
  +    else:
  +        TypeClass = GraphQLObjectType
  +
  +        extra_kwargs["interfaces"] = [
  +            klass.field
  +            for klass in cls.__bases__
  +            if hasattr(klass, IS_STRAWBERRY_INTERFACE)
  +        ]
  +
       cls.field = TypeClass(name, lambda: _get_fields(), **extra_kwargs)
   
       return dataclass(cls, repr=False)
   
   
  -def type(cls=None, *, is_input=False, description=None):
  +def type(cls=None, *, is_input=False, is_interface=False, description=None):
       """Annotates a class as a GraphQL type.
   
       Example usage:
  @@ -95,7 +110,9 @@
       """
   
       def wrap(cls):
  -        return _process_type(cls, is_input=is_input, description=description)
  +        return _process_type(
  +            cls, is_input=is_input, is_interface=is_interface, description=description
  +        )
   
       if cls is None:
           return wrap
  @@ -104,3 +121,4 @@
   
   
   input = partial(type, is_input=True)
  +interface = partial(type, is_interface=True)
  
verification_info: {"golden_diff": "diff --git a/strawberry/__init__.py b/strawberry/__init__.py\n--- a/strawberry/__init__.py\n+++ b/strawberry/__init__.py\n@@ -6,4 +6,4 @@\n from .mutation import mutation, subscription  # noqa\n from .scalars import ID  # noqa\n from .schema import Schema  # noqa\n-from .type import input, type  # noqa\n+from .type import input, type, interface  # noqa\ndiff --git a/strawberry/constants.py b/strawberry/constants.py\n--- a/strawberry/constants.py\n+++ b/strawberry/constants.py\n@@ -1,2 +1,3 @@\n IS_STRAWBERRY_FIELD = \"_is_strawberry_field\"\n IS_STRAWBERRY_INPUT = \"_is_strawberry_input\"\n+IS_STRAWBERRY_INTERFACE = \"_is_strawberry_interface\"\ndiff --git a/strawberry/type.py b/strawberry/type.py\n--- a/strawberry/type.py\n+++ b/strawberry/type.py\n@@ -6,11 +6,12 @@\n     GraphQLField,\n     GraphQLInputField,\n     GraphQLInputObjectType,\n+    GraphQLInterfaceType,\n     GraphQLObjectType,\n )\n from graphql.utilities.schema_printer import print_type\n \n-from .constants import IS_STRAWBERRY_FIELD, IS_STRAWBERRY_INPUT\n+from .constants import IS_STRAWBERRY_FIELD, IS_STRAWBERRY_INPUT, IS_STRAWBERRY_INTERFACE\n from .type_converter import REGISTRY, get_graphql_type_for_annotation\n from .utils.str_converters import to_camel_case\n \n@@ -51,7 +52,7 @@\n     return fields\n \n \n-def _process_type(cls, *, is_input=False, description=None):\n+def _process_type(cls, *, is_input=False, is_interface=False, description=None):\n     name = cls.__name__\n     REGISTRY[name] = cls\n \n@@ -75,16 +76,30 @@\n \n     if is_input:\n         setattr(cls, IS_STRAWBERRY_INPUT, True)\n+    elif is_interface:\n+        setattr(cls, IS_STRAWBERRY_INTERFACE, True)\n \n     extra_kwargs = {\"description\": description or cls.__doc__}\n \n-    TypeClass = GraphQLInputObjectType if is_input else GraphQLObjectType\n+    if is_input:\n+        TypeClass = GraphQLInputObjectType\n+    elif is_interface:\n+        TypeClass = GraphQLInterfaceType\n+    else:\n+        TypeClass = GraphQLObjectType\n+\n+        extra_kwargs[\"interfaces\"] = [\n+            klass.field\n+            for klass in cls.__bases__\n+            if hasattr(klass, IS_STRAWBERRY_INTERFACE)\n+        ]\n+\n     cls.field = TypeClass(name, lambda: _get_fields(), **extra_kwargs)\n \n     return dataclass(cls, repr=False)\n \n \n-def type(cls=None, *, is_input=False, description=None):\n+def type(cls=None, *, is_input=False, is_interface=False, description=None):\n     \"\"\"Annotates a class as a GraphQL type.\n \n     Example usage:\n@@ -95,7 +110,9 @@\n     \"\"\"\n \n     def wrap(cls):\n-        return _process_type(cls, is_input=is_input, description=description)\n+        return _process_type(\n+            cls, is_input=is_input, is_interface=is_interface, description=description\n+        )\n \n     if cls is None:\n         return wrap\n@@ -104,3 +121,4 @@\n \n \n input = partial(type, is_input=True)\n+interface = partial(type, is_interface=True)\n", "issue": "Add support for interfaces\nWe should be able to define interfaces with strawberry, something like this:\r\n\r\n```python\r\n\r\n@strawberry.interface\r\nclass Node:\r\n    id: strawberry.ID\r\n```\n", "before_files": [{"content": "import typing\nfrom functools import partial\n\nfrom dataclasses import dataclass\nfrom graphql import (\n    GraphQLField,\n    GraphQLInputField,\n    GraphQLInputObjectType,\n    GraphQLObjectType,\n)\nfrom graphql.utilities.schema_printer import print_type\n\nfrom .constants import IS_STRAWBERRY_FIELD, IS_STRAWBERRY_INPUT\nfrom .type_converter import REGISTRY, get_graphql_type_for_annotation\nfrom .utils.str_converters import to_camel_case\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 _convert_annotations_fields(cls, *, is_input=False):\n    FieldClass = GraphQLInputField if is_input else GraphQLField\n    annotations = typing.get_type_hints(cls, None, REGISTRY)\n\n    fields = {}\n\n    for key, annotation in annotations.items():\n        field_name = to_camel_case(key)\n        class_field = getattr(cls, key, None)\n\n        description = getattr(class_field, \"description\", None)\n\n        fields[field_name] = FieldClass(\n            get_graphql_type_for_annotation(annotation, key),\n            description=description,\n            **({} if is_input else {\"resolve\": _get_resolver(cls, key)})\n        )\n\n    return fields\n\n\ndef _process_type(cls, *, is_input=False, description=None):\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    def _get_fields():\n        fields = _convert_annotations_fields(cls, is_input=is_input)\n\n        fields.update(\n            {\n                to_camel_case(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    if is_input:\n        setattr(cls, IS_STRAWBERRY_INPUT, True)\n\n    extra_kwargs = {\"description\": description or cls.__doc__}\n\n    TypeClass = GraphQLInputObjectType if is_input else GraphQLObjectType\n    cls.field = TypeClass(name, lambda: _get_fields(), **extra_kwargs)\n\n    return dataclass(cls, repr=False)\n\n\ndef type(cls=None, *, is_input=False, description=None):\n    \"\"\"Annotates a class as a GraphQL type.\n\n    Example usage:\n\n    >>> @strawberry.type:\n    >>> class X:\n    >>>     field_abc: str = \"ABC\"\n    \"\"\"\n\n    def wrap(cls):\n        return _process_type(cls, is_input=is_input, description=description)\n\n    if cls is None:\n        return wrap\n\n    return wrap(cls)\n\n\ninput = partial(type, is_input=True)\n", "path": "strawberry/type.py"}, {"content": "IS_STRAWBERRY_FIELD = \"_is_strawberry_field\"\nIS_STRAWBERRY_INPUT = \"_is_strawberry_input\"\n", "path": "strawberry/constants.py"}, {"content": "__version__ = \"0.1.0\"\n\n\nfrom .enum import enum  # noqa\nfrom .field import field  # noqa\nfrom .mutation import mutation, subscription  # noqa\nfrom .scalars import ID  # noqa\nfrom .schema import Schema  # noqa\nfrom .type import input, type  # noqa\n", "path": "strawberry/__init__.py"}]}