graphql-python / graphql-python/graphene
Failed to print schema with InputObjectType with DateTime field with default_value
- Dominant language
- Python
- Stars
- 8.2k
- Forks
- 818
- PR merge metrics
- No merged PRs in 30d
Description
Declaring a DateTime with default_value in InputObjectType makes schema unprintable due to unsupported conversion in `graphql/utils/ast_from_value.py`
InputObjectType declared as:
```
class Filters(InputObjectType):
datetime_after = DateTime(required=False, default_value=datetime.min)
datetime_before = DateTime(required=False, default_value=datetime.max)
```
normally attached to the Query
causes `print(schema)` failing with:
```
(...)
File "lib/python3.8/site-packages/graphql/utils/schema_printer.py", line 205, in _print_input_value
default_value = " = " + print_ast(ast_from_value(arg.default_value, arg.type))
File "lib/python3.8/site-packages/graphql/utils/ast_from_value.py", line 53, in ast_from_value
assert isinstance(value, dict)
AssertionError
```
Without default_value it works.
I'm using default values like shown in #856 but even without this support in ast_from_value is clearly missing.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the schema-printing failure with the Filters InputObjectType and DateTime defaults shown in the issue. Start in graphql/utils/ast_from_value.py, then inspect the schema_printer.py call site; done means print(schema) succeeds when DateTime fields have default_value values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100