Open sergey-komissarov opened 5 years ago
@sergey-komissarov this doesn't look like a bug because you're trying to pass the string null
to the JSON parser and so it's going to error out. If you have no valid json to pass to the graphene then you shouldn't be passing a value at all.
@sergey-komissarov this doesn't look like a bug because you're trying to pass the string
null
to the JSON parser and so it's going to error out. If you have no valid json to pass to the graphene then you shouldn't be passing a value at all.
I can not agree with you, "null"
is a valid JSON and parsed without errors. But core itself does not allow argument field to be None
.
Also passing None
as member value or not passing member at all have different meaning for our graphql api, hacking it with null
in query argument works but smells badly.
@sergey-komissarov my apologies you're absolutely right. It looks like the bug is here: https://github.com/graphql-python/graphql-core/blob/fa4eeda36029680205e20059379e89189b946032/graphql/utils/is_valid_value.py#L77-L79
Because json.loads("null")
returns None
it's tripping up the validation and throwing the error.
Unfortunately I can't see an easy fix. You might want to try https://github.com/graphql-python/graphql-core-next which is a more recent port of the graphql-js reference library and so probably doesn't suffer from the same bug. I don't think it's compatible with Graphene yet but you can still use it on its own. Also @Cito is a much more responsive maintainer 🙂
I don't understand why it can't be fixed? 🤔
I'd like to see that bug fixed too :smiling_face_with_tear:
Hello,
graphql-core
2.1 is unable to parse such values as argument.Result:
Argument "value" has invalid value "null". Expected type "JSONString", found "null".
Seems that
None
value is invalid regardless of the argument type. Of course we can handle it by passingnull
via query argument but I still think this is a bug.Exception stack trace:
Simple way to reproduce:
Query example:
GraphQL schema:
Graphene code: