Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit097997a

Browse files
committed
feat: add basic GraphQL support (wip)
1 parentc7cf0d1 commit097997a

File tree

13 files changed

+328
-100
lines changed

13 files changed

+328
-100
lines changed

‎docs/api-usage.rst‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
############################
2-
Getting started withthe API
3-
############################
1+
##################
2+
Usingthe REST API
3+
##################
44

5-
python-gitlab only supports GitLabAPI v4.
5+
python-gitlabcurrentlyonly supportsv4 of theGitLabREST API.
66

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

‎docs/cli-usage.rst‎

Lines changed: 3 additions & 3 deletions
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.

‎docs/graphql-api-usage.rst‎

Lines changed: 55 additions & 0 deletions
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)

‎docs/index.rst‎

Lines changed: 1 addition & 0 deletions
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

‎gitlab/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
__title__,
3030
__version__,
3131
)
32-
fromgitlab.clientimportGitlab,GitlabList# noqa: F401
32+
fromgitlab.clientimportGitlab,GitlabList,GraphQLGitlab# noqa: F401
3333
fromgitlab.exceptionsimport*# noqa: F401,F403
3434

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp