-
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 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Also returning |
Beta Was this translation helpful? Give feedback.
resolve_organizations
is root resolver, so itsobj
argument isNone
by default. This behavior is mentioned at the beginning or resolves documentation:resolve_organizations
should retrieve organizations list from suitable place: database, config or 3rd party API.Also returning
resolve_owner
as part of field looks wrong here. Why can't you embed this data directly and then use resolver onowner
field to complete data resolution process?