You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When combining the @strawberry.input and @strawberry_sqlalchemy_mapper.type decorators i was able to declare a valid strawberry input type.
However, i came into a problem trying to define which fields (generated by strawberry_sqlalchemy_mapper.type from the model) are optional (without overriding their previous strawberry_sqlalchemy_mapper declaration).
Could be useful to make a strawberry_sqlalchemy_mapper.input decorator that implements this (perhaps by checking 'SQLAlchemy.Column.nullable' property, or simply by listing them) and wraps both @strawberry.input and @strawberry_sqlalchemy_mapper.type.
EDIT
After examining the source code i see the mapper does take optional into account, it just does not reflect that when working with the @strawberry.input decorator (raises __init__() missing # required keyword-only argument(s))
possible use:
# models.py
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class User(Base):
__tablename__ = "user"
username= Column(String, primary_key=True)
password_hash = Column(String, nullable=False)
first_name = Column(String, nullable=False)
last_name = Column(String, nullable=True)
# elsewhere
# ...
from strawberry_sqlalchemy_mapper import StrawberrySQLAlchemyMapper
strawberry_sqlalchemy_mapper = StrawberrySQLAlchemyMapper()
@strawberry_sqlalchemy_mapper.input(models.User)
class UserInput:
__exclude__ = ["password_hash"]
__optional__ = ["last_name"] # or read nullable attribute
password : str
Upvote & Fund
We're using Polar.sh so you can upvote and help fund this issue.
We receive the funding once the issue is completed & confirmed by you.
Thank you in advance for helping prioritize & fund our backlog.
The text was updated successfully, but these errors were encountered:
When combining the @strawberry.input and @strawberry_sqlalchemy_mapper.type decorators i was able to declare a valid strawberry input type.
However, i came into a problem trying to define which fields (generated by strawberry_sqlalchemy_mapper.type from the model) are optional (without overriding their previous strawberry_sqlalchemy_mapper declaration).
Could be useful to make a strawberry_sqlalchemy_mapper.input decorator that implements this (perhaps by checking 'SQLAlchemy.Column.nullable' property, or simply by listing them) and wraps both @strawberry.input and @strawberry_sqlalchemy_mapper.type.
EDIT
After examining the source code i see the mapper does take optional into account, it just does not reflect that when working with the @strawberry.input decorator (raises
__init__() missing # required keyword-only argument(s)
)possible use:
Upvote & Fund
The text was updated successfully, but these errors were encountered: