Releases: graphql-python/graphene-sqlalchemy
v3.0.0rc1
RELEASE CANDIDATE
This is the last release with feature additions before we move graphene-sqlalchemy 3.0 to GA 🎉
We have implemented some awesome new features, including new filters, and SQLAlchemy 2.0 support that we are very excited about.
Please test this release and report any issues you find so we can fix them for the release.
When upgrading and testing, please take care of the previous release notes and look at the following breaking changes PR:
#371
If you are using hybrid properties as fields in your GraphQL schema in combination with from __future___ import annotations
, this issue might affect you. We are actively working towards a fix for str,bool
and other primitives.
#396
A more detailed upgrade guide summarizing all beta releases will be published with the full release.
What's Changed
Filters are out in early access 🎉
Graphene SQLAlchemy 3.0 will provide a completely overhauled filtering syntax, removing the need for an external plugin. We support automatically filtering over relationships and complex filter types as well as easy customization. Please check out the docs here and give us feedback about your experience! 😊
https://graphql-python.github.io/graphene-sqlalchemy/filters.html
Add Filters by @sabard in #357
Other contributions since the last beta release
- docs: update PyPI page by @sabard in #384
- fix: set README content_type by @sabard in #385
- feat: SQLAlchemy 2.0 support by @erikwrede in #368
- Add database session to the example by @clemens-tolboom in #249
- association_proxy support by @dpep in #267
- Recreate loader if old loader is on different loop by @zeptonaut in #395
- fix: keep converting tuples to strings for composite primary keys in relay ID field by @erikwrede in #399
New Contributors
- @zeptonaut made their first contribution in #395
Full Changelog: v3.0.0b4...v3.0.0rc1
Full Changelog since 2.x: 2.3.0...v3.0.0rc1
Thanks to everyone that contributed to this release and supported our biweekly maintainer meetings. We are looking forward to your feedback and appreciate any PRs 😊
v3.0.0b4
What's Changed
- Enable sorting when batching is enabled by @PaulSchweizer in #355
- Add Black to pre-commit by @erikwrede in #361
- Fix: RelationshipLoader should utilize DataLoader from the
get_data_loader_impl()
function, and not directly from aiodataloader library by @flipbit03 in #362 - Add support for UUIDs in
@hybrid_property
by @flipbit03 in #363 - chore: limit CI runs to master pushes & PRs by @erikwrede in #366
- Support GQL interfaces for polymorphic SQLA models by @polgfred in #365
- feat(async): add support for async sessions by @jendrikjoe in #350
- Fix installation instruction: '--pre' instead of '>=3' by @zahrevsky in #372
- refactor!: use the same conversion system for hybrids and columns by @erikwrede in #371
- Stricter non-null fields for relationships by @polgfred in #367
- fix singledispatch inheritance by @erikwrede in #377
- chore: limit lint runs to master pushes and PRs by @sabard in #382
- fix: warnings in docs build by @sabard in #383
New Contributors
- @PaulSchweizer made their first contribution in #355
- @polgfred made their first contribution in #365
- @jendrikjoe made their first contribution in #350
- @zahrevsky made their first contribution in #372
- @sabard made their first contribution in #382
Full Changelog: 3.0.0b3...v3.0.0b4
v3 Beta 3
This is a small fix. Graphene DataLoader
is used when using graphene>=3.1.1
to allow for more frequent updates to DataLoaders & fix issues with pytest
.
Please check the graphene
release notes to learn more: https://github.com/graphql-python/graphene/releases/tag/v3.1.1
What's Changed
- Use Graphene DataLoader in graphene>=3.1.1 by @erikwrede in #360
Full Changelog: 3.0.0b2...3.0.0b3
3.0.0b2
What's Changed
Extended Support for hybrid_property
In older versions, hybrid properties of an SQLAlchemy model were converted to Strings in the SQLAlchemyObjectType
, unless overridden by an ORMField
. This release includes support for automatic type detection based on the type hints of the method.
Old Behavior
class Interval(Base):
id = Column(Integer, primary_key=True)
start = Column(Integer, nullable=False)
end = Column(Integer, nullable=False)
@hybrid_property
def length(self):
return self.end - self.start
class GQLInterval(SQLAlchemyObjectType):
class Meta:
model = Interval
GraphQL Schema:
type Interval {
id: ID!
start: Int!
end: Int!
length: String
}
New Behavior
class Interval(Base):
#Fields from above
@hybrid_property
def length(self) -> int:
return self.end - self.start
class GQLInterval(SQLAlchemyObjectType):
class Meta:
model = Interval
GraphQL Schema:
type Interval {
id: ID!
start: Int!
end: Int!
length: Int
}
The feature supports all basic python types (#340) , ObjectTypes and Unions of ObjectTypes (Union[T1,T2]
or 3.10-style: T1 | T2
).
Adding additional converters is possible similar to column type converters using @convert_sqlalchemy_hybrid_property_type.register(matcher)
. See converter.py
for examples.
This feature is experimental and subject to extension (NonNull
Support, Hybrid Methods, @property
support). If you encounter an issue, see room for improvement or want to help extend the feature, please open an issue!
- Support setting @hybrid_property's return type from the functions type annotations. by @flipbit03 in #340
- Supplant @hybrid_property's type annotation support with
Optional[T]
by @flipbit03 in #343
Docstring Support for hybrid_property
The default behavior was changed to include the docstrings of hybrid property methods into the schema, similar to the docstrings of the column. This can be overridden using an ORMField
providing an empty docstring.
Changes to existing Column Type converters
This PR brought updates and additions to type converters. Some type converters were adjusted to map to the correct graphene scalar type. The changes might reflect in your schema types.
Type | Old Scalar | New Scalar |
---|---|---|
sqa.Date |
graphene.String |
graphene.Date |
sqa.Time |
graphene.String |
graphene.Time |
sqa.DateTime |
graphene.String |
graphene.DateTime |
postgresql.UUID |
graphene.String |
graphene.UUID |
sqa_utils.UUID |
--- | graphene.UUID |
sqa.Variant |
--- | Converts Variant.impl |
sqa_utils.IPAddressType |
--- | graphene.String |
sqa_utils.EmailType |
--- | graphene.String |
sqa_utils.URLType |
--- | graphene.String |
Additionally, Enums are now generated from Column.key
instead of Column.name
. See #301
- Native support for additional Type Converters by @erikwrede in #353
Other changes
- Build clean up by @mvanlonden in #318
- I resolved spelling and capitalization mistakes in the file,
README.md
. by @quinnkj in #290 - Fix for import from graphql-relay-py (#329) by @Cito in #330
- Fix for issue #288 by @jbeard4 in #289
- Don't suppress SQLAlchemy errors when mapping classes by @connorbrinton in #169
- Pick up the docstrings of hybrid properties by @bim9262 in #344
- Add Python 3.10 Support & update pre-commit hooks by @erikwrede in #352
New Contributors
- @quinnkj made their first contribution in #290
- @jbeard4 made their first contribution in #289
- @connorbrinton made their first contribution in #169
- @flipbit03 made their first contribution in #340
- @bim9262 made their first contribution in #344
Full Changelog: 3.0.0b1...3.0.0b2
3.0.0b1
Upgrade to v3 🎉
- Now supports sqlalchemy v1.4
- Replaces the promises.dataloader with aiodataloader making batched queries asyncio-dependant
2.3.0
Batching
Batching can be now enabled via the batching
param:
- we can configure all the fields of a type at once via
SQLAlchemyObjectType.meta.batching
- or we can specify it for a specific field via
ORMfield.batching
. This trumpsSQLAlchemyObjectType.meta.batching
.
See relevant PR: #253 #254 #260
Add support for Non-Null SQLAlchemyConnectionField
See #261
Simplify access to model Connection
One can access the connection on the SQLAlchemyObjectType
directly. ex: MyModel.connection
And other minor fixes
Regression Fix
Fixes issue #234. The regression was introduced in 9a0f740.
Custom resolve_<field_name> functions were no longer call for fields auto-generated by SQLAlchemyObjectType. The issue was caused by a soon-to-be-documented feature that allows users to rename auto-generated fields (aka ORMField.model_attr).