Skip to content

fix: warnings in docs build #383

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 3 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ SQLAlchemyInterface

ORMField
--------------------
.. autoclass:: graphene_sqlalchemy.fields.ORMField
.. autoclass:: graphene_sqlalchemy.types.ORMField

SQLAlchemyConnectionField
-------------------------
.. autoclass:: graphene_sqlalchemy.SQLAlchemyConnectionField
.. autoclass:: graphene_sqlalchemy.SQLAlchemyConnectionField
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
# html_static_path = ["_static"]

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down
8 changes: 7 additions & 1 deletion docs/inheritance.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
Inheritance Examples
====================


Create interfaces from inheritance relationships
------------------------------------------------
.. note:: If you're using `AsyncSession`, please check the section `Eager Loading & Using with AsyncSession`_.

.. note::
If you're using `AsyncSession`, please check the chapter `Eager Loading & Using with AsyncSession`_.

SQLAlchemy has excellent support for class inheritance hierarchies.
These hierarchies can be represented in your GraphQL schema by means
of interfaces_. Much like ObjectTypes, Interfaces in
Expand Down Expand Up @@ -111,8 +115,10 @@ class to the Schema constructor via the `types=` argument:

See also: `Graphene Interfaces <https://docs.graphene-python.org/en/latest/types/interfaces/>`_


Eager Loading & Using with AsyncSession
----------------------------------------

When querying the base type in multi-table inheritance or joined table inheritance, you can only directly refer to polymorphic fields when they are loaded eagerly.
This restricting is in place because AsyncSessions don't allow implicit async operations such as the loads of the joined tables.
To load the polymorphic fields eagerly, you can use the `with_polymorphic` attribute of the mapper args in the base model:
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
sphinx
# Docs template
http://graphene-python.org/sphinx_graphene_theme.zip
1 change: 1 addition & 0 deletions docs/tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Tips
Querying
--------
.. _querying:

In order to make querying against the database work, there are two alternatives:

- Set the db session when you do the execution:
Expand Down
54 changes: 29 additions & 25 deletions graphene_sqlalchemy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,15 @@ class SQLAlchemyObjectType(SQLAlchemyBase, ObjectType):

Usage:

class MyModel(Base):
id = Column(Integer(), primary_key=True)
name = Column(String())
.. code-block:: python

class MyType(SQLAlchemyObjectType):
class Meta:
model = MyModel
class MyModel(Base):
id = Column(Integer(), primary_key=True)
name = Column(String())

class MyType(SQLAlchemyObjectType):
class Meta:
model = MyModel
"""

@classmethod
Expand Down Expand Up @@ -450,30 +452,32 @@ class SQLAlchemyInterface(SQLAlchemyBase, Interface):

Usage (using joined table inheritance):

class MyBaseModel(Base):
id = Column(Integer(), primary_key=True)
type = Column(String())
name = Column(String())
.. code-block:: python

__mapper_args__ = {
"polymorphic_on": type,
}
class MyBaseModel(Base):
id = Column(Integer(), primary_key=True)
type = Column(String())
name = Column(String())

class MyChildModel(Base):
date = Column(Date())
__mapper_args__ = {
"polymorphic_on": type,
}

__mapper_args__ = {
"polymorphic_identity": "child",
}
class MyChildModel(Base):
date = Column(Date())

class MyBaseType(SQLAlchemyInterface):
class Meta:
model = MyBaseModel
__mapper_args__ = {
"polymorphic_identity": "child",
}

class MyChildType(SQLAlchemyObjectType):
class Meta:
model = MyChildModel
interfaces = (MyBaseType,)
class MyBaseType(SQLAlchemyInterface):
class Meta:
model = MyBaseModel

class MyChildType(SQLAlchemyObjectType):
class Meta:
model = MyChildModel
interfaces = (MyBaseType,)
"""

@classmethod
Expand Down