Skip to content

Feature/fix deprecation warnings #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ target/
.pyre
/.vscode
/type_info.json
/.venv
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ matrix:
python: 3.5
- env: TOXENV=py36
python: 3.6
# - env: TOXENV=py37
# python: 3.7
# - env: TOXENV=py37
# python: 3.7
- env: TOXENV=pypy
python: pypy-5.7.1
- env: TOXENV=pre-commit
Expand Down
4 changes: 2 additions & 2 deletions graphql/execution/tests/test_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def batch_load_fn(self, keys):
class Context(object):
business_data_loader = BusinessDataLoader()

result = execute(schema, doc_ast, None, context_value=Context(), executor=executor)
result = execute(schema, doc_ast, None, context=Context(), executor=executor)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of removing _value from a bunch of the kwargs throughout this review? Is there some issue related to this where that's explained? A personal preference?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless one has a foo and a foo_value, the suffix seems confusing. This is a Context instance, so the lower-case variable name seems a good fit

Copy link
Member

@Cito Cito Mar 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this change is that these parameters have been renamed in graphql-core where the _value postfix was removed in June 2018 and you get deprecation warnings now if you use the _value postfix. That's why @ekampf removed the postfixes here as well.

However, I think we should revert the removal of _value in graphql-core - see #234.

assert not result.errors
assert result.data == {"business1": {"id": "1"}, "business2": {"id": "2"}}
assert load_calls == [["1", "2"]]
Expand Down Expand Up @@ -161,7 +161,7 @@ class Context(object):
business_data_loader = BusinessDataLoader()
location_data_loader = LocationDataLoader()

result = execute(schema, doc_ast, None, context_value=Context(), executor=executor)
result = execute(schema, doc_ast, None, context=Context(), executor=executor)
assert not result.errors
assert result.data == {
"business1": {"id": "1", "location": {"id": "location-1"}},
Expand Down
2 changes: 1 addition & 1 deletion graphql/execution/tests/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def deeper(self):
schema = GraphQLSchema(query=DataType)

result = execute(
schema, ast, Data(), operation_name="Example", variable_values={"size": 100}
schema, ast, Data(), operation_name="Example", variables={"size": 100}
)
assert not result.errors
assert result.data == expected
Expand Down
6 changes: 2 additions & 4 deletions graphql/execution/tests/test_executor_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,13 @@ def handle_result(result):
schema,
ast,
Data(),
variable_values={"size": 100},
variables={"size": 100},
operation_name="Example",
executor=ThreadExecutor(),
)
)
handle_result(
execute(
schema, ast, Data(), variable_values={"size": 100}, operation_name="Example"
)
execute(schema, ast, Data(), variables={"size": 100}, operation_name="Example")
)


