graphene-django
graphene-django copied to clipboard
GraphQLLocatedError at schema dump for date values
- What is the current behavior?
When trying to dump a schema using the graphql_schema
command that contains the following default date value:
class MyQuery(graphene.ObjectType):
field = graphene.ConnectionField(
type=MyQueryConnectionType,
start_date=graphene.Argument(
graphene.Date,
default_value=date.min,
description="Earliest `date` value my query",
),
An error is raised from site-packages/graphql/utils/ast_from_value.py", line 53, in ast_from_value
Adding the following above the error line:
if isinstance(value, datetime.date):
return ast.StringValue(value.isoformat())
solves the issue. Is this the appropriate solution to this problem ?
- What is the expected behavior?
The schema to generate without error. Using the above fix the following entry is generated:
"defaultValue": "\"0001-01-01\"",
"description": "Earliest `date` value for my query",
"name": "startDate",
"type": {
"kind": "SCALAR",
"name": "Date",
"ofType": null
}
},
- What is the motivation / use case for changing the behavior?
Be able to generate a schema with date values as default parameters to arguments.
- Please tell us about your environment:
graphene==2.1.9 graphene-django==2.15.0 Python 3.10