GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python-gitlab/docs/api-usage-graphql.rst at main · python-gitlab/python-gitlab

Expand file tree

/

api-usage-graphql.rst

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
74 lines (52 loc) · 2.13 KB
/

api-usage-graphql.rst

Copy path

File metadata and controls

74 lines (52 loc) · 2.13 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Using the GraphQL API (beta)

python-gitlab provides basic support for executing GraphQL queries and mutations, providing both a synchronous and asynchronous client.

!DANGER!

The GraphQL client is experimental and only provides basic support. It does not currently support pagination, obey rate limits, or attempt complex retries. You can use it to build simple queries and mutations.

It is currently unstable and its implementation may change. You can expect a more mature client in one of the upcoming versions.

The gitlab.GraphQL and gitlab.AsyncGraphQL classes

As with the REST client, you connect to a GitLab instance by creating a gitlab.GraphQL (for synchronous code) or gitlab.AsyncGraphQL instance (for asynchronous code):

import gitlab

# anonymous read-only access for public resources (GitLab.com)
gq = gitlab.GraphQL()

# anonymous read-only access for public resources (self-hosted GitLab instance)
gq = gitlab.GraphQL('https://gitlab.example.com')

# personal access token or OAuth2 token authentication (GitLab.com)
gq = gitlab.GraphQL(token='glpat-JVNSESs8EwWRx5yDxM5q')

# personal access token or OAuth2 token authentication (self-hosted GitLab instance)
gq = gitlab.GraphQL('https://gitlab.example.com', token='glpat-JVNSESs8EwWRx5yDxM5q')

# or the async equivalents
async_gq = gitlab.AsyncGraphQL()
async_gq = gitlab.AsyncGraphQL('https://gitlab.example.com')
async_gq = gitlab.AsyncGraphQL(token='glpat-JVNSESs8EwWRx5yDxM5q')
async_gq = gitlab.AsyncGraphQL('https://gitlab.example.com', token='glpat-JVNSESs8EwWRx5yDxM5q')

Sending queries

Get the result of a query:

query = """
{
    currentUser {
        name
    }
}
"""

result = gq.execute(query)

Get the result of a query using the async client:

query = """
{
    currentUser {
        name
    }
}
"""

result = await async_gq.execute(query)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.