# GraphQL 模式

当您需要精确的模式端点、想要检查当前公共 GraphQL 接口、或者需要用于工具和离线分析的 SDL 时，请使用此页面。

跳转到：

 * [端点](#Endpoints)
 * [公共集成边界](#Public%20integration%20boundary)
 * [实时自省](#Live%20introspection)
 * [工具指南](#Tooling%20recipes)
 * [相关参考页面](#Related%20reference%20pages)

## 端点

使用这些端点进行模式检查：

 * GraphQL 端点：https://api.cloud.luxonis.com/graphql
 * 控制平面身份验证：Authorization: Bearer <your_api_key>
 * 自省访问：无需身份验证即可使用
 * 公共集成根：team { ... }

如果您需要请求形状基础知识或 GraphQL 术语，请继续阅读 [关于 GraphQL](https://docs.luxonis.com/cloud/api/graphql.md)。

## 公共集成边界

对于外部集成，请围绕公共 team { ... } 接口进行设计，并使用官方指南和参考页面以及模式检查。

## 实时自省

通过 GraphQL 端点自省当前公共模式：

```http
https://api.cloud.luxonis.com/graphql
```

无需身份验证即可访问自省。如果您已经使用经过身份验证的 GraphQL 客户端进行测试，则相同的端点仍然有效。

### 在 GraphQL 客户端中检查

当您想要以交互方式浏览类型、字段、参数和枚举时，请使用 GraphQL 客户端，例如 [Altair](https://altairgraphql.dev/)。

 * 端点：https://api.cloud.luxonis.com/graphql
 * 最佳用途：在编写查询或变更之前检查字段名称、输入对象形状和枚举值

### 最小的自省请求

如果您需要验证从您的环境是否可以访问自省，请发送如下最小的查询：

```bash
curl -X POST https://api.cloud.luxonis.com/graphql \
  -H "Content-Type: application/json" \
  -d '{"query":"{ __schema { queryType { name } mutationType { name } } }"}'
```

## 工具指南

### 从您检入的操作生成类型化客户端

对于生产应用程序，最好从您实际使用的查询和变更中生成类型，而不是在每次更改时手动浏览模式。

```yaml
schema: https://api.cloud.luxonis.com/graphql
documents: ./src/**/*.graphql
```

这是实际的工作流程：

 * 定义您的集成所需的查询和变更
 * 根据当前模式生成类型
 * 将生成错误视为操作或模式合约已更改的信号

选择与任务匹配的检查路径：

 * 当您需要快速检查一个字段、参数或输入形状时，使用实时自省。
 * 当您已经知道要查找的操作类型时，使用 [查询](https://docs.luxonis.com/cloud/api/reference/control-api/queries.md) 和
   [变更](https://docs.luxonis.com/cloud/api/reference/control-api/mutations.md)。

## 相关参考页面

### Queries

Review the available read operations exposed by the public GraphQL API.

[Queries](https://docs.luxonis.com/cloud/api/reference/control-api/queries.md)

### Mutations

Review the available write operations and team-scoped control flows.

[Mutations](https://docs.luxonis.com/cloud/api/reference/control-api/mutations.md)

### Types

Inspect the public object and connection types returned by queries and mutations.

[Types](https://docs.luxonis.com/cloud/api/reference/control-api/types.md)

### About GraphQL

Return to the request shape, public boundaries, and Hub-specific GraphQL usage patterns.

[About GraphQL](https://docs.luxonis.com/cloud/api/graphql.md)
