Skip to content

feat(async): add support for async sessions #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
32bf439
feat(async): add support for async sessions
May 16, 2022
41c88f9
fix(test batching): ensure that objects are added to database in asyn…
May 16, 2022
47d224e
test: only run batching tests with sync session
May 17, 2022
811cdf2
chore(fields): use get_query instead of manually crafting the query
May 31, 2022
3149830
fix: throw exceptions if Async Session is used with old sql alchemy
May 31, 2022
0e60c03
test: fix sqlalchemy 1.2 and 1.3 tests, fix batching tests by separat…
May 31, 2022
0180f69
fix: ensure that synchronous execute calls are still feasible
Jun 2, 2022
ec76697
refactor: remove duplicate code by fixing if condition
Jun 7, 2022
6a00846
chore: add specific error if awaitable is returned in synchronous exe…
Jun 7, 2022
9897a03
chore: merge master, resolve conflicts
Sep 15, 2022
fff782f
test: use pytest_asyncio.fixture instead normal fixture, fix issues i…
Sep 15, 2022
1250231
chore: remove duplicate eventually_await_session
Oct 7, 2022
eee2314
chore: remove duplicate skip statement
Oct 7, 2022
bacf15d
fix: fix benchmark tests not being executed properly
Oct 7, 2022
2bc6f84
chore: format files
Oct 7, 2022
a968ff8
chore: move is_graphene_version_less_than to top of file
Oct 7, 2022
1039f03
test: remove unnecessary pytest.mark.asyncio, auto-reformatting
Oct 7, 2022
e61df34
chore: revert faulty formatting
Oct 7, 2022
2ff54dc
fix: run startup checkt for sqlalchemy version
Oct 31, 2022
4321b04
chore: rebase onto master, adapt interface test to run with sync sess…
Dec 9, 2022
1e857e0
fix: allow polymorphism with async session
erikwrede Dec 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: merge master, resolve conflicts
  • Loading branch information
Jendrik committed Sep 15, 2022
commit 9897a03da55ccd60aa2a8e5000fe5aad26278561
3 changes: 1 addition & 2 deletions graphene_sqlalchemy/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
from graphql_relay import connection_from_array_slice

from .batching import get_batch_resolver
from .utils import (EnumValue, get_query, get_session,
is_sqlalchemy_version_less_than)
from .utils import EnumValue, get_query, get_session, is_sqlalchemy_version_less_than

if not is_sqlalchemy_version_less_than("1.4"):
from sqlalchemy.ext.asyncio import AsyncSession
Expand Down
2 changes: 1 addition & 1 deletion graphene_sqlalchemy/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_db_url(async_session: bool):
async def session_factory(async_session: bool, test_db_url: str):
if async_session:
if is_sqlalchemy_version_less_than("1.4"):
pytest.skip(f"Async Sessions only work in sql alchemy 1.4 and above")
pytest.skip("Async Sessions only work in sql alchemy 1.4 and above")
engine = create_async_engine(test_db_url)
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
Expand Down
31 changes: 29 additions & 2 deletions graphene_sqlalchemy/tests/models_batching.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@

import enum

from sqlalchemy import (Column, Date, Enum, ForeignKey, Integer, String, Table,
func, select)
from sqlalchemy import (
Column,
Date,
Enum,
ForeignKey,
Integer,
String,
Table,
func,
select,
)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import column_property, relationship

Expand Down Expand Up @@ -62,3 +71,21 @@ class Article(Base):
headline = Column(String(100))
pub_date = Column(Date())
reporter_id = Column(Integer(), ForeignKey("reporters.id"))
readers = relationship(
"Reader", secondary="articles_readers", back_populates="articles"
)


class Reader(Base):
__tablename__ = "readers"
id = Column(Integer(), primary_key=True)
name = Column(String(100))
articles = relationship(
"Article", secondary="articles_readers", back_populates="readers"
)


class ArticleReader(Base):
__tablename__ = "articles_readers"
article_id = Column(Integer(), ForeignKey("articles.id"), primary_key=True)
reader_id = Column(Integer(), ForeignKey("readers.id"), primary_key=True)
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.