summaryrefslogtreecommitdiff
path: root/gitlab/graphql/transport.py
diff options
context:
space:
mode:
Diffstat (limited to 'gitlab/graphql/transport.py')
-rw-r--r--gitlab/graphql/transport.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/gitlab/graphql/transport.py b/gitlab/graphql/transport.py
new file mode 100644
index 0000000..26c3700
--- /dev/null
+++ b/gitlab/graphql/transport.py
@@ -0,0 +1,25 @@
+from typing import Any
+
+import requests
+from gql.transport.requests import RequestsHTTPTransport
+
+
+class GitlabSyncTransport(RequestsHTTPTransport):
+ """A gql requests transport that reuses an existing requests.Session.
+
+ By default, gql's requests transport does not have a keep-alive session
+ and does not enable providing your own session.
+
+ This transport lets us provide and close our session on our own.
+ For details, see https://github.com/graphql-python/gql/issues/91.
+ """
+
+ def __init__(self, *args: Any, session: requests.Session, **kwargs: Any):
+ super().__init__(*args, **kwargs)
+ self.session = session
+
+ def connect(self) -> None:
+ pass
+
+ def close(self) -> None:
+ pass