8000 Add sync batching to requests sync transport by itolosa · Pull Request #431 · graphql-python/gql · GitHub
[go: up one dir, main page]

Skip to content

Add sync batching to requests sync transport #431

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
merged 15 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update library locations and reformat
  • Loading branch information
itolosa committed Sep 5, 2023
commit afe90ef7bdf6b2604ed1ebbbb57d8cbf044a797a
2 changes: 1 addition & 1 deletion gql/client.py
10000
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def execute_batch(
- execute the GraphQL requests on the transport session
- close the session and close the connection to the server

If you want to perform multiple executions, it is better to use
If you want to perform multiple executions, it is better to use
the context manager to keep a session active.

The extra arguments passed in the method will be passed to the transport
Expand Down
5 changes: 2 additions & 3 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import pytest
from graphql import build_ast_schema, parse

from gql import Client, gql
from gql import Client, GraphQLRequest, gql
from gql.transport import Transport
from gql.transport.data_structures.graphql_request import GraphQLRequest
from gql.transport.exceptions import TransportQueryError

with suppress(ModuleNotFoundError):
Expand Down Expand Up @@ -44,7 +43,7 @@ def execute_batch(self):

with pytest.raises(NotImplementedError) as exc_info:
RandomTransport().execute_batch()
assert "Any Transport subclass must implement execute_batch method" == str(
assert "This Transport has not implemented the execute_batch method" == str(
exc_info.value
)

Expand Down
16 changes: 0 additions & 16 deletions tests/test_httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pytest

from gql import Client, gql
from gql.transport.data_structures import GraphQLRequest
from gql.transport.exceptions import (
TransportAlreadyConnected,
TransportClosed,
Expand Down Expand Up @@ -34,21 +33,6 @@
)


@pytest.mark.aiohttp
@pytest.mark.asyncio
def test_httpx_execute_batch_is_not_implemented():
from gql.transport.httpx import HTTPXTransport

with Client(transport=HTTPXTransport(url="/")) as session:
reqs = [GraphQLRequest(document=gql(query1_str))]

with pytest.raises(NotImplementedError) as exc_info:
session.execute_batch(reqs)
assert "Any Transport subclass must implement execute_batch method" == str(
exc_info.value
)


@pytest.mark.aiohttp
@pytest.mark.asyncio
async def test_httpx_query(event_loop, aiohttp_server, run_sync_test):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_requests_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import pytest

from gql import Client, gql
from gql.transport.data_structures.graphql_request import GraphQLRequest
from gql import Client, GraphQLRequest, gql
from gql.transport.exceptions import (
TransportClosed,
TransportProtocolError,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_transport_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

from gql import Client, gql
from gql.transport.data_structures.graphql_request import GraphQLRequest
from gql.graphql_request import GraphQLRequest

# We serve https://github.com/graphql-python/swapi-graphene locally:
URL = "http://127.0.0.1:8000/graphql"
Expand Down
0