Skip to content
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ classifiers = [
requires-python = ">=3.9"
dependencies = [
"aiohttp[speedups]~=3.8",
"gql[aiohttp,requests]>=3.5.1,<5",
"gql[aiohttp,requests]>=4,<5",
"pyjwt[crypto]~=2.8",
"requests~=2.31",
]
Expand Down
8 changes: 6 additions & 2 deletions src/simple_github/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ def execute(self, query: str, variables: RequestData = None) -> Dict[str, Any]:
Dict: The result of the executed query.
"""
session = self._get_gql_session()
return session.execute(gql(query), variable_values=variables)
gql_query = gql(query)
gql_query.variable_values = variables
return session.execute(gql_query)


class AsyncClient(Client):
Expand Down Expand Up @@ -350,4 +352,6 @@ async def execute(
Dict: The result of the executed query.
"""
session = await self._get_gql_session()
return await session.execute(gql(query), variable_values=variables)
gql_query = gql(query)
gql_query.variable_values = variables
return await session.execute(gql_query)
26 changes: 25 additions & 1 deletion test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,41 @@ def test_sync_client_rest_with_text(responses, sync_client):
@pytest.mark.asyncio
async def test_async_client_graphql(aioresponses, async_client):
client = async_client

aioresponses.post(
GITHUB_GRAPHQL_ENDPOINT, status=200, payload={"data": {"foo": "bar"}}
GITHUB_GRAPHQL_ENDPOINT,
status=200,
payload={"data": {"foo": "bar"}},
)
query = "query { viewer { login }}"
result = await client.execute(query)
assert result == {"foo": "bar"}

aioresponses.post(
GITHUB_GRAPHQL_ENDPOINT,
status=200,
payload={"data": {"user": {"email": "octocat@github.com"}}},
)
query = "query($user:String!) { user(login: $user) { email }}"
variables = {"user": "octocat"}
result = await client.execute(query, variables)
assert result == {"user": {"email": "octocat@github.com"}}


def test_sync_client_graphql(responses, sync_client):
client = sync_client

responses.post(GITHUB_GRAPHQL_ENDPOINT, status=200, json={"data": {"foo": "bar"}})
query = "query { viewer { login }}"
result = client.execute(query)
assert result == {"foo": "bar"}

responses.post(
GITHUB_GRAPHQL_ENDPOINT,
status=200,
json={"data": {"user": {"email": "octocat@github.com"}}},
)
query = "query($user:String!) { user(login: $user) { email }}"
variables = {"user": "octocat"}
result = client.execute(query, variables)
assert result == {"user": {"email": "octocat@github.com"}}
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading