-
Notifications
You must be signed in to change notification settings - Fork 822
ObjectType resolving fields from dicts or objects #798
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
Comments
What does the |
@jkimbo as I say it's a list of dicts. I can convert it to list of Photos() manually, but the question is there any already implemented way to fill ObjectType with nested fields from dictionary or I have to implement it by myself. |
You could change the default resolver on the from graphene.types.resolver import dict_resolver
class Photo(graphene.ObjectType):
class Meta:
default_resolver = dict_resolver
id = graphene.ID()
url = graphene.String()
fileName = graphene.String()
extension = graphene.String() |
Thanks, @jkimbo. That's what I was looking for. I think that it would be in docs. |
Yep I agree. A PR would be welcome if you have the time |
Also I have a PR #638 which should mean by default graphene would handle dicts and objects transparently |
I'm surprised this wasn't in the docs, i'd spent so much unnecessary effort explicitly resolving dicts... please update the docs, this is an expected behavior of graphql. thanks |
Is it correct, that the Is there any other workaround to set the |
Hi! There is an example code:
The result is
Field "photos" not initialized in init. In argument "photos" I got just list with dicts. I know that I can to this serialization by myself, but maybe it's already implemented?
The text was updated successfully, but these errors were encountered: