prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Decimal scalars aren't serialized as strings when passed as numbers
  When using the `Decimal` scalar, if the value passed in is a floating point number, the value isn't serialized as a string, but as if it were still the floating point number which causes precision issues as can be seen in the working example below.
  
  
  [Working example](https://la4de.github.io/strawberry-playground/#UEsDBAoAAAAAAFaAjFQgaUU4EgAAABIAAAAQAAAAcmVxdWlyZW1lbnRzLnR4dHN0cmF3YmVycnktZ3JhcGhxbFBLAwQKAAAAAABWgIxUj3TlatIAAADSAAAACQAAAHNjaGVtYS5weWltcG9ydCBzdHJhd2JlcnJ5CmZyb20gZGVjaW1hbCBpbXBvcnQgRGVjaW1hbAoKQHN0cmF3YmVycnkudHlwZQpjbGFzcyBRdWVyeToKICAgIEBzdHJhd2JlcnJ5LmZpZWxkCiAgICBkZWYgZGVjaW1hbChzZWxmLCB2YWx1ZTogRGVjaW1hbCkgLT4gRGVjaW1hbDoKICAgICAgICByZXR1cm4gdmFsdWUKCnNjaGVtYSA9IHN0cmF3YmVycnkuU2NoZW1hKHF1ZXJ5PVF1ZXJ5KVBLAwQKAAAAAABWgIxUERrh0UMAAABDAAAACQAAAHF1ZXJ5LmdxbHsKICBkZWNpbWFsKHZhbHVlOiAzLjE0KQogIGFub3RoZXJEZWNpbWFsOiBkZWNpbWFsKHZhbHVlOiAiMy4xNCIpCn1QSwMECgAAAAAAVoCMVKi7vnMDAAAAAwAAAA4AAAB2YXJpYWJsZXMuanNvbnsKfVBLAQIUAAoAAAAAAFaAjFQgaUU4EgAAABIAAAAQAAAAAAAAAAAAAAAAAAAAAAByZXF1aXJlbWVudHMudHh0UEsBAhQACgAAAAAAVoCMVI905WrSAAAA0gAAAAkAAAAAAAAAAAAAAAAAQAAAAHNjaGVtYS5weVBLAQIUAAoAAAAAAFaAjFQRGuHRQwAAAEMAAAAJAAAAAAAAAAAAAAAAADkBAABxdWVyeS5ncWxQSwECFAAKAAAAAABWgIxUqLu+cwMAAAADAAAADgAAAAAAAAAAAAAAAACjAQAAdmFyaWFibGVzLmpzb25QSwUGAAAAAAQABADoAAAA0gEAAAAA)
  
  Actual output - `"3.140000000000000124344978758017532527446746826171875"`
  Expected output - `"3.14"`
  
  As text:
  
  ```
  @strawberry.type
  class DecimalResponse:
      value: Decimal
  
  
  @strawberry.field
  def decimals(
      dec_value: Decimal,
  ) -> DecimalResponse:
      return DecimalResponse(value=dec_value)
   ```
  ```
  mutation decimals($dec_value: Decimal!) {
    decimals(
      decValue: $dec_value
    ) {
      ... on DecimalResponse {
        value
      }
    }
  }
  {
      "dec_value": 3.14
  }
  ```
  
  
  --- 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/schema/types/base_scalars.py`
  Content:
  ```
  1 import datetime
  2 import decimal
  3 import uuid
  4 from operator import methodcaller
  5 from typing import Callable
  6 
  7 import dateutil.parser
  8 
  9 from graphql import GraphQLError
  10 
  11 from strawberry.custom_scalar import scalar
  12 
  13 
  14 def wrap_parser(parser: Callable, type_: str) -> Callable:
  15     def inner(value: str):
  16         try:
  17             return parser(value)
  18         except ValueError as e:
  19             raise GraphQLError(f'Value cannot represent a {type_}: "{value}". {e}')
  20 
  21     return inner
  22 
  23 
  24 def parse_decimal(value: str) -> decimal.Decimal:
  25     try:
  26         return decimal.Decimal(value)
  27     except decimal.DecimalException:
  28         raise GraphQLError(f'Value cannot represent a Decimal: "{value}".')
  29 
  30 
  31 isoformat = methodcaller("isoformat")
  32 
  33 
  34 Date = scalar(
  35     datetime.date,
  36     name="Date",
  37     description="Date (isoformat)",
  38     serialize=isoformat,
  39     parse_value=wrap_parser(datetime.date.fromisoformat, "Date"),
  40 )
  41 DateTime = scalar(
  42     datetime.datetime,
  43     name="DateTime",
  44     description="Date with time (isoformat)",
  45     serialize=isoformat,
  46     parse_value=wrap_parser(dateutil.parser.isoparse, "DateTime"),
  47 )
  48 Time = scalar(
  49     datetime.time,
  50     name="Time",
  51     description="Time (isoformat)",
  52     serialize=isoformat,
  53     parse_value=wrap_parser(datetime.time.fromisoformat, "Time"),
  54 )
  55 
  56 Decimal = scalar(
  57     decimal.Decimal,
  58     name="Decimal",
  59     description="Decimal (fixed-point)",
  60     serialize=str,
  61     parse_value=parse_decimal,
  62 )
  63 
  64 UUID = scalar(
  65     uuid.UUID,
  66     name="UUID",
  67     serialize=str,
  68     parse_value=wrap_parser(uuid.UUID, "UUID"),
  69 )
  70 
  71 
  72 def _verify_void(x) -> None:
  73     if x is not None:
  74         raise ValueError(f"Expected 'None', got '{x}'")
  75 
  76 
  77 Void = scalar(
  78     type(None),
  79     name="Void",
  80     serialize=_verify_void,
  81     parse_value=_verify_void,
  82     description="Represents NULL values",
  83 )
  84
  ```
  --- 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/schema/types/base_scalars.py b/strawberry/schema/types/base_scalars.py
  --- a/strawberry/schema/types/base_scalars.py
  +++ b/strawberry/schema/types/base_scalars.py
  @@ -21,9 +21,9 @@
       return inner
   
   
  -def parse_decimal(value: str) -> decimal.Decimal:
  +def parse_decimal(value: object) -> decimal.Decimal:
       try:
  -        return decimal.Decimal(value)
  +        return decimal.Decimal(str(value))
       except decimal.DecimalException:
           raise GraphQLError(f'Value cannot represent a Decimal: "{value}".')
  
verification_info: {"golden_diff": "diff --git a/strawberry/schema/types/base_scalars.py b/strawberry/schema/types/base_scalars.py\n--- a/strawberry/schema/types/base_scalars.py\n+++ b/strawberry/schema/types/base_scalars.py\n@@ -21,9 +21,9 @@\n     return inner\n \n \n-def parse_decimal(value: str) -> decimal.Decimal:\n+def parse_decimal(value: object) -> decimal.Decimal:\n     try:\n-        return decimal.Decimal(value)\n+        return decimal.Decimal(str(value))\n     except decimal.DecimalException:\n         raise GraphQLError(f'Value cannot represent a Decimal: \"{value}\".')\n", "issue": "Decimal scalars aren't serialized as strings when passed as numbers\nWhen using the `Decimal` scalar, if the value passed in is a floating point number, the value isn't serialized as a string, but as if it were still the floating point number which causes precision issues as can be seen in the working example below.\r\n\r\n\r\n[Working example](https://la4de.github.io/strawberry-playground/#UEsDBAoAAAAAAFaAjFQgaUU4EgAAABIAAAAQAAAAcmVxdWlyZW1lbnRzLnR4dHN0cmF3YmVycnktZ3JhcGhxbFBLAwQKAAAAAABWgIxUj3TlatIAAADSAAAACQAAAHNjaGVtYS5weWltcG9ydCBzdHJhd2JlcnJ5CmZyb20gZGVjaW1hbCBpbXBvcnQgRGVjaW1hbAoKQHN0cmF3YmVycnkudHlwZQpjbGFzcyBRdWVyeToKICAgIEBzdHJhd2JlcnJ5LmZpZWxkCiAgICBkZWYgZGVjaW1hbChzZWxmLCB2YWx1ZTogRGVjaW1hbCkgLT4gRGVjaW1hbDoKICAgICAgICByZXR1cm4gdmFsdWUKCnNjaGVtYSA9IHN0cmF3YmVycnkuU2NoZW1hKHF1ZXJ5PVF1ZXJ5KVBLAwQKAAAAAABWgIxUERrh0UMAAABDAAAACQAAAHF1ZXJ5LmdxbHsKICBkZWNpbWFsKHZhbHVlOiAzLjE0KQogIGFub3RoZXJEZWNpbWFsOiBkZWNpbWFsKHZhbHVlOiAiMy4xNCIpCn1QSwMECgAAAAAAVoCMVKi7vnMDAAAAAwAAAA4AAAB2YXJpYWJsZXMuanNvbnsKfVBLAQIUAAoAAAAAAFaAjFQgaUU4EgAAABIAAAAQAAAAAAAAAAAAAAAAAAAAAAByZXF1aXJlbWVudHMudHh0UEsBAhQACgAAAAAAVoCMVI905WrSAAAA0gAAAAkAAAAAAAAAAAAAAAAAQAAAAHNjaGVtYS5weVBLAQIUAAoAAAAAAFaAjFQRGuHRQwAAAEMAAAAJAAAAAAAAAAAAAAAAADkBAABxdWVyeS5ncWxQSwECFAAKAAAAAABWgIxUqLu+cwMAAAADAAAADgAAAAAAAAAAAAAAAACjAQAAdmFyaWFibGVzLmpzb25QSwUGAAAAAAQABADoAAAA0gEAAAAA)\r\n\r\nActual output - `\"3.140000000000000124344978758017532527446746826171875\"`\r\nExpected output - `\"3.14\"`\r\n\r\nAs text:\r\n\r\n```\r\n@strawberry.type\r\nclass DecimalResponse:\r\n    value: Decimal\r\n\r\n\r\n@strawberry.field\r\ndef decimals(\r\n    dec_value: Decimal,\r\n) -> DecimalResponse:\r\n    return DecimalResponse(value=dec_value)\r\n ```\r\n```\r\nmutation decimals($dec_value: Decimal!) {\r\n  decimals(\r\n    decValue: $dec_value\r\n  ) {\r\n    ... on DecimalResponse {\r\n      value\r\n    }\r\n  }\r\n}\r\n{\r\n    \"dec_value\": 3.14\r\n}\r\n```\r\n\n", "before_files": [{"content": "import datetime\nimport decimal\nimport uuid\nfrom operator import methodcaller\nfrom typing import Callable\n\nimport dateutil.parser\n\nfrom graphql import GraphQLError\n\nfrom strawberry.custom_scalar import scalar\n\n\ndef wrap_parser(parser: Callable, type_: str) -> Callable:\n    def inner(value: str):\n        try:\n            return parser(value)\n        except ValueError as e:\n            raise GraphQLError(f'Value cannot represent a {type_}: \"{value}\". {e}')\n\n    return inner\n\n\ndef parse_decimal(value: str) -> decimal.Decimal:\n    try:\n        return decimal.Decimal(value)\n    except decimal.DecimalException:\n        raise GraphQLError(f'Value cannot represent a Decimal: \"{value}\".')\n\n\nisoformat = methodcaller(\"isoformat\")\n\n\nDate = scalar(\n    datetime.date,\n    name=\"Date\",\n    description=\"Date (isoformat)\",\n    serialize=isoformat,\n    parse_value=wrap_parser(datetime.date.fromisoformat, \"Date\"),\n)\nDateTime = scalar(\n    datetime.datetime,\n    name=\"DateTime\",\n    description=\"Date with time (isoformat)\",\n    serialize=isoformat,\n    parse_value=wrap_parser(dateutil.parser.isoparse, \"DateTime\"),\n)\nTime = scalar(\n    datetime.time,\n    name=\"Time\",\n    description=\"Time (isoformat)\",\n    serialize=isoformat,\n    parse_value=wrap_parser(datetime.time.fromisoformat, \"Time\"),\n)\n\nDecimal = scalar(\n    decimal.Decimal,\n    name=\"Decimal\",\n    description=\"Decimal (fixed-point)\",\n    serialize=str,\n    parse_value=parse_decimal,\n)\n\nUUID = scalar(\n    uuid.UUID,\n    name=\"UUID\",\n    serialize=str,\n    parse_value=wrap_parser(uuid.UUID, \"UUID\"),\n)\n\n\ndef _verify_void(x) -> None:\n    if x is not None:\n        raise ValueError(f\"Expected 'None', got '{x}'\")\n\n\nVoid = scalar(\n    type(None),\n    name=\"Void\",\n    serialize=_verify_void,\n    parse_value=_verify_void,\n    description=\"Represents NULL values\",\n)\n", "path": "strawberry/schema/types/base_scalars.py"}], "after_files": [{"content": "import datetime\nimport decimal\nimport uuid\nfrom operator import methodcaller\nfrom typing import Callable\n\nimport dateutil.parser\n\nfrom graphql import GraphQLError\n\nfrom strawberry.custom_scalar import scalar\n\n\ndef wrap_parser(parser: Callable, type_: str) -> Callable:\n    def inner(value: str):\n        try:\n            return parser(value)\n        except ValueError as e:\n            raise GraphQLError(f'Value cannot represent a {type_}: \"{value}\". {e}')\n\n    return inner\n\n\ndef parse_decimal(value: object) -> decimal.Decimal:\n    try:\n        return decimal.Decimal(str(value))\n    except decimal.DecimalException:\n        raise GraphQLError(f'Value cannot represent a Decimal: \"{value}\".')\n\n\nisoformat = methodcaller(\"isoformat\")\n\n\nDate = scalar(\n    datetime.date,\n    name=\"Date\",\n    description=\"Date (isoformat)\",\n    serialize=isoformat,\n    parse_value=wrap_parser(datetime.date.fromisoformat, \"Date\"),\n)\nDateTime = scalar(\n    datetime.datetime,\n    name=\"DateTime\",\n    description=\"Date with time (isoformat)\",\n    serialize=isoformat,\n    parse_value=wrap_parser(dateutil.parser.isoparse, \"DateTime\"),\n)\nTime = scalar(\n    datetime.time,\n    name=\"Time\",\n    description=\"Time (isoformat)\",\n    serialize=isoformat,\n    parse_value=wrap_parser(datetime.time.fromisoformat, \"Time\"),\n)\n\nDecimal = scalar(\n    decimal.Decimal,\n    name=\"Decimal\",\n    description=\"Decimal (fixed-point)\",\n    serialize=str,\n    parse_value=parse_decimal,\n)\n\nUUID = scalar(\n    uuid.UUID,\n    name=\"UUID\",\n    serialize=str,\n    parse_value=wrap_parser(uuid.UUID, \"UUID\"),\n)\n\n\ndef _verify_void(x) -> None:\n    if x is not None:\n        raise ValueError(f\"Expected 'None', got '{x}'\")\n\n\nVoid = scalar(\n    type(None),\n    name=\"Void\",\n    serialize=_verify_void,\n    parse_value=_verify_void,\n    description=\"Represents NULL values\",\n)\n", "path": "strawberry/schema/types/base_scalars.py"}]}