strawberry-sqlalchemy-mapper 0.4.0__tar.gz → 0.4.2__tar.gz
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.
- {strawberry_sqlalchemy_mapper-0.4.0 → strawberry_sqlalchemy_mapper-0.4.2}/PKG-INFO +2 -2
- {strawberry_sqlalchemy_mapper-0.4.0 → strawberry_sqlalchemy_mapper-0.4.2}/README.md +1 -1
- {strawberry_sqlalchemy_mapper-0.4.0 → strawberry_sqlalchemy_mapper-0.4.2}/pyproject.toml +2 -2
- {strawberry_sqlalchemy_mapper-0.4.0 → strawberry_sqlalchemy_mapper-0.4.2}/src/strawberry_sqlalchemy_mapper/mapper.py +22 -3
- strawberry_sqlalchemy_mapper-0.4.2/src/strawberry_sqlalchemy_mapper/scalars.py +10 -0
- {strawberry_sqlalchemy_mapper-0.4.0 → strawberry_sqlalchemy_mapper-0.4.2}/LICENSE.txt +0 -0
- {strawberry_sqlalchemy_mapper-0.4.0 → strawberry_sqlalchemy_mapper-0.4.2}/src/strawberry_sqlalchemy_mapper/__init__.py +0 -0
- {strawberry_sqlalchemy_mapper-0.4.0 → strawberry_sqlalchemy_mapper-0.4.2}/src/strawberry_sqlalchemy_mapper/exc.py +0 -0
- {strawberry_sqlalchemy_mapper-0.4.0 → strawberry_sqlalchemy_mapper-0.4.2}/src/strawberry_sqlalchemy_mapper/field.py +0 -0
- {strawberry_sqlalchemy_mapper-0.4.0 → strawberry_sqlalchemy_mapper-0.4.2}/src/strawberry_sqlalchemy_mapper/loader.py +0 -0
- {strawberry_sqlalchemy_mapper-0.4.0 → strawberry_sqlalchemy_mapper-0.4.2}/src/strawberry_sqlalchemy_mapper/ordering.py +0 -0
- {strawberry_sqlalchemy_mapper-0.4.0 → strawberry_sqlalchemy_mapper-0.4.2}/src/strawberry_sqlalchemy_mapper/py.typed +0 -0
- {strawberry_sqlalchemy_mapper-0.4.0 → strawberry_sqlalchemy_mapper-0.4.2}/src/strawberry_sqlalchemy_mapper/relay.py +0 -0
- {strawberry_sqlalchemy_mapper-0.4.0 → strawberry_sqlalchemy_mapper-0.4.2}/src/strawberry_sqlalchemy_mapper/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: strawberry-sqlalchemy-mapper
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: A library for autogenerating Strawberry GraphQL types from SQLAlchemy models.
|
|
5
5
|
Home-page: https://strawberry.rocks/
|
|
6
6
|
License: MIT
|
|
@@ -172,7 +172,7 @@ Natively supports the following SQLAlchemy types:
|
|
|
172
172
|
```python
|
|
173
173
|
Integer: int,
|
|
174
174
|
Float: float,
|
|
175
|
-
BigInteger:
|
|
175
|
+
BigInteger: BigInt,
|
|
176
176
|
Numeric: Decimal,
|
|
177
177
|
DateTime: datetime,
|
|
178
178
|
Date: date,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "strawberry-sqlalchemy-mapper"
|
|
3
3
|
packages = [ { include = "strawberry_sqlalchemy_mapper", from = "src" } ]
|
|
4
|
-
version = "0.4.
|
|
4
|
+
version = "0.4.2"
|
|
5
5
|
description = "A library for autogenerating Strawberry GraphQL types from SQLAlchemy models."
|
|
6
6
|
authors = ["Tim Dumol <tim@timdumol.com>"]
|
|
7
7
|
license = "MIT"
|
|
@@ -50,7 +50,7 @@ sqlakeyset = "^2.0.1695177552"
|
|
|
50
50
|
asyncpg = ">=0.28,<0.30"
|
|
51
51
|
black = ">=22,<24"
|
|
52
52
|
importlib-metadata = ">=4.11.1,<8.0.0"
|
|
53
|
-
mypy = "1.
|
|
53
|
+
mypy = "1.8.0"
|
|
54
54
|
nox = "^2023.4.22"
|
|
55
55
|
nox-poetry = "^1.0.2"
|
|
56
56
|
packaging = ">=23.1"
|
|
@@ -73,6 +73,7 @@ from sqlalchemy.sql.type_api import TypeEngine
|
|
|
73
73
|
from strawberry import relay
|
|
74
74
|
from strawberry.annotation import StrawberryAnnotation
|
|
75
75
|
from strawberry.field import StrawberryField
|
|
76
|
+
from strawberry.lazy_type import LazyType
|
|
76
77
|
from strawberry.private import is_private
|
|
77
78
|
from strawberry.scalars import JSON as StrawberryJSON
|
|
78
79
|
from strawberry.type import WithStrawberryObjectDefinition, get_object_definition
|
|
@@ -92,6 +93,7 @@ from strawberry_sqlalchemy_mapper.relay import (
|
|
|
92
93
|
resolve_model_node,
|
|
93
94
|
resolve_model_nodes,
|
|
94
95
|
)
|
|
96
|
+
from strawberry_sqlalchemy_mapper.scalars import BigInt
|
|
95
97
|
|
|
96
98
|
if TYPE_CHECKING:
|
|
97
99
|
from sqlalchemy.sql.expression import ColumnElement
|
|
@@ -112,6 +114,19 @@ _IS_GENERATED_CONNECTION_TYPE_KEY = "_is_generated_connection_type"
|
|
|
112
114
|
_IS_GENERATED_RESOLVER_KEY = "_is_generated_resolver"
|
|
113
115
|
|
|
114
116
|
|
|
117
|
+
@dataclasses.dataclass(frozen=True)
|
|
118
|
+
class StrawberrySQLAlchemyLazy(LazyType):
|
|
119
|
+
# We don't actually want `Optional` here but we can't use dataclasse's
|
|
120
|
+
# kw_only untul python 3.10, and we do have fields with default values
|
|
121
|
+
# in strawberry's LazyType
|
|
122
|
+
mapper: Optional["StrawberrySQLAlchemyMapper[Any]"] = None
|
|
123
|
+
module: str = "__not_used__"
|
|
124
|
+
|
|
125
|
+
def resolve_type(self) -> Type[Any]:
|
|
126
|
+
assert self.mapper is not None
|
|
127
|
+
return self.mapper.mapped_types[self.type_name]
|
|
128
|
+
|
|
129
|
+
|
|
115
130
|
class WithStrawberrySQLAlchemyObjectDefinition(
|
|
116
131
|
WithStrawberryObjectDefinition,
|
|
117
132
|
Protocol,
|
|
@@ -179,7 +194,7 @@ class StrawberrySQLAlchemyMapper(Generic[BaseModelType]):
|
|
|
179
194
|
] = {
|
|
180
195
|
Integer: int,
|
|
181
196
|
Float: float,
|
|
182
|
-
BigInteger:
|
|
197
|
+
BigInteger: BigInt,
|
|
183
198
|
Numeric: Decimal,
|
|
184
199
|
DateTime: datetime,
|
|
185
200
|
Date: date,
|
|
@@ -282,11 +297,12 @@ class StrawberrySQLAlchemyMapper(Generic[BaseModelType]):
|
|
|
282
297
|
"""
|
|
283
298
|
edge_name = f"{type_name}Edge"
|
|
284
299
|
if edge_name not in self.edge_types:
|
|
300
|
+
lazy_type = StrawberrySQLAlchemyLazy(type_name=type_name, mapper=self)
|
|
285
301
|
self.edge_types[edge_name] = edge_type = strawberry.type(
|
|
286
302
|
dataclasses.make_dataclass(
|
|
287
303
|
edge_name,
|
|
288
304
|
[],
|
|
289
|
-
bases=(relay.Edge[
|
|
305
|
+
bases=(relay.Edge[lazy_type],), # type: ignore[valid-type]
|
|
290
306
|
)
|
|
291
307
|
)
|
|
292
308
|
setattr(edge_type, _GENERATED_FIELD_KEYS_KEY, ["node"])
|
|
@@ -300,13 +316,14 @@ class StrawberrySQLAlchemyMapper(Generic[BaseModelType]):
|
|
|
300
316
|
connection_name = f"{type_name}Connection"
|
|
301
317
|
if connection_name not in self.connection_types:
|
|
302
318
|
edge_type = self._edge_type_for(type_name)
|
|
319
|
+
lazy_type = StrawberrySQLAlchemyLazy(type_name=type_name, mapper=self)
|
|
303
320
|
self.connection_types[connection_name] = connection_type = strawberry.type(
|
|
304
321
|
dataclasses.make_dataclass(
|
|
305
322
|
connection_name,
|
|
306
323
|
[
|
|
307
324
|
("edges", List[edge_type]), # type: ignore[valid-type]
|
|
308
325
|
],
|
|
309
|
-
bases=(relay.ListConnection[
|
|
326
|
+
bases=(relay.ListConnection[lazy_type],), # type: ignore[valid-type]
|
|
310
327
|
)
|
|
311
328
|
)
|
|
312
329
|
setattr(connection_type, _GENERATED_FIELD_KEYS_KEY, ["edges"])
|
|
@@ -337,6 +354,8 @@ class StrawberrySQLAlchemyMapper(Generic[BaseModelType]):
|
|
|
337
354
|
if item_type is SkipTypeSentinel:
|
|
338
355
|
return item_type
|
|
339
356
|
type_annotation = List[item_type] # type: ignore
|
|
357
|
+
elif isinstance(column.type, BigInteger):
|
|
358
|
+
type_annotation = BigInt
|
|
340
359
|
else:
|
|
341
360
|
for (
|
|
342
361
|
sqlalchemy_type,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|