graphql-python / graphene-sqlalchemy

Graphene SQLAlchemy integration
http://docs.graphene-python.org/projects/sqlalchemy/en/latest/
MIT License
980 stars 226 forks source link

feat: SQLAlchemy 2.0 support #368

Closed erikwrede closed 1 year ago

erikwrede commented 1 year ago

SQLAlchemy 2.0 is coming soon. This PR is going to collect all of the necessary changes to support it.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01 :warning:

Comparison is base (882205d) 96.39% compared to head (a0abf8a) 96.39%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #368 +/- ## ========================================== - Coverage 96.39% 96.39% -0.01% ========================================== Files 9 9 Lines 916 915 -1 ========================================== - Hits 883 882 -1 Misses 33 33 ``` | [Impacted Files](https://app.codecov.io/gh/graphql-python/graphene-sqlalchemy/pull/368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=graphql-python) | Coverage Δ | | |---|---|---| | [graphene\_sqlalchemy/batching.py](https://app.codecov.io/gh/graphql-python/graphene-sqlalchemy/pull/368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=graphql-python#diff-Z3JhcGhlbmVfc3FsYWxjaGVteS9iYXRjaGluZy5weQ==) | `95.45% <100.00%> (+0.10%)` | :arrow_up: | | [graphene\_sqlalchemy/utils.py](https://app.codecov.io/gh/graphql-python/graphene-sqlalchemy/pull/368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=graphql-python#diff-Z3JhcGhlbmVfc3FsYWxjaGVteS91dGlscy5weQ==) | `96.03% <100.00%> (-0.07%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

erikwrede commented 1 year ago

Some Exception ignored errors have appeared on 2.0:

Exception ignored in: <function _ConnectionRecord.checkout.<locals>.<lambda> at 0x11159d7a0>
Traceback (most recent call last):
  File "/Users/erik/dev/graphene-sqlalchemy/venv/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 734, in <lambda>
    if _finalize_fairy is not None
  File "/Users/erik/dev/graphene-sqlalchemy/venv/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 1030, in _finalize_fairy
    fairy.dbapi_connection = fairy._connection_record = None  # type: ignore
AttributeError: 'NoneType' object has no attribute 'dbapi_connection'

These seem to be related to the pytest fixtures, not the actual test cases. I haven't been able to identify a cause so far.

pappasam commented 1 year ago

@erikwrede just checking in to see if there's any help you need here to get this to the finish line? I'm not sure if this is paused because of some other piece of dependent work, but I'm very excited to use sqlalchemy 2.0 in my applications and this (AFAIK) is my final blocker.

erikwrede commented 1 year ago

@pappasam on this branch, all tests are passing on 2.0. Fixing the review comments is still on my list and will be done soon. You can already start testing by installing this branch via pip. Async sessions are also supported already. Would appreciate any feedback! :)

pappasam commented 1 year ago

@erikwrede I can confirm that this branch works for me! No issues I can find on my end; I'm very much looking forward to this making it into a beta release

budroco commented 1 year ago

How's it going? I use sqlalchemy 2 and it would be nice to have an official version of this.

FWIW, with this branch at least the example in the readme works. In pipenv it can be installed with:

pipenv install "git+https://github.com/graphql-python/graphene-sqlalchemy@sqa-2.0#egg=graphene-sqlalchemy"

budroco commented 1 year ago

Awesome, thank you!