Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 097997a

Browse filesBrowse files
committed
feat: add basic GraphQL support (wip)
1 parent c7cf0d1 commit 097997a
Copy full SHA for 097997a

File tree

Expand file treeCollapse file tree

13 files changed

+328
-100
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

13 files changed

+328
-100
lines changed
Open diff view settings
Collapse file

‎docs/api-usage.rst‎

Copy file name to clipboardExpand all lines: docs/api-usage.rst
+4-4Lines changed: 4 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
############################
2-
Getting started with the API
3-
############################
1+
##################
2+
Using the REST API
3+
##################
44

5-
python-gitlab only supports GitLab API v4.
5+
python-gitlab currently only supports v4 of the GitLab REST API.
66

77
``gitlab.Gitlab`` class
88
=======================
Collapse file

‎docs/cli-usage.rst‎

Copy file name to clipboardExpand all lines: docs/cli-usage.rst
+3-3Lines changed: 3 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
############################
2-
Getting started with the CLI
3-
############################
1+
#############
2+
Using the CLI
3+
#############
44

55
``python-gitlab`` provides a :command:`gitlab` command-line tool to interact
66
with GitLab servers.
Collapse file

‎docs/graphql-api-usage.rst‎

Copy file name to clipboard
+55Lines changed: 55 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#####################
2+
Using the GraphQL API
3+
#####################
4+
5+
python-gitlab provides basic support for executing GraphQL queries and mutations.
6+
7+
.. danger::
8+
9+
The GraphQL client is experimental and only provides basic support.
10+
It does not currently support pagination, obey rate limits,
11+
or attempt complex retries. You can use it to build simple queries
12+
13+
It is currently unstable and its implementation may change. You can expect a more
14+
mature client in one of the upcoming major versions.
15+
16+
The ``gitlab.GraphQLGitlab`` class
17+
==================================
18+
19+
As with the REST client, you connect to a GitLab instance by creating a ``gitlab.GraphQLGitlab`` object:
20+
21+
.. code-block:: python
22+
23+
import gitlab
24+
25+
# anonymous read-only access for public resources (GitLab.com)
26+
gl = gitlab.GraphQLGitlab()
27+
28+
# anonymous read-only access for public resources (self-hosted GitLab instance)
29+
gl = gitlab.GraphQLGitlab('https://gitlab.example.com')
30+
31+
# private token or personal token authentication (GitLab.com)
32+
gl = gitlab.GraphQLGitlab(private_token='JVNSESs8EwWRx5yDxM5q')
33+
34+
# private token or personal token authentication (self-hosted GitLab instance)
35+
gl = gitlab.GraphQLGitlab(url='https://gitlab.example.com', private_token='JVNSESs8EwWRx5yDxM5q')
36+
37+
# oauth token authentication
38+
gl = gitlab.GraphQLGitlab('https://gitlab.example.com', oauth_token='my_long_token_here')
39+
40+
Sending queries
41+
===============
42+
43+
Get the result of a simple query:
44+
45+
.. code-block:: python
46+
47+
query = """{
48+
query {
49+
currentUser {
50+
name
51+
}
52+
}
53+
"""
54+
55+
result = gl.execute(query)
Collapse file

‎docs/index.rst‎

Copy file name to clipboardExpand all lines: docs/index.rst
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
cli-usage
88
api-usage
99
api-usage-advanced
10+
graphql-api-usage
1011
cli-examples
1112
api-objects
1213
api/gitlab
Collapse file

‎gitlab/__init__.py‎

Copy file name to clipboardExpand all lines: gitlab/__init__.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
__title__,
3030
__version__,
3131
)
32-
from gitlab.client import Gitlab, GitlabList # noqa: F401
32+
from gitlab.client import Gitlab, GitlabList, GraphQLGitlab # noqa: F401
3333
from gitlab.exceptions import * # noqa: F401,F403
3434

3535
warnings.filterwarnings("default", category=DeprecationWarning, module="^gitlab")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.