|
Say we have the following schema: type OrganizationUser {
name: String!
organization: Organization!
}
type Organization {
name: String!
owner: OrganizationUser!
}
type Query {
organizations: [Organization!]!
}See comment in @query.field("organizations")
def resolve_organizations(parent, info: GraphQLResolveInfo):
def resolve_owner(info: GraphQLResolveInfo):
# here info.parent_type == Organization, but the parent is inaccessible
return {
"name": "Sundar Pichai",
"organization": None # missing for demo
}
return [{
"name": "Google",
"owner": resolve_owner
}]I wonder why |
Replies: 1 comment 2 replies
|
Also returning |
resolve_organizationsis root resolver, so itsobjargument isNoneby default. This behavior is mentioned at the beginning or resolves documentation:resolve_organizationsshould retrieve organizations list from suitable place: database, config or 3rd party API.Also returning
resolve_owneras part of field looks wrong here. Why can't you embed this data directly and then use resolver onownerfield to complete data resolution process?