-
Notifications
You must be signed in to change notification settings - Fork 2
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
Initial support for file metadata. #38
Conversation
@@ -50,6 +51,33 @@ async def get_entities( | |||
return result.scalars().all() | |||
|
|||
|
|||
async def get_files( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the File table doesn't have its own owner/collection id's so we have to tweak the fetch code to filter fields from the related Entity type.
if type(related_model) == db.File: | ||
load_method = get_files | ||
else: | ||
load_method = get_entities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch between entity/file loaders. We might want a prettier way to break this up (maybe a config map?) in the future.
@@ -125,6 +158,22 @@ async def resolve_entity( | |||
return resolve_entity | |||
|
|||
|
|||
def get_file_loader(sql_model, gql_type): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, very slightly different code path than Entities
producing_run_id = Column(Integer, nullable=True) | ||
owner_user_id = Column(Integer, nullable=False) | ||
collection_id = Column(Integer, nullable=False) | ||
producing_run_id: Mapped[uuid.UUID] = mapped_column(Integer, nullable=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently SQLAlchemy wants us to use mapped_column
from now on:
https://docs.sqlalchemy.org/en/20/changelog/whatsnew_20.html#orm-declarative-models
@@ -602,6 +602,7 @@ def convert(type_: Any) -> Any: | |||
|
|||
if make_interface: | |||
mapped_type = strawberry.interface(type_) | |||
self.mapped_interfaces[type_.__name__] = mapped_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a bug in the mapper where it'd loop over all currently-unmapped fields and try to map them, until the list of unmapped fields is empty. The mapper keeps track of mapped_types
and mapped_interfaces
and adds types to the mapped_types
dict ... and doesn't have any code in it to ever update mapped_interfaces
so the app goes into an infinite loop at map-time.
I'm not sure if this is a perfect fix, but it seems like an improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
No description provided.