prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  from_pydantic error if pydantic models contains contains fields that are resolver field in strawberry type
  Hi :),
  i have a pydantic model that i want to convert to strawberry type using from_pydantic() method. The pydantic model contains fields that are resolver field in the strawberry type model.
  
  ```python
  
  from .pydantic_models import Post as PostModel
  
  # Strawberry type 
  @strawberry.experimental.pydantic.type(name="Post", model=PostModel)
  class PostType:
      user: Optional[LazyType["UserType", "api_gateway.user"]] = strawberry.field(name="user", resolver=resolve_user)
      create_date: auto
      text: auto
  ```
  
  ```python
  
  # pydantic_models.py
  
  from pydantic import BaseModel
  
  # pydantic model
  class Post(BaseModel):
      user: Optional["User"]
      create_date: datetime = Field(default_factory=datetime.utcnow)
      text: str
  ```
  
  **Actual Behavior**
  ----------------------------------
  __init__() got an unexpected keyword argument user
  
  **Steps to Reproduce the Problem**
  ----------------------------------
  pydantic_post = Post(user=None, text="Hello World!") #create pydantic instance
  posttype = PostType.from_pydantic(pydantic_post) # not work - error
  
  This also not work:
  pydantic_post = Post(text="Hello World!")
  posttype = PostType.from_pydantic(pydantic_post) # also not work
  
  Thx
  
  
  
  
  </issue>
  <code>
  [start of strawberry/experimental/pydantic/conversion.py]
  1 from typing import Union, cast
  2 
  3 from strawberry.enum import EnumDefinition
  4 from strawberry.field import StrawberryField
  5 from strawberry.type import StrawberryList, StrawberryOptional, StrawberryType
  6 from strawberry.union import StrawberryUnion
  7 
  8 
  9 def _convert_from_pydantic_to_strawberry_type(
  10     type_: Union[StrawberryType, type], data_from_model=None, extra=None
  11 ):
  12     data = data_from_model if data_from_model is not None else extra
  13 
  14     if isinstance(type_, StrawberryOptional):
  15         if data is None:
  16             return data
  17         return _convert_from_pydantic_to_strawberry_type(
  18             type_.of_type, data_from_model=data, extra=extra
  19         )
  20     if isinstance(type_, StrawberryUnion):
  21         for option_type in type_.types:
  22             if hasattr(option_type, "_pydantic_type"):
  23                 source_type = option_type._pydantic_type  # type: ignore
  24             else:
  25                 source_type = cast(type, option_type)
  26             if isinstance(data, source_type):
  27                 return _convert_from_pydantic_to_strawberry_type(
  28                     option_type, data_from_model=data, extra=extra
  29                 )
  30     if isinstance(type_, EnumDefinition):
  31         return data
  32     if isinstance(type_, StrawberryList):
  33         items = []
  34         for index, item in enumerate(data):
  35             items.append(
  36                 _convert_from_pydantic_to_strawberry_type(
  37                     type_.of_type,
  38                     data_from_model=item,
  39                     extra=extra[index] if extra else None,
  40                 )
  41             )
  42 
  43         return items
  44 
  45     if hasattr(type_, "_type_definition"):
  46         # in the case of an interface, the concrete type may be more specific
  47         # than the type in the field definition
  48         if hasattr(type(data), "_strawberry_type"):
  49             type_ = type(data)._strawberry_type
  50         return convert_pydantic_model_to_strawberry_class(
  51             type_, model_instance=data_from_model, extra=extra
  52         )
  53 
  54     return data
  55 
  56 
  57 def convert_pydantic_model_to_strawberry_class(cls, *, model_instance=None, extra=None):
  58     extra = extra or {}
  59     kwargs = {}
  60 
  61     for field in cls._type_definition.fields:
  62         field = cast(StrawberryField, field)
  63         python_name = field.python_name
  64 
  65         data_from_extra = extra.get(python_name, None)
  66         data_from_model = (
  67             getattr(model_instance, python_name, None) if model_instance else None
  68         )
  69         kwargs[python_name] = _convert_from_pydantic_to_strawberry_type(
  70             field.type, data_from_model, extra=data_from_extra
  71         )
  72 
  73     return cls(**kwargs)
  74
  [end of strawberry/experimental/pydantic/conversion.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/experimental/pydantic/conversion.py b/strawberry/experimental/pydantic/conversion.py
  --- a/strawberry/experimental/pydantic/conversion.py
  +++ b/strawberry/experimental/pydantic/conversion.py
  @@ -66,8 +66,12 @@
           data_from_model = (
               getattr(model_instance, python_name, None) if model_instance else None
           )
  -        kwargs[python_name] = _convert_from_pydantic_to_strawberry_type(
  -            field.type, data_from_model, extra=data_from_extra
  -        )
  +
  +        # only convert and add fields to kwargs if they are present in the `__init__`
  +        # method of the class
  +        if field.init:
  +            kwargs[python_name] = _convert_from_pydantic_to_strawberry_type(
  +                field.type, data_from_model, extra=data_from_extra
  +            )
   
       return cls(**kwargs)
  
verification_info: {"golden_diff": "diff --git a/strawberry/experimental/pydantic/conversion.py b/strawberry/experimental/pydantic/conversion.py\n--- a/strawberry/experimental/pydantic/conversion.py\n+++ b/strawberry/experimental/pydantic/conversion.py\n@@ -66,8 +66,12 @@\n         data_from_model = (\n             getattr(model_instance, python_name, None) if model_instance else None\n         )\n-        kwargs[python_name] = _convert_from_pydantic_to_strawberry_type(\n-            field.type, data_from_model, extra=data_from_extra\n-        )\n+\n+        # only convert and add fields to kwargs if they are present in the `__init__`\n+        # method of the class\n+        if field.init:\n+            kwargs[python_name] = _convert_from_pydantic_to_strawberry_type(\n+                field.type, data_from_model, extra=data_from_extra\n+            )\n \n     return cls(**kwargs)\n", "issue": "from_pydantic error if pydantic models contains contains fields that are resolver field in strawberry type\nHi :),\r\ni have a pydantic model that i want to convert to strawberry type using from_pydantic() method. The pydantic model contains fields that are resolver field in the strawberry type model.\r\n\r\n```python\r\n\r\nfrom .pydantic_models import Post as PostModel\r\n\r\n# Strawberry type \r\n@strawberry.experimental.pydantic.type(name=\"Post\", model=PostModel)\r\nclass PostType:\r\n    user: Optional[LazyType[\"UserType\", \"api_gateway.user\"]] = strawberry.field(name=\"user\", resolver=resolve_user)\r\n    create_date: auto\r\n    text: auto\r\n```\r\n\r\n```python\r\n\r\n# pydantic_models.py\r\n\r\nfrom pydantic import BaseModel\r\n\r\n# pydantic model\r\nclass Post(BaseModel):\r\n    user: Optional[\"User\"]\r\n    create_date: datetime = Field(default_factory=datetime.utcnow)\r\n    text: str\r\n```\r\n\r\n**Actual Behavior**\r\n----------------------------------\r\n__init__() got an unexpected keyword argument user\r\n\r\n**Steps to Reproduce the Problem**\r\n----------------------------------\r\npydantic_post = Post(user=None, text=\"Hello World!\") #create pydantic instance\r\nposttype = PostType.from_pydantic(pydantic_post) # not work - error\r\n\r\nThis also not work:\r\npydantic_post = Post(text=\"Hello World!\")\r\nposttype = PostType.from_pydantic(pydantic_post) # also not work\r\n\r\nThx\r\n\r\n\r\n\n", "before_files": [{"content": "from typing import Union, cast\n\nfrom strawberry.enum import EnumDefinition\nfrom strawberry.field import StrawberryField\nfrom strawberry.type import StrawberryList, StrawberryOptional, StrawberryType\nfrom strawberry.union import StrawberryUnion\n\n\ndef _convert_from_pydantic_to_strawberry_type(\n    type_: Union[StrawberryType, type], data_from_model=None, extra=None\n):\n    data = data_from_model if data_from_model is not None else extra\n\n    if isinstance(type_, StrawberryOptional):\n        if data is None:\n            return data\n        return _convert_from_pydantic_to_strawberry_type(\n            type_.of_type, data_from_model=data, extra=extra\n        )\n    if isinstance(type_, StrawberryUnion):\n        for option_type in type_.types:\n            if hasattr(option_type, \"_pydantic_type\"):\n                source_type = option_type._pydantic_type  # type: ignore\n            else:\n                source_type = cast(type, option_type)\n            if isinstance(data, source_type):\n                return _convert_from_pydantic_to_strawberry_type(\n                    option_type, data_from_model=data, extra=extra\n                )\n    if isinstance(type_, EnumDefinition):\n        return data\n    if isinstance(type_, StrawberryList):\n        items = []\n        for index, item in enumerate(data):\n            items.append(\n                _convert_from_pydantic_to_strawberry_type(\n                    type_.of_type,\n                    data_from_model=item,\n                    extra=extra[index] if extra else None,\n                )\n            )\n\n        return items\n\n    if hasattr(type_, \"_type_definition\"):\n        # in the case of an interface, the concrete type may be more specific\n        # than the type in the field definition\n        if hasattr(type(data), \"_strawberry_type\"):\n            type_ = type(data)._strawberry_type\n        return convert_pydantic_model_to_strawberry_class(\n            type_, model_instance=data_from_model, extra=extra\n        )\n\n    return data\n\n\ndef convert_pydantic_model_to_strawberry_class(cls, *, model_instance=None, extra=None):\n    extra = extra or {}\n    kwargs = {}\n\n    for field in cls._type_definition.fields:\n        field = cast(StrawberryField, field)\n        python_name = field.python_name\n\n        data_from_extra = extra.get(python_name, None)\n        data_from_model = (\n            getattr(model_instance, python_name, None) if model_instance else None\n        )\n        kwargs[python_name] = _convert_from_pydantic_to_strawberry_type(\n            field.type, data_from_model, extra=data_from_extra\n        )\n\n    return cls(**kwargs)\n", "path": "strawberry/experimental/pydantic/conversion.py"}]}