strawberry-graphql 0.265.0__py3-none-any.whl → 0.266.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,6 +20,7 @@ if TYPE_CHECKING:
20
20
 
21
21
  def enum_value(
22
22
  value: Any,
23
+ name: Optional[str] = None,
23
24
  deprecation_reason: Optional[str] = None,
24
25
  directives: Iterable[object] = (),
25
26
  inaccessible: bool = False,
@@ -35,7 +36,12 @@ def enum_value(
35
36
  if tags:
36
37
  directives.extend(Tag(name=tag) for tag in tags)
37
38
 
38
- return base_enum_value(value, deprecation_reason, directives)
39
+ return base_enum_value(
40
+ value=value,
41
+ name=name,
42
+ deprecation_reason=deprecation_reason,
43
+ directives=directives,
44
+ )
39
45
 
40
46
 
41
47
  @overload
strawberry/sanic/utils.py CHANGED
@@ -1,6 +1,5 @@
1
1
  from __future__ import annotations
2
2
 
3
- from io import BytesIO
4
3
  from typing import TYPE_CHECKING, Any, Optional, Union, cast
5
4
 
6
5
  if TYPE_CHECKING:
@@ -8,7 +7,7 @@ if TYPE_CHECKING:
8
7
 
9
8
 
10
9
  def convert_request_to_files_dict(request: Request) -> dict[str, Any]:
11
- """Converts the request.files dictionary to a dictionary of BytesIO objects.
10
+ """Converts the request.files dictionary to a dictionary of sanic Request objects.
12
11
 
13
12
  `request.files` has the following format, even if only a single file is uploaded:
14
13
 
@@ -27,12 +26,12 @@ def convert_request_to_files_dict(request: Request) -> dict[str, Any]:
27
26
  if not request_files:
28
27
  return {}
29
28
 
30
- files_dict: dict[str, Union[BytesIO, list[BytesIO]]] = {}
29
+ files_dict: dict[str, Union[File, list[File]]] = {}
31
30
 
32
31
  for field_name, file_list in request_files.items():
33
32
  assert len(file_list) == 1
34
33
 
35
- files_dict[field_name] = BytesIO(file_list[0].body)
34
+ files_dict[field_name] = file_list[0]
36
35
 
37
36
  return files_dict
38
37
 
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Optional, Tuple, Union, cast
3
+ from typing import TYPE_CHECKING, Optional, Union, cast
4
4
  from typing_extensions import Protocol
5
5
 
6
6
  from strawberry.directive import StrawberryDirective
@@ -106,7 +106,7 @@ class NameConverter:
106
106
  return union.graphql_name
107
107
 
108
108
  name = ""
109
- types: Tuple[StrawberryType, ...] = union.types
109
+ types: tuple[StrawberryType, ...] = union.types
110
110
 
111
111
  if union.concrete_of and union.concrete_of.graphql_name:
112
112
  concrete_of_types = set(union.concrete_of.types)
strawberry/types/enum.py CHANGED
@@ -50,6 +50,7 @@ class EnumDefinition(StrawberryType):
50
50
  @dataclasses.dataclass
51
51
  class EnumValueDefinition:
52
52
  value: Any
53
+ graphql_name: Optional[str] = None
53
54
  deprecation_reason: Optional[str] = None
54
55
  directives: Iterable[object] = ()
55
56
  description: Optional[str] = None
@@ -60,6 +61,7 @@ class EnumValueDefinition:
60
61
 
61
62
  def enum_value(
62
63
  value: Any,
64
+ name: Optional[str] = None,
63
65
  deprecation_reason: Optional[str] = None,
64
66
  directives: Iterable[object] = (),
65
67
  description: Optional[str] = None,
@@ -68,6 +70,7 @@ def enum_value(
68
70
 
69
71
  Args:
70
72
  value: The value of the enum member.
73
+ name: The GraphQL name of the enum member.
71
74
  deprecation_reason: The deprecation reason of the enum member,
72
75
  setting this will mark the enum member as deprecated.
73
76
  directives: The directives to attach to the enum member.
@@ -90,6 +93,7 @@ def enum_value(
90
93
  """
91
94
  return EnumValueDefinition(
92
95
  value=value,
96
+ graphql_name=name,
93
97
  deprecation_reason=deprecation_reason,
94
98
  directives=directives,
95
99
  description=description,
@@ -123,12 +127,16 @@ def _process_enum(
123
127
  item_directives = item_value.directives
124
128
  enum_value_description = item_value.description
125
129
  deprecation_reason = item_value.deprecation_reason
126
- item_value = item_value.value
127
130
 
128
131
  # update _value2member_map_ so that doing `MyEnum.MY_VALUE` and
129
132
  # `MyEnum['MY_VALUE']` both work
130
- cls._value2member_map_[item_value] = item
131
- cls._member_map_[item_name]._value_ = item_value
133
+ cls._value2member_map_[item_value.value] = item
134
+ cls._member_map_[item_name]._value_ = item_value.value
135
+
136
+ if item_value.graphql_name:
137
+ item_name = item_value.graphql_name
138
+
139
+ item_value = item_value.value
132
140
 
133
141
  value = EnumValue(
134
142
  item_name,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: strawberry-graphql
3
- Version: 0.265.0
3
+ Version: 0.266.0
4
4
  Summary: A library for creating GraphQL APIs
5
5
  License: MIT
6
6
  Keywords: graphql,api,rest,starlette,async
@@ -113,7 +113,7 @@ strawberry/fastapi/context.py,sha256=O_cDNppfUJJecM0ZU_RJ-dhdF0o1x39JfYvYg-7uob4
113
113
  strawberry/fastapi/router.py,sha256=cfRGP1SL_QaSNjCk3Zi7YDQte1EsIljvqTDB1J0O4fQ,12018
114
114
  strawberry/federation/__init__.py,sha256=Pw01N0rG9o0NaUxXLMNGeW5oLENeWVx_d8Kuef1ES4s,549
115
115
  strawberry/federation/argument.py,sha256=rs71S1utiNUd4XOLRa9KVtSMA3yqvKJnR_qdJqX6PPM,860
116
- strawberry/federation/enum.py,sha256=MdtblT4Z8_-2L8gUdo0ROnw3aY8RAAtTvyfHbCBBPrA,3033
116
+ strawberry/federation/enum.py,sha256=geyNA00IjUBroBc6EFrTK0n6DGIVyKOeSE_3aqiwUaQ,3151
117
117
  strawberry/federation/field.py,sha256=pcFgl33xgJcunb6TxfOPuzsAQTGbbzjKi41SUUSV3w4,8914
118
118
  strawberry/federation/mutation.py,sha256=5t2E419m4K2W6LoWEOzWgMdL2J0PwHnsffYkpChqqDQ,67
119
119
  strawberry/federation/object_type.py,sha256=tuUn_YqtOcvivVSHrXESSFr2kae79xW_SLUV3oNINdE,9381
@@ -158,7 +158,7 @@ strawberry/relay/utils.py,sha256=-QxroxkSYtFnMYsJyTyfIi0I1fLtjnt6siW0kLNiyfs,590
158
158
  strawberry/resolvers.py,sha256=Vdidc3YFc4-olSQZD_xQ1icyAFbyzqs_8I3eSpMFlA4,260
159
159
  strawberry/sanic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
160
160
  strawberry/sanic/context.py,sha256=qN7I9K_qIqgdbG_FbDl8XMb9aM1PyjIxSo8IAg2Uq8o,844
161
- strawberry/sanic/utils.py,sha256=DiHWMfaulaP2QSi79NwI847xkUiBybvLdr0VSbKAwNQ,1044
161
+ strawberry/sanic/utils.py,sha256=XjUVBFuBWfECBCZbx_YtrjQnFTUyIGTo7aISIeB22Gc,1007
162
162
  strawberry/sanic/views.py,sha256=F5ZrKt-R3135evKLfhQuPd1isOexI0Lrzevm_6Te4Eg,7069
163
163
  strawberry/scalars.py,sha256=FcFTbu-yKbBfPCuAfXNa6DbTbEzF3eiQHs5nlt6GJdM,2234
164
164
  strawberry/schema/__init__.py,sha256=u1QCyDVQExUVDA20kyosKPz3TS5HMCN2NrXclhiFAL4,92
@@ -166,7 +166,7 @@ strawberry/schema/base.py,sha256=q5UAw6do4Ele5Cf8dNAouiPjNmZoCBNFqh5Vl05caCI,386
166
166
  strawberry/schema/compat.py,sha256=9qJ0lhYJeaN43ayFgVz708ZMvedBhofiTSw9kpFqmjU,1830
167
167
  strawberry/schema/config.py,sha256=6BpCbNNCuekGgiKEPt2mliMqLH_wIjJmSW0tLbnJwk4,924
168
168
  strawberry/schema/exceptions.py,sha256=rqVNb_oYrKM0dHPgvAemqCG6Um282LPPu4zwQ5cZqs4,584
169
- strawberry/schema/name_converter.py,sha256=MK4CqCtboyWnjIwit0tx9VCoS75LYTz4O5YAL3HBpiA,6952
169
+ strawberry/schema/name_converter.py,sha256=xFOXEgqldFkxXRkIQvsJN1dPkWbEUaIrTYNOMYSEVwQ,6945
170
170
  strawberry/schema/schema.py,sha256=qthZttzb9a0GEcwh7trqBKHmuPXOgQlnceqiCRPj4_s,34566
171
171
  strawberry/schema/schema_converter.py,sha256=OkJaYrWKGqcxdhoTeuf0aGqiTnWtDuZwYddY5uBlf8Q,37521
172
172
  strawberry/schema/types/__init__.py,sha256=oHO3COWhL3L1KLYCJNY1XFf5xt2GGtHiMC-UaYbFfnA,68
@@ -199,7 +199,7 @@ strawberry/types/arguments.py,sha256=Ny4meiKYtcXpAV0rFKWJXOJK5iQB-zs-23n0w8S8zVc
199
199
  strawberry/types/auto.py,sha256=WZ2cQAI8nREUigBzpzFqIKGjJ_C2VqpAPNe8vPjTciM,3007
200
200
  strawberry/types/base.py,sha256=rx7J9dGUCUCap0lgb5Yyb_WXnB95FZEY6gQcYasiI9w,14907
201
201
  strawberry/types/cast.py,sha256=fx86MkLW77GIximBAwUk5vZxSGwDqUA6XicXvz8EXwQ,916
202
- strawberry/types/enum.py,sha256=gy4gZvhprZqXJrjeBtokW-0CUcOl6BUOaI2apOSn2mc,5974
202
+ strawberry/types/enum.py,sha256=IcCz0FLswJtDC_bU8aG1cjreawcqHywAzzVRBZUSAqs,6229
203
203
  strawberry/types/execution.py,sha256=Ylc0lH0nyHyQW509mVqBh2sIN5qpf4cJtt8QhVmWGgI,3749
204
204
  strawberry/types/field.py,sha256=vxb7JvkHfRmDCYsjhDmVnO2lMbtSOteQm3jQUeSFu6g,21605
205
205
  strawberry/types/fields/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -228,8 +228,8 @@ strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,7
228
228
  strawberry/utils/operation.py,sha256=s7ajvLg_q6v2mg47kEMQPjO_J-XluMKTCwo4d47mGvE,1195
229
229
  strawberry/utils/str_converters.py,sha256=-eH1Cl16IO_wrBlsGM-km4IY0IKsjhjnSNGRGOwQjVM,897
230
230
  strawberry/utils/typing.py,sha256=Xmnhwvnw8RIQVIc5D5iI4_9qM4Thpk7tWx8xf-RW_So,13383
231
- strawberry_graphql-0.265.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
232
- strawberry_graphql-0.265.0.dist-info/METADATA,sha256=Ds08QsahrOH09gzBALiyESIbKiVn8CHMnsf-OLW_kLk,7679
233
- strawberry_graphql-0.265.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
234
- strawberry_graphql-0.265.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
235
- strawberry_graphql-0.265.0.dist-info/RECORD,,
231
+ strawberry_graphql-0.266.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
232
+ strawberry_graphql-0.266.0.dist-info/METADATA,sha256=NHtUpiQOm0Urof6R0H9vRIlBJzRpQyVDq3BEAgBHoGs,7679
233
+ strawberry_graphql-0.266.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
234
+ strawberry_graphql-0.266.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
235
+ strawberry_graphql-0.266.0.dist-info/RECORD,,