strawberry-graphql 0.265.1__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/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.1
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
@@ -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.1.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
232
- strawberry_graphql-0.265.1.dist-info/METADATA,sha256=tKLR23Ny7gQstdF5V-53xqdtPjsciPtA44Jqab3DLmI,7679
233
- strawberry_graphql-0.265.1.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
234
- strawberry_graphql-0.265.1.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
235
- strawberry_graphql-0.265.1.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,,