Passing JSONString with value "null" as mutation input leads to an error.
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start with graphql/utils/is_valid_literal_value.py, especially the parse_result handling shown in the traceback, and trace how arguments_of_correct_type.py validates the JSONString literal. Reproduce the mutation using value: "null" and verify the intended handling of that literal before adding or updating the relevant validation test.
Written by the indexing model from the issue text.
Description
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 passing null via query argument but I still think this is a bug.
Exception stack trace:
File "/venv/lib/python3.7/site-packages/graphql/graphql.py", line 44, in graphql
return execute_graphql(*args, **kwargs)
File "/venv/lib/python3.7/site-packages/graphql/graphql.py", line 70, in execute_graphql
**execute_options
File "/venv/lib/python3.7/site-packages/graphql/backend/core.py", line 30, in execute_and_validate
validation_errors = validate(schema, document_ast)
File "/venv/lib/python3.7/site-packages/graphql/validation/validation.py", line 33, in validate
return visit_using_rules(schema, type_info, ast, rules)
File "/venv/lib/python3.7/site-packages/graphql/validation/validation.py", line 40, in visit_using_rules
visit(ast, TypeInfoVisitor(type_info, ParallelVisitor(visitors)))
File "/venv/lib/python3.7/site-packages/graphql/language/visitor.py", line 128, in visit
result = enter(node, key, parent, path, ancestors)
File "/venv/lib/python3.7/site-packages/graphql/language/visitor.py", line 279, in enter
result = self.visitor.enter(node, key, parent, path, ancestors)
File "/venv/lib/python3.7/site-packages/graphql/language/visitor.py", line 231, in enter
result = visitor.enter(node, key, parent, path, ancestors)
File "/venv/lib/python3.7/site-packages/graphql/language/visitor.py", line 191, in enter
return method(self, node, key, parent, path, ancestors)
File "/venv/lib/python3.7/site-packages/graphql/validation/rules/arguments_of_correct_type.py", line 24, in enter_Argument
errors = is_valid_literal_value(arg_def.type, node.value)
File "/venv/lib/python3.7/site-packages/graphql/utils/is_valid_literal_value.py", line 86, in is_valid_literal_value
if parse_result is None:
Simple way to reproduce:
Query example:
mutation {
testNull(value: "null") { value }
}
GraphQL schema:
TestNull:
value: JSONString
testNull(value: JSONString): TestNull
Graphene code:
class TestNull(graphene.Mutation):
class Input:
value = graphene.JSONString()
value = graphene.JSONString()
@classmethod
def mutate(cls, instance, input, info):
value = input.get('value')
print(f"VALUE={value}")
return TestNull(value=value)
- Dominant language
- Python
- Stars
- 371
- Forks
- 175
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from graphql-python/graphql-core-legacy
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Quiver source Open
Difficulty 5/5 Over a week Newbie friendliness 20/100
graphql-python/graphql-core-legacy#286 · 3 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
graphql-python/graphql-core-legacy#280 · 2 comments · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
All issues in graphql-python/graphql-core-legacy
Similar issues
-
area: harness bug status: needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Human-Agent-Society/reef#625 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 1/5 Under an hour Newbie friendliness 80/100
learningequality/kolibri#15351 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Name consistency Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
eellak/triplestore#65 · 1 comment ·