graphql-python / graphql-python/graphene-django
graphql_schema --out=-.graphql raises error
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 760
- PR merge metrics
- No merged PRs in 30d
Description
* **What is the current behavior?**
Executing `python manage.py graphql_schema --schema theapp.schema --out=-.graphql` results in
```
Traceback (most recent call last):
File "/theapp/manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/env/lib/python3.9/site-packages/django/core/management/base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "/env/lib/python3.9/site-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/env/lib/python3.9/site-packages/graphene_django/management/commands/graphql_schema.py", line 115, in handle
self.get_schema(schema, out, indent)
File "/env/lib/python3.9/site-packages/graphene_django/management/commands/graphql_schema.py", line 66, in get_schema
self.stdout.write(print_schema(schema))
File "/env/lib/python3.9/site-packages/graphql/utilities/print_schema.py", line 39, in print_schema
return print_filtered_schema(
File "/env/lib/python3.9/site-packages/graphql/utilities/print_schema.py", line 57, in print_filtered_schema
directives = filter(directive_filter, schema.directives)
File "/env/lib/python3.9/site-packages/graphene/types/schema.py", line 552, in __getattr__
raise AttributeError(f'Type "{type_name}" not found in the Schema')
AttributeError: Type "directives" not found in the Schema
```
Executing
`python manage.py graphql_schema --schema app.schema --out=schema.graphql`
succeeds with
```
Successfully dumped GraphQL schema to schema.graphql
```
If you look in the code, the former does:
`self.stdout.write(print_schema(schema))`
the latter does:
`outfile.write(print_schema(schema.graphql_schema))`
* **Please tell us about your environment:**
- Version: 3.0.0.b7
- Platform: python 3.9
* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)
Contributor guide
Assessment
This issue has not been assessed yet.