strawberry-graphql 0.275.3__py3-none-any.whl → 0.275.5__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.
@@ -198,8 +198,6 @@ class AsyncBaseHTTPView(
198
198
  if not self.allow_queries_via_get and request_adapter.method == "GET":
199
199
  allowed_operation_types = allowed_operation_types - {OperationType.QUERY}
200
200
 
201
- assert self.schema
202
-
203
201
  if request_data.protocol == "multipart-subscription":
204
202
  return await self.schema.subscribe(
205
203
  request_data.query, # type: ignore
@@ -291,7 +289,7 @@ class AsyncBaseHTTPView(
291
289
  view=self,
292
290
  websocket=websocket,
293
291
  context=context,
294
- root_value=root_value, # type: ignore
292
+ root_value=root_value,
295
293
  schema=self.schema,
296
294
  debug=self.debug,
297
295
  connection_init_wait_timeout=self.connection_init_wait_timeout,
@@ -301,7 +299,7 @@ class AsyncBaseHTTPView(
301
299
  view=self,
302
300
  websocket=websocket,
303
301
  context=context,
304
- root_value=root_value, # type: ignore
302
+ root_value=root_value,
305
303
  schema=self.schema,
306
304
  debug=self.debug,
307
305
  keep_alive=self.keep_alive,
@@ -536,9 +534,16 @@ class AsyncBaseHTTPView(
536
534
  "The GraphQL operation's `query` must be a string or null, if provided.",
537
535
  )
538
536
 
537
+ variables = data.get("variables")
538
+ if not isinstance(variables, (dict, type(None))):
539
+ raise HTTPException(
540
+ 400,
541
+ "The GraphQL operation's `variables` must be an object or null, if provided.",
542
+ )
543
+
539
544
  return GraphQLRequestData(
540
545
  query=query,
541
- variables=data.get("variables"),
546
+ variables=variables,
542
547
  operation_name=data.get("operationName"),
543
548
  extensions=data.get("extensions"),
544
549
  protocol=protocol,
@@ -116,8 +116,6 @@ class SyncBaseHTTPView(
116
116
  if not self.allow_queries_via_get and request_adapter.method == "GET":
117
117
  allowed_operation_types = allowed_operation_types - {OperationType.QUERY}
118
118
 
119
- assert self.schema
120
-
121
119
  return self.schema.execute_sync(
122
120
  request_data.query,
123
121
  root_value=root_value,
@@ -161,9 +159,16 @@ class SyncBaseHTTPView(
161
159
  "The GraphQL operation's `query` must be a string or null, if provided.",
162
160
  )
163
161
 
162
+ variables = data.get("variables")
163
+ if not isinstance(variables, (dict, type(None))):
164
+ raise HTTPException(
165
+ 400,
166
+ "The GraphQL operation's `variables` must be an object or null, if provided.",
167
+ )
168
+
164
169
  return GraphQLRequestData(
165
170
  query=query,
166
- variables=data.get("variables"),
171
+ variables=variables,
167
172
  operation_name=data.get("operationName"),
168
173
  extensions=data.get("extensions"),
169
174
  )
@@ -53,7 +53,7 @@ class BaseGraphQLTransportWSHandler(Generic[Context, RootValue]):
53
53
  view: AsyncBaseHTTPView[Any, Any, Any, Any, Any, Context, RootValue],
54
54
  websocket: AsyncWebSocketAdapter,
55
55
  context: Context,
56
- root_value: RootValue,
56
+ root_value: Optional[RootValue],
57
57
  schema: BaseSchema,
58
58
  debug: bool,
59
59
  connection_init_wait_timeout: timedelta,
@@ -42,7 +42,7 @@ class BaseGraphQLWSHandler(Generic[Context, RootValue]):
42
42
  view: AsyncBaseHTTPView[Any, Any, Any, Any, Any, Context, RootValue],
43
43
  websocket: AsyncWebSocketAdapter,
44
44
  context: Context,
45
- root_value: RootValue,
45
+ root_value: Optional[RootValue],
46
46
  schema: BaseSchema,
47
47
  debug: bool,
48
48
  keep_alive: bool,
@@ -144,12 +144,52 @@ class StrawberryArgument:
144
144
  return isinstance(self.type, StrawberryMaybe)
145
145
 
146
146
 
147
+ def _is_leaf_type(
148
+ type_: Union[StrawberryType, type],
149
+ scalar_registry: Mapping[object, Union[ScalarWrapper, ScalarDefinition]],
150
+ skip_classes: tuple[type, ...] = (),
151
+ ) -> bool:
152
+ if type_ in skip_classes:
153
+ return False
154
+
155
+ if is_scalar(type_, scalar_registry):
156
+ return True
157
+
158
+ if isinstance(type_, EnumDefinition):
159
+ return True
160
+
161
+ if isinstance(type_, LazyType):
162
+ return _is_leaf_type(type_.resolve_type(), scalar_registry)
163
+
164
+ if hasattr(type_, "_enum_definition"):
165
+ enum_definition: EnumDefinition = type_._enum_definition
166
+ return _is_leaf_type(enum_definition, scalar_registry)
167
+
168
+ return False
169
+
170
+
171
+ def _is_optional_leaf_type(
172
+ type_: Union[StrawberryType, type],
173
+ scalar_registry: Mapping[object, Union[ScalarWrapper, ScalarDefinition]],
174
+ skip_classes: tuple[type, ...] = (),
175
+ ) -> bool:
176
+ if type_ in skip_classes:
177
+ return False
178
+
179
+ if isinstance(type_, StrawberryOptional):
180
+ return _is_leaf_type(type_.of_type, scalar_registry, skip_classes)
181
+
182
+ return False
183
+
184
+
147
185
  def convert_argument(
148
186
  value: object,
149
187
  type_: Union[StrawberryType, type],
150
188
  scalar_registry: Mapping[object, Union[ScalarWrapper, ScalarDefinition]],
151
189
  config: StrawberryConfig,
152
190
  ) -> object:
191
+ from strawberry.relay.types import GlobalID
192
+
153
193
  # TODO: move this somewhere else and make it first class
154
194
  if isinstance(type_, StrawberryOptional):
155
195
  res = convert_argument(value, type_.of_type, scalar_registry, config)
@@ -164,22 +204,27 @@ def convert_argument(
164
204
 
165
205
  if isinstance(type_, StrawberryList):
166
206
  value_list = cast("Iterable", value)
207
+
208
+ if _is_leaf_type(
209
+ type_.of_type, scalar_registry, skip_classes=(GlobalID,)
210
+ ) or _is_optional_leaf_type(
211
+ type_.of_type, scalar_registry, skip_classes=(GlobalID,)
212
+ ):
213
+ return value_list
214
+
215
+ value_list = cast("Iterable", value)
216
+
167
217
  return [
168
218
  convert_argument(x, type_.of_type, scalar_registry, config)
169
219
  for x in value_list
170
220
  ]
171
221
 
172
- if is_scalar(type_, scalar_registry):
173
- from strawberry.relay.types import GlobalID
174
-
222
+ if _is_leaf_type(type_, scalar_registry):
175
223
  if type_ is GlobalID:
176
224
  return GlobalID.from_id(value) # type: ignore
177
225
 
178
226
  return value
179
227
 
180
- if isinstance(type_, EnumDefinition):
181
- return value
182
-
183
228
  if isinstance(type_, LazyType):
184
229
  return convert_argument(value, type_.resolve_type(), scalar_registry, config)
185
230
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: strawberry-graphql
3
- Version: 0.275.3
3
+ Version: 0.275.5
4
4
  Summary: A library for creating GraphQL APIs
5
5
  License: MIT
6
6
  Keywords: graphql,api,rest,starlette,async
@@ -135,12 +135,12 @@ strawberry/file_uploads/utils.py,sha256=-c6TbqUI-Dkb96hWCrZabh6TL2OabBuQNkCarOqg
135
135
  strawberry/flask/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
136
136
  strawberry/flask/views.py,sha256=MCvAsNgTZLU8RvTYKWfnLU2w7Wv1ZZpxW9W3TyTZuPY,6355
137
137
  strawberry/http/__init__.py,sha256=ytAirKk7K7D5knY21tpCGeZ-sCPgwMsijL5AxmOy-94,1163
138
- strawberry/http/async_base_view.py,sha256=FPQLQ_JBCFIRhOn4wTyymNaOcB0BTGjvHy-ek51tWb4,20358
138
+ strawberry/http/async_base_view.py,sha256=tEwuCb2VmyfY1QOXCPzXLpnvoWAGId0qHeYd-coAQX8,20550
139
139
  strawberry/http/base.py,sha256=MiX0-RqOkhRvlfpmuvgTHp4tygbUmG8fnLc0uCrOllU,2550
140
140
  strawberry/http/exceptions.py,sha256=9E2dreS1crRoJVUEPuHyx23NcDELDHNzkAOa-rGv-8I,348
141
141
  strawberry/http/ides.py,sha256=WjU0nsMDgr3Bd1ebWkUEkO2d1hk0dI16mLqXyCHqklA,613
142
142
  strawberry/http/parse_content_type.py,sha256=CYHO8F9b9DP1gJ1xxPjc9L2GkBwsyC1O_GCEp1QOuG0,381
143
- strawberry/http/sync_base_view.py,sha256=vD69LL1s_xKxxbR8fjZfE4Y2WAbJyhD6VgpORF_JmJs,7658
143
+ strawberry/http/sync_base_view.py,sha256=j7lJIc6nbhwHx80evpLkR7m7i-uX9qNdgrL3CdpvEZg,7882
144
144
  strawberry/http/temporal_response.py,sha256=HTt65g-YxqlPGxjqvH5bzGoU1b3CctVR-9cmCRo5dUo,196
145
145
  strawberry/http/types.py,sha256=H0wGOdCO-5tNKZM_6cAtNRwZAjoEXnAC5N0Q7b70AtU,398
146
146
  strawberry/http/typevars.py,sha256=Uu6NkKe3h7o29ZWwldq6sJy4ioSSeXODTCDRvY2hUpE,489
@@ -188,10 +188,10 @@ strawberry/static/pathfinder.html,sha256=0DPx9AmJ2C_sJstFXnWOz9k5tVQHeHaK7qdVY4l
188
188
  strawberry/subscriptions/__init__.py,sha256=1VGmiCzFepqRFyCikagkUoHHdoTG3XYlFu9GafoQMws,170
189
189
  strawberry/subscriptions/protocols/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
190
190
  strawberry/subscriptions/protocols/graphql_transport_ws/__init__.py,sha256=wN6dkMu6WiaIZTE19PGoN9xXpIN_RdDE_q7F7ZgjCxk,138
191
- strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py,sha256=XJYPq_Nl6PWYu-u_uAmh-AO1k2wD3gAQjGMhRjkcwbo,15475
191
+ strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py,sha256=Uy7UWPAgbCEIZfMs1R6RDIStLkHCM33Zsc0sMpgDwrc,15485
192
192
  strawberry/subscriptions/protocols/graphql_transport_ws/types.py,sha256=N9r2mXg5jmmjYoZV5rWf3lAzgylCOUrbKGmClXCoOso,2169
193
193
  strawberry/subscriptions/protocols/graphql_ws/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
194
- strawberry/subscriptions/protocols/graphql_ws/handlers.py,sha256=4o_ptDXL1gMLVQUfxJYO8Xfm_I3gt-Y1Z2CsOb7K1yw,8658
194
+ strawberry/subscriptions/protocols/graphql_ws/handlers.py,sha256=6Rz47q-VbzTVyL48hgHYoGpT1MRMytFi2SDGreD7axw,8668
195
195
  strawberry/subscriptions/protocols/graphql_ws/types.py,sha256=Uumiz-1O5qQnx-ERBaQtaf7db5yx-V9LMypOn9oGKwM,2003
196
196
  strawberry/test/__init__.py,sha256=lKVbKJDBnrYSPYHIKrg54UpaZcSoL93Z01zOpA1IzZM,115
197
197
  strawberry/test/client.py,sha256=ILAttb6A3jplH5wJNMeyyT1u_Q8KnollfpYLP_BVZR4,6438
@@ -199,7 +199,7 @@ strawberry/tools/__init__.py,sha256=pdGpZx8wpq03VfUZJyF9JtYxZhGqzzxCiipsalWxJX4,
199
199
  strawberry/tools/create_type.py,sha256=y10LgJnWDFtZB-xHLqpVg5ySqvz5KSFC6PNflogie1Q,2329
200
200
  strawberry/tools/merge_types.py,sha256=hUMRRNM28FyPp70jRA3d4svv9WoEBjaNpihBt3DaY0I,1023
201
201
  strawberry/types/__init__.py,sha256=baWEdDkkmCcITOhkg2hNUOenrNV1OYdxGE5qgvIRwwU,351
202
- strawberry/types/arguments.py,sha256=DVouyH70uvTcFP3PmRzo8QdMThoqXdigJbWE9Lgn5pU,9849
202
+ strawberry/types/arguments.py,sha256=Qe3bpKjJWsrN7Qh9kOr0ZjrwDVc_nb2VFWqL22XJ4II,11129
203
203
  strawberry/types/auto.py,sha256=WZ2cQAI8nREUigBzpzFqIKGjJ_C2VqpAPNe8vPjTciM,3007
204
204
  strawberry/types/base.py,sha256=Bfa-5Wen8qR7m6tlSMRRGlGE-chRGMHjQMopfNdbbrk,15197
205
205
  strawberry/types/cast.py,sha256=fx86MkLW77GIximBAwUk5vZxSGwDqUA6XicXvz8EXwQ,916
@@ -234,8 +234,8 @@ strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,7
234
234
  strawberry/utils/operation.py,sha256=ZgVOw3K2jQuLjNOYUHauF7itJD0QDNoPw9PBi0IYf6k,1234
235
235
  strawberry/utils/str_converters.py,sha256=-eH1Cl16IO_wrBlsGM-km4IY0IKsjhjnSNGRGOwQjVM,897
236
236
  strawberry/utils/typing.py,sha256=SDvX-Du-9HAV3-XXjqi7Q5f5qPDDFd_gASIITiwBQT4,14073
237
- strawberry_graphql-0.275.3.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
238
- strawberry_graphql-0.275.3.dist-info/METADATA,sha256=uw0OJJzoykRBGBq_-k-1nVHD6BWr0j0K-z83XLoZfA4,7393
239
- strawberry_graphql-0.275.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
240
- strawberry_graphql-0.275.3.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
241
- strawberry_graphql-0.275.3.dist-info/RECORD,,
237
+ strawberry_graphql-0.275.5.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
238
+ strawberry_graphql-0.275.5.dist-info/METADATA,sha256=jZRPaAmLFjGkKFs3nlqsZYt7DtpV8gelJSaNvNDw__g,7393
239
+ strawberry_graphql-0.275.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
240
+ strawberry_graphql-0.275.5.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
241
+ strawberry_graphql-0.275.5.dist-info/RECORD,,