Closed AlecRosenbaum closed 1 month ago
I was wrong about the graceful failure on resolve_type
. graphene
doesn't provide a resolve_type
function by default. It seem that resolve_type
takes precedence over is_type_of
if it's present, regardless of what it returns.
If I understand correctly, it seems that graphene
forces the presence of a user-defined is_type_of
function on implementing types, a resolve_type
function on the interface, or will generate an is_type_of
function for you based on a list of types provided within the metadata (still explicit / opt-in).
Should strawberry require explicit type resolution for duck-typed objects?
Not sure why this closed...
I think this was fixed by https://github.com/strawberry-graphql/strawberry/pull/1406 (at least that was intended to fix this)
This comment is correct: https://github.com/strawberry-graphql/strawberry/blob/feb6edee0df8cac3aeb663f67a169035a0271f40/strawberry/schema/schema_converter.py#L235-L244
It's correctly reflected in the docs, but still does pose a pretty bad limitation for implementations that resolve to non-strawberry types.
The following test fails (using a similar example to https://github.com/strawberry-graphql/strawberry/pull/1150):
In
graphene
, the converter allows you to defineis_type_of
classmethods on concrete types or aresolve_type
classmethod on the interface. I think the equivalent within strawberry would be to optionally includeis_type_of
here, and to gracefully fail type resolution for non-strawberry objects (by returningNone
) withinresolve_type
.Upvote & Fund