Skip to content
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

Fix graphql deprecation warnings #1056

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions setup.cfg
Expand Up @@ -31,5 +31,3 @@ filterwarnings=
ignore: "@coroutine" decorator is deprecated.*:DeprecationWarning
# https://github.com/graphql-python/graphene/issues/1055
ignore: Using or importing the ABCs from 'collections' instead of from 'collections\.abc' is deprecated.*:DeprecationWarning
ignore: The 'context' alias has been deprecated. Please use 'context_value' instead\.:DeprecationWarning
ignore: The 'variables' alias has been deprecated. Please use 'variable_values' instead\.:DeprecationWarning
8 changes: 4 additions & 4 deletions starlette/graphql.py
Expand Up @@ -123,19 +123,19 @@ async def execute( # type: ignore
if self.is_async:
return await self.schema.execute(
query,
variables=variables,
variable_values=variables,
Copy link
Member Author

Choose a reason for hiding this comment

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

you might instead choose to propagate the rename all the way up?

Copy link
Member

Choose a reason for hiding this comment

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

🤔 I'm in two minds about this. On the one hand, graphene/graphql-core seems to have settled on these names with _value. OTOH, whether we want to properly support GraphQL in Starlette is unclear (#619) so I'm hesitant to make more than the most minimal changes to make the warnings go away.

How about we do go to the effort of renaming the parameters of this function (execute(..., variable_values=None, ...) so that it remains a very small wrapper around calling the schema? But not do anything more than that (although that might be everything there is to do anyway 😅). It doesn't seem to be a documented Starlette API anyway, so it should be safe to change.

operation_name=operation_name,
executor=self.executor,
return_promise=True,
context=context,
context_value=context,
)
else:
return await run_in_threadpool(
self.schema.execute,
query,
variables=variables,
variable_values=variables,
operation_name=operation_name,
context=context,
context_value=context,
)

async def handle_graphiql(self, request: Request) -> Response:
Expand Down