I'm trying to follow the Django tutorial at http://docs.graphene-python.org/projects/django/en/latest/tutorial.html and getting the following error:
ImportError at /api
Could not import 'cookbook.schema.schema' for Graphene setting 'SCHEMA'. AttributeError: type object 'Query' has no attribute 'name'.
Changing AbstractType to ObjectType seems to fix it, but I'm not sure if that's the right thing.
I also hit this
When I tried changing AbstractType to ObjectType and open /graphql, I get this error message:
{
"errors": [
{
"message": "Query fields must be a mapping (dict / OrderedDict) with field names as keys or a function which returns such a mapping."
}
]
}
I resolved by changing class Query(cookbook.ingredients.Query): to class Query(cookbook.ingredients.Query, graphene.ObjectType): in the top-level schema.
That is, I had my top-level Query object inherit from graphene.ObjectType in addition to the app-specific schema Query objects
This is fixed in graphene-django with this commit: https://github.com/graphql-python/graphene-django/commit/d1f28633744d61aa955dc862c5cd2c29d678695c
The docs had an issue while doing the build so they haven't been automatically updated with each git commit, but I'm working on fixing that there.
Refer to the graphene-python.org issue if you want to keep track of this.
Closing issue :)
I have the same problem!
Most helpful comment
I also hit this