Skip to content

Remove Client type_def obsolete argument #262

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

Merged
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
15 changes: 0 additions & 15 deletions gql/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
import warnings
from typing import Any, AsyncGenerator, Dict, Generator, Optional, Union

from graphql import (
Expand Down Expand Up @@ -45,7 +44,6 @@ def __init__(
self,
schema: Optional[Union[str, GraphQLSchema]] = None,
introspection=None,
type_def: Optional[str] = None,
transport: Optional[Union[Transport, AsyncTransport]] = None,
fetch_schema_from_transport: bool = False,
execute_timeout: Optional[Union[int, float]] = 10,
Expand All @@ -67,19 +65,6 @@ def __init__(
:param parse_results: Whether gql will try to parse the serialized output
sent by the backend. Can be used to unserialize custom scalars or enums.
"""
assert not (
type_def and introspection
), "Cannot provide introspection and type definition at the same time."

if type_def:
assert (
not schema
), "Cannot provide type definition and schema at the same time."
warnings.warn(
"type_def is deprecated; use schema instead",
category=DeprecationWarning,
)
schema = type_def

if introspection:
assert (
Expand Down
21 changes: 3 additions & 18 deletions tests/test_async_client_validation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import asyncio
import json
import warnings

import graphql
import pytest
Expand Down Expand Up @@ -83,7 +82,6 @@ async def server_starwars(ws, path):
[
{"schema": StarWarsSchema},
{"introspection": StarWarsIntrospection},
{"type_def": StarWarsTypeDef},
{"schema": StarWarsTypeDef},
],
)
Expand All @@ -97,11 +95,7 @@ async def test_async_client_validation(

sample_transport = WebsocketsTransport(url=url)

with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", message="type_def is deprecated; use schema instead"
)
client = Client(transport=sample_transport, **client_params)
client = Client(transport=sample_transport, **client_params)

async with client as session:

Expand Down Expand Up @@ -135,7 +129,6 @@ async def test_async_client_validation(
[
{"schema": StarWarsSchema},
{"introspection": StarWarsIntrospection},
{"type_def": StarWarsTypeDef},
{"schema": StarWarsTypeDef},
],
)
Expand All @@ -149,11 +142,7 @@ async def test_async_client_validation_invalid_query(

sample_transport = WebsocketsTransport(url=url)

with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", message="type_def is deprecated; use schema instead"
)
client = Client(transport=sample_transport, **client_params)
client = Client(transport=sample_transport, **client_params)

async with client as session:

Expand All @@ -174,11 +163,7 @@ async def test_async_client_validation_invalid_query(
@pytest.mark.parametrize("subscription_str", [starwars_invalid_subscription_str])
@pytest.mark.parametrize(
"client_params",
[
{"schema": StarWarsSchema, "introspection": StarWarsIntrospection},
{"schema": StarWarsSchema, "type_def": StarWarsTypeDef},
{"introspection": StarWarsIntrospection, "type_def": StarWarsTypeDef},
],
[{"schema": StarWarsSchema, "introspection": StarWarsIntrospection}],
)
async def test_async_client_validation_different_schemas_parameters_forbidden(
event_loop, server, subscription_str, client_params
Expand Down