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
I'm currently trying to set my model user User subfield user.actor.id as field source of my DjangoObjectType.
This happens because there's other kind of users within the application like an Organization or even a Bot (all of them are actors).
Example
Lets define a custom Type:
classUser(DjangoObjectType):
classMeta:
model=UserModelexclude= ['actor']
filter_fields= ['actor__login']
interfaces= [graphene.relay.Node]
skip_registry=True# The login field is originated from `actor` relationship, not from the user model itself.# It doesn't work, actor__login is interpreted as user field [user.actor__login] not [user.actor.login].login=graphene.Field(graphene.String, source='actor__login')
# ...
In the example above I define the login field source as source='actor__login' but I saw that here we're using getattr function to resolve the source so it's currently impossible to set the field without defining a custom resolver.
I would like to know if there's an alternative solution to select a subfield like the example or we're forced to create a custom resolver by using the resolver=lambda _, __: ... arg or the class method declaration.
Thanks for the hard work and the library!
The text was updated successfully, but these errors were encountered:
Context
I'm currently trying to set my model user
User
subfielduser.actor.id
as field source of myDjangoObjectType
.This happens because there's other kind of users within the application like an
Organization
or even aBot
(all of them are actors).Example
Lets define a custom
Type
:In the example above I define the login field source as
source='actor__login'
but I saw that here we're usinggetattr
function to resolve the source so it's currently impossible to set the field without defining a custom resolver.graphene/graphene/types/field.py
Lines 16 to 20 in dfece7f
I would like to know if there's an alternative solution to select a subfield like the example or we're forced to create a custom resolver by using the
resolver=lambda _, __: ...
arg or the class method declaration.Thanks for the hard work and the library!
The text was updated successfully, but these errors were encountered: