ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
# GraphQL API > 原文:[https://docs.gitlab.com/ee/api/graphql/](https://docs.gitlab.com/ee/api/graphql/) * [Getting Started](#getting-started) * [Quick Reference](#quick-reference) * [GraphiQL](#graphiql) * [What is GraphQL?](#what-is-graphql) * [Vision](#vision) * [Available queries](#available-queries) * [Multiplex queries](#multiplex-queries) * [Reference](#reference) # GraphQL API[](#graphql-api "Permalink") 版本历史 * 在 GitLab 11.0 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/19008) (由功能标志`graphql`启用). * [始终](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/30444)在 GitLab 12.1 中[启用](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/30444) . ## Getting Started[](#getting-started "Permalink") 有关 GitLab GraphQL API 的新知识,请参见 GitLab GraphQL API [入门](getting_started.html) . ### Quick Reference[](#quick-reference "Permalink") * GitLab 的 GraphQL API 端点位于`/api/graphql` . * [从 graphql.org](https://s0graphql0org.icopy.site/)获得[GraphQL 的简介](https://s0graphql0org.icopy.site/) . * GitLab 支持广泛的资源,在[GraphQL API Reference 中](reference/index.html)列出. #### GraphiQL[](#graphiql "Permalink") 使用交互式[GraphiQL](https://gitlab.com/-/graphql-explorer)浏览器浏览 GraphQL API,或在`https://<your-gitlab-site.com>/-/graphql-explorer`上的自管理 GitLab 实例上`https://<your-gitlab-site.com>/-/graphql-explorer` . 有关 GraphiQL Explorer 的更多信息,请参见[GitLab GraphQL 概述](getting_started.html#graphiql) . ## What is GraphQL?[](#what-is-graphql "Permalink") [GraphQL](https://s0graphql0org.icopy.site/)是 API 的查询语言,它允许客户端准确地请求他们所需的数据,从而有可能在有限数量的请求中获得所有必需的数据. 可以以类型的形式描述 GraphQL 数据(字段),从而允许客户端使用[客户端 GraphQL 库](https://s0graphql0org.icopy.site/code/)来使用 API​​并避免手动解析. 由于没有固定的端点和数据模型,因此可以在不进行重大更改的情况下将新功能添加到 API. 这使我们可以拥有[GraphQL 文档](https://s0graphql0org.icopy.site/learn/best-practices/)中[所述的无](https://s0graphql0org.icopy.site/learn/best-practices/)版本 API. ## Vision[](#vision "Permalink") 我们希望 GraphQL API 是与 GitLab 进行编程交互的**主要**方式. 为此,它需要全面覆盖-REST API 中可能的一切在 GraphQL API 中也应该可行. 为了帮助我们实现这一愿景,前端应优先使用 GraphQL 而不是 REST API 的新功能. There are no plans to deprecate the REST API. To reduce the technical burden of supporting two APIs in parallel, they should share implementations as much as possible. ## Available queries[](#available-queries "Permalink") GraphQL API 在根级别包含以下查询: 1. `project` :项目信息及其许多关联,例如问题和合并请求. 2. `group` :基本组信息和史诗 目前受支持. 3. `user` :有关特定用户的信息. 4. `namespace` :在名称空间内,也可以提取`projects` . 5. `currentUser` :有关当前登录用户的信息. 6. `users` :有关用户集合的信息. 7. `metaData` :有关 GitLab 和 GraphQL API 的元数据. 8. `snippets` :当前登录用户可见的`snippets` . 新的关联和根级别对象正在不断添加. 有关最新信息,请参见《 [GraphQL API 参考](reference/index.html) 》. 根级查询在[`app/graphql/types/query_type.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/app/graphql/types/query_type.rb) . ### Multiplex queries[](#multiplex-queries "Permalink") GitLab 支持使用[apollo-link-batch-http 将](https://www.apollographql.com/docs/link/links/batch-http/)查询批量处理为单个请求. GitLab 在后端使用的库[GraphQL Ruby](https://graphql-ruby.org/queries/multiplex.html)也提供了有关多路查询的更多信息. ## Reference[](#reference "Permalink") GitLab 的 GraphQL 参考[可用](reference/index.html) . 它是从 GitLab 的 GraphQL 模式自动生成的,并嵌入到 Markdown 文件中. 机器可读版本也可用: * [JSON format](reference/gitlab_schema.json) * [IDL format](reference/gitlab_schema.graphql)