Releases: strawberry-graphql/strawberry-sqlalchemy
π 0.6.4
This release improves how types inherit fields from other mapped types using @mapper.type(...)
.
You can now safely inherit from another mapped type, and the resulting GraphQL type will include all expected fields with predictable conflict resolution.
Some examples:
- Basic Inheritance:
@mapper.type(ModelA)
class ApiA:
pass
@mapper.type(ModelB)
class ApiB(ApiA):
# ApiB inherits all fields declared in ApiA
pass
- The
__exclude__
option continues working:
@mapper.type(ModelA)
class ApiA:
__exclude__ = ["relationshipB_id"]
@mapper.type(ModelB)
class ApiB(ApiA):
# ApiB will have all fields declared in ApiA, except "relationshipB_id"
pass
- If two SQLAlchemy models define fields with the same name, the field from the model inside
.type(...)
takes precedence:
class ModelA(base):
__tablename__ = "a"
id = Column(String, primary_key=True)
example_field = Column(String(50))
class ModelB(base):
__tablename__ = "b"
id = Column(String, primary_key=True)
example_field = Column(Integer, autoincrement=True)
@mapper.type(ModelA)
class ApiA:
# example_field will be a String
pass
@mapper.type(ModelB)
class ApiB(ApiA):
# example_field will be taken from ModelB and will be an Integer
pass
- If a field is explicitly declared in the mapped type, it will override any inherited or model-based definition:
class ModelA(base):
__tablename__ = "a"
id = Column(String, primary_key=True)
example_field = Column(String(50))
class ModelB(base):
__tablename__ = "b"
id = Column(String, primary_key=True)
example_field = Column(Integer, autoincrement=True)
@mapper.type(ModelA)
class ApiA:
pass
@mapper.type(ModelB)
class ApiB(ApiA):
# example_field will be a Float
example_field: float = strawberry.field(name="exampleField")
π 0.6.3
π 0.6.2
This release does not introduce any new features or bug fixes. It focuses solely on internal code quality improvements.
Changes:
- Added Mypy configuration aligned with the main Strawberry project.
- Enforced type checking via CI to ensure consistency.
- Ran pre-commit across all files to standardize formatting and follow the project's linting architecture.
These changes aim to improve maintainability and ensure better development practices moving forward.
π 0.6.1
Ensure association proxy resolvers return valid relay connections, including page_info
and edge cursor
details, even for empty results.
Thanks to https://github.com/tylernisonoff for the original PR.
π 0.6.0
Added support for GraphQL directives in the SQLAlchemy type mapper, enabling better integration with GraphQL federation.
Example usage:
@mapper.type(Employee, directives=["@deprecated(reason: 'Use newEmployee instead')"])
class Employee:
pass
Releases contributed by @csechrist via #204
π 0.5.0
Add an optional function to exclude relationships from relay pagination and use traditional strawberry lists.
Default behavior preserves original behavior for backwords compatibilty.
Releases contributed by @fruitymedley via #168
π 0.4.5
π 0.4.4
π 0.4.3
Fix an issue where auto generated connections were missing some expected
attributes to be properly instantiated.
Releases contributed by @bellini666 via #137