Open
Description
For example in the current test
ariadne/tests/test_directives.py
Line 60 in e03d333
For simplicity if I change the test case to have both convert_names_case=True
and @upper
it will fail
def test_field_definition_directive_replaces_field_resolver_with_custom_one():
type_defs = """
directive @upper on FIELD_DEFINITION
type Query {
test: Custom
}
type Custom {
nodeField: String @upper
}
"""
query = QueryType()
query.set_field("test", lambda *_: {"node_field": "custom"})
schema = make_executable_schema(
type_defs,
[query],
directives={"upper": UpperDirective},
convert_names_case=True,
)
result = graphql_sync(schema, "{ test { nodeField }}")
assert result.errors is None
assert result.data == {"test": {"nodeField": "CUSTOM"}}
python -m pytest tests/test_directives.py::test_field_definition_directive_replaces_field_resolver_with_custom_one
FAILED tests/test_directives.py::test_field_definition_directive_replaces_field_resolver_with_custom_one - assert [GraphQLError("'NoneType' object has no attribute 'upper'", locations=[SourceLocation(line=1, column=10)], path=['test', 'nodeField'])] is None
But if I change the test case to have only convert_names_case=True
it will succeed
def test_field_definition_directive_replaces_field_resolver_with_custom_one():
type_defs = """
type Query {
test: Custom
}
type Custom {
nodeField: String
}
"""
query = QueryType()
query.set_field("test", lambda *_: {"node_field": "custom"})
schema = make_executable_schema(
type_defs,
[query],
convert_names_case=True,
)
result = graphql_sync(schema, "{ test { nodeField }}")
assert result.errors is None
assert result.data == {"test": {"nodeField": "custom"}}
python -m pytest tests/test_directives.py::test_field_definition_directive_replaces_field_resolver_with_custom_one
1 passed, 2 warnings in 0.04s
It will also succeed if I explicitly provide a resolver when having both convert_names_case=True
and @upper
def test_field_definition_directive_replaces_field_resolver_with_custom_one():
type_defs = """
directive @upper on FIELD_DEFINITION
type Query {
test: Custom
}
type Custom {
nodeField: String @upper
}
"""
query = QueryType()
test = ObjectType('Custom')
query.set_field("test", lambda *_: {"node_field": "custom"})
test.set_field("nodeField", lambda obj, *_: obj["node_field"])
schema = make_executable_schema(
type_defs,
[query, test],
directives={"upper": UpperDirective},
convert_names_case=True,
)
result = graphql_sync(schema, "{ test { nodeField }}")
assert result.errors is None
assert result.data == {"test": {"nodeField": "CUSTOM"}}
python -m pytest tests/test_directives.py::test_field_definition_directive_replaces_field_resolver_with_custom_one
1 passed, 2 warnings in 0.05s
Metadata
Metadata
Assignees
Labels
No labels