Expand Down
2 changes: 1 addition & 1 deletion graphql/execution/tests/test_subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def test_accepts_an_object_with_named_properties_as_arguments():
}
"""
)
result = subscribe(email_schema, document, root_value=None)
result = subscribe(email_schema, document, root=None)
assert isinstance(result, Observable)


Expand Down
2 changes: 1 addition & 1 deletion graphql/execution/tests/test_union_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def resolve_type(obj, info):
context = {"hey"}
ast = parse("""{ name, friends { name } }""")

result = execute(schema2, ast, john2, context_value=context)
result = execute(schema2, ast, john2, context=context)
assert not result.errors
assert result.data == {"name": "John", "friends": [{"name": "Liz"}]}

Expand Down
2 changes: 1 addition & 1 deletion graphql/execution/tests/test_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def check(
):
# type: (...) -> None
ast = parse(doc)
response = execute(schema, ast, variable_values=args)
response = execute(schema, ast, variables=args)

if response.errors:
result = {
Expand Down
8 changes: 6 additions & 2 deletions graphql/execution/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,15 @@ def __init__(
self.variable_values = variable_values
self.errors = errors
self.context_value = context_value
self.argument_values_cache = {} # type: Dict[Tuple[GraphQLField, Field], Dict[str, Any]]
self.argument_values_cache = (
{}
) # type: Dict[Tuple[GraphQLField, Field], Dict[str, Any]]
self.executor = executor
self.middleware = middleware
self.allow_subscriptions = allow_subscriptions
self._subfields_cache = {} # type: Dict[Tuple[GraphQLObjectType, Tuple[Field, ...]], DefaultOrderedDict]
self._subfields_cache = (
{}
) # type: Dict[Tuple[GraphQLObjectType, Tuple[Field, ...]], DefaultOrderedDict]

def get_field_resolver(self, field_resolver):
# type: (Callable) -> Callable
Expand Down
12 changes: 6 additions & 6 deletions graphql/type/tests/test_enum_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def test_accepts_json_string_as_enum_variable():
result = graphql(
Schema,
"query test($color: Color!) { colorEnum(fromEnum: $color) }",
variable_values={"color": "BLUE"},
variables={"color": "BLUE"},
)
assert not result.errors
assert result.data == {"colorEnum": "BLUE"}
Expand All @@ -171,7 +171,7 @@ def test_accepts_enum_literals_as_input_arguments_to_mutations():
result = graphql(
Schema,
"mutation x($color: Color!) { favoriteEnum(color: $color) }",
variable_values={"color": "GREEN"},
variables={"color": "GREEN"},
)
assert not result.errors
assert result.data == {"favoriteEnum": "GREEN"}
Expand All @@ -181,7 +181,7 @@ def test_accepts_enum_literals_as_input_arguments_to_subscriptions():
result = graphql(
Schema,
"subscription x($color: Color!) { subscribeToEnum(color: $color) }",
variable_values={"color": "GREEN"},
variables={"color": "GREEN"},
allow_subscriptions=True,
)
assert isinstance(result, Observable)
Expand All @@ -196,7 +196,7 @@ def test_does_not_accept_internal_value_as_enum_variable():
result = graphql(
Schema,
"query test($color: Color!) { colorEnum(fromEnum: $color) }",
variable_values={"color": 2},
variables={"color": 2},
)
assert not result.data
assert (
Expand All @@ -209,7 +209,7 @@ def test_does_not_accept_string_variables_as_enum_input():
result = graphql(
Schema,
"query test($color: String!) { colorEnum(fromEnum: $color) }",
variable_values={"color": "BLUE"},
variables={"color": "BLUE"},
)
assert not result.data
assert (
Expand All @@ -222,7 +222,7 @@ def test_does_not_accept_internal_value_as_enum_input():
result = graphql(
Schema,
"query test($color: Int!) { colorEnum(fromEnum: $color) }",
variable_values={"color": 2},
variables={"color": 2},
)
assert not result.data
assert (
Expand Down
8 changes: 6 additions & 2 deletions graphql/utils/type_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ def __init__(self, schema, get_field_def_fn=get_field_def):
# type: (GraphQLSchema, Callable) -> None
self._schema = schema
self._type_stack = [] # type: List[Optional[GraphQLType]]
self._parent_type_stack = [] # type: List[Union[GraphQLInterfaceType, GraphQLObjectType, None]]
self._input_type_stack = [] # type: List[Optional[Union[GraphQLInputObjectType, GraphQLNonNull, GraphQLList, GraphQLScalarType, None]]]
self._parent_type_stack = (
[]
) # type: List[Union[GraphQLInterfaceType, GraphQLObjectType, None]]
self._input_type_stack = (
[]
) # type: List[Optional[Union[GraphQLInputObjectType, GraphQLNonNull, GraphQLList, GraphQLScalarType, None]]]
self._field_def_stack = [] # type: List[Optional[GraphQLField]]
self._directive = None # type: Optional[GraphQLDirective]
self._argument = None # type: Optional[GraphQLArgument]
Expand Down
4 changes: 3 additions & 1 deletion graphql/validation/rules/overlapping_fields_can_be_merged.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def __init__(self, context):
# A cache for the "field map" and list of fragment names found in any given
# selection set. Selection sets may be asked for this information multiple
# times, so this improves the performance of this validator.
self._cached_fields_and_fragment_names = {} # type: Dict[SelectionSet, Tuple[Dict[str, List[Tuple[Union[GraphQLInterfaceType, GraphQLObjectType, None], Field, GraphQLField]]], List[str]]]
self._cached_fields_and_fragment_names = (
{}
) # type: Dict[SelectionSet, Tuple[Dict[str, List[Tuple[Union[GraphQLInterfaceType, GraphQLObjectType, None], Field, GraphQLField]]], List[str]]]

def leave_SelectionSet(
self,
Expand Down
8 changes: 6 additions & 2 deletions graphql/validation/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ def __init__(self, schema, ast, type_info):
self._errors = [] # type: List[GraphQLError]
self._fragments = None # type: Optional[Dict[str, FragmentDefinition]]
self._fragment_spreads = {} # type: Dict[Node, List[FragmentSpread]]
self._recursively_referenced_fragments = {} # type: Dict[OperationDefinition, List[FragmentSpread]]
self._recursively_referenced_fragments = (
{}
) # type: Dict[OperationDefinition, List[FragmentSpread]]
self._variable_usages = {} # type: Dict[Node, List[VariableUsage]]
self._recursive_variable_usages = {} # type: Dict[OperationDefinition, List[VariableUsage]]
self._recursive_variable_usages = (
{}
) # type: Dict[OperationDefinition, List[VariableUsage]]

def report_error(self, error):
self._errors.append(error)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
install_requires = ["six>=1.10.0", "promise>=2.1", "rx>=1.6.0"]

tests_requires = [
"pytest==3.0.2",
"pytest~=3.8.1",
"pytest-django==2.9.1",
"pytest-cov==2.3.1",
"coveralls",
"gevent==1.1rc1",
"gevent~=1.3.6",
"six>=1.10.0",
"pytest-benchmark==3.0.0",
"pytest-mock==1.2",
Expand Down
6 changes: 3 additions & 3 deletions tests/starwars/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test_fetch_some_id_query():
"""
params = {"someId": "1000"}
expected = {"human": {"name": "Luke Skywalker"}}
result = graphql(StarWarsSchema, query, variable_values=params)
result = graphql(StarWarsSchema, query, variables=params)
assert not result.errors
assert result.data == expected

Expand All @@ -141,7 +141,7 @@ def test_fetch_some_id_query2():
"""
params = {"someId": "1002"}
expected = {"human": {"name": "Han Solo"}}
result = graphql(StarWarsSchema, query, variable_values=params)
result = graphql(StarWarsSchema, query, variables=params)
assert not result.errors
assert result.data == expected

Expand All @@ -156,7 +156,7 @@ def test_invalid_id_query():
"""
params = {"id": "not a valid id"}
expected = {"human": None}
result = graphql(StarWarsSchema, query, variable_values=params)
result = graphql(StarWarsSchema, query, variables=params)
assert not result.errors
assert result.data == expected

Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ envlist = py27,py34,py35,py36,py37,pre-commit,pypy,mypy,docs

[testenv]
deps =
pytest>=2.7.2
gevent==1.1rc1
pytest>=3.8.1
gevent~=1.3.6
promise>=2.0
six>=1.10.0
pytest-mock
Expand Down