Skip to content

Commit b24798d

Browse files
authored
chore(deps): update gql to v4 (#598)
* chore(deps): update gql to v4.0.0 * fix: use non-deprecated gql calls It's worth mentioning that the documentation suggests[^1] setting `variable_values` directly on the (in our case, global) query object, and doesn't really talk about race conditions, but I would assume they can happen, especially in async code. It might be fine if you call `gql.gql(<str>)` every time, which might be what the documentation suggests, but that seems like a performance nightmare. Therefore, we just construct a new `GraphQLRequest` from the existing globals, which automatically copies over the parsed `Document` node, so it should have little to no overhead. [^1]: https://gql.readthedocs.io/en/latest/usage/variables.html * feat: improve gql logging level overrides transports now log with `DEBUG` instead of `INFO`, so we can go back up to `INFO` without getting too spammy. * fix: remove now unnecessary ssl param for gql transport
1 parent 62c2409 commit b24798d

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

monty/exts/info/github_info.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,7 @@ class GithubInfo(
221221
def __init__(self, bot: Monty) -> None:
222222
self.bot = bot
223223

224-
transport = AIOHTTPTransport(
225-
url="https://api.github.com/graphql", timeout=20, headers=GITHUB_REQUEST_HEADERS, ssl=True
226-
)
224+
transport = AIOHTTPTransport(url="https://api.github.com/graphql", timeout=20, headers=GITHUB_REQUEST_HEADERS)
227225

228226
self.gql = gql.Client(transport=transport, fetch_schema_from_transport=True)
229227

@@ -575,12 +573,14 @@ async def fetch_issues(
575573

576574
try:
577575
json_data = await self.gql.execute_async(
578-
DISCUSSION_GRAPHQL_QUERY,
579-
variable_values={
580-
"user": user,
581-
"repository": repository,
582-
"number": number,
583-
},
576+
gql.GraphQLRequest(
577+
DISCUSSION_GRAPHQL_QUERY,
578+
variable_values={
579+
"user": user,
580+
"repository": repository,
581+
"number": number,
582+
},
583+
)
584584
)
585585
except (TransportError, TransportQueryError):
586586
return FetchError(-1, "Issue not found.")
@@ -1010,10 +1010,12 @@ async def handle_issue_comment(
10101010

10111011
try:
10121012
json_data = await self.gql.execute_async(
1013-
DISCUSSION_COMMENT_GRAPHQL_QUERY,
1014-
variable_values={
1015-
"id": global_id,
1016-
},
1013+
gql.GraphQLRequest(
1014+
DISCUSSION_COMMENT_GRAPHQL_QUERY,
1015+
variable_values={
1016+
"id": global_id,
1017+
},
1018+
)
10171019
)
10181020
except (TransportError, TransportQueryError) as e:
10191021
log.warning("encountered error fetching discussion comment: %s", e)

monty/log.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ def setup() -> None:
102102
logging.getLogger("cachingutils").setLevel(logging.INFO)
103103
logging.getLogger("sqlalchemy.engine").setLevel(logging.DEBUG)
104104
logging.getLogger("sqlalchemy.pool").setLevel(logging.INFO)
105-
logging.getLogger("gql.transport.aiohttp").setLevel(logging.WARNING)
105+
logging.getLogger("gql.dsl").setLevel(logging.INFO)
106+
logging.getLogger("gql.transport.aiohttp").setLevel(logging.INFO)
106107
_set_trace_loggers()
107108

108109
root_logger.info("Logging initialization complete")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies = [
2222
"colorama~=0.4.5; sys_platform == \"win32\"",
2323
"disnake @ git+https://github.com/DisnakeDev/disnake.git@master",
2424
"orjson<4.0.0,>=3.10.18",
25-
"gql<4.0.0,>=3.5.2",
25+
"gql~=4.0",
2626
"lxml<6.0.0,>=5.4.0",
2727
"markdownify==0.11.6",
2828
"mistune<3.0.0,>=2.0.4",

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)