-
Notifications
You must be signed in to change notification settings - Fork 225
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
hybrid_property annotations with built-in types defaulting to ForwardRef
and failing schema compilation
#396
Comments
Hello @yesthesoup, You're spot on with your understanding of the problem. Our approach to handling forward references was indeed shaped during a time of less clarity in Python's typing landscape. The shift towards Your workaround of explicitly excluding affected fields or setting types for specific fields is a solid interim solution. Our recent update (#371 was intended to improve handling by inferring types from annotations instead of converting hybrids to strings. However, with Manually setting the type for hybrids or use manual I agree that this is not the ideal state, and we're aiming to address this post the 3.0 release. Thanks for pushing this by sharing your experience. |
Thank you for the reply - good to know this is on the radar. |
dependencies:
I am upgrading from
graphene==2.1.9
andgraphene-sqlalchemy==2.3.0
where these hybrid properties worked.simplified example:
It seems like support was added for these annotations in #340 in v3.0.0b2, but then is no longer working as expected since several refactors.
I get this error for the string return type hybrid
and this for the Boolean.
MyModel
in reality has many many fields so it was also hard to figure out it was the hybrid_property fields that were causing problems, vs. the actual relationship fields etcWhich seems to be because the function
convert_hybrid_property_return_type
https://github.com/graphql-python/graphene-sqlalchemy/blob/v3.0.0b4/graphene_sqlalchemy/converter.py#L640
returns a string version of the type, and string defaults to being processed by
convert_sqlalchemy_hybrid_property_bare_str
even though those strings are valid types, notForwardRef
s.https://github.com/graphql-python/graphene-sqlalchemy/blob/v3.0.0b4/graphene_sqlalchemy/converter.py#L632
I am getting around this by explicitly declaring the graphene types but my understanding was that graphene-sqlalchemy should be able to pick them up automatically due to the recent support that was integrated, as referenced above.
workaround:
If this is intended behaviour, could the error be more helpful? Spent several hours digging as I was not attempting anything with a ForwardRef type.
The text was updated successfully, but these errors were encountered: