运行查询或变更 已弃用

发布 /groups/{groupId}/apps/{appId}/graphql

以系统用户身份运行查询或突变,绕过身份验证和数据访问规则。您可以通过内省查询访问有关 API 的元数据,包括其模式。

路径参数

application/json

body

  • 查询 字符串 必需

    一个字符串化的 .graphql 文件,其中包含一个或多个适用于 API 的有效 GraphQL 操作。如果已定义多个操作,则必须指定要在 operationName 中运行的操作。

  • variables 字符串

    字符串化的 JSON 对象,其中每个字段名称都会将一个值映射到指定操作中的变量。

  • operationName 字符串

    query 中指定要运行的 GraphQL 操作的名称。

响应

  • 200 application/json

    正常

    隐藏响应属性 显示响应属性 对象
    • 数据 对象| null 必需

      操作成功的结果。如果 null,则操作出错。

    • errors 大量[对象]

      运行操作时遇到的错误列表。

      运行操作时遇到错误。

      至少 1 个元素。

      隐藏错误属性 显示错误属性 对象
      • message 字符串 必需

        描述错误的消息。

      • 位置 大量[对象] 必需

        导致错误的操作中的一个或多个位置的列表。

        导致错误的操作行号和列号。

        隐藏位置属性 显示位置属性 对象
        • line 整型 必需
        • 整型 必需
POST /groups/{groupId}/apps/{appId}/GraphQL
curl \
 --request POST 'https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/graphql' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"query":"query AllTasks { tasks(query: { status: $status }) { _id owner } }","variables":"{ \"status\": \"complete\" }","operationName":"AllTasks"}'
请求示例
{
  "query": "query AllTasks { tasks(query: { status: $status }) { _id owner } }",
  "variables": "{ \"status\": \"complete\" }",
  "operationName": "AllTasks"
}
响应示例 (200)
{
  "data": {},
  "errors": [
    {
      "message": "string",
      "locations": [
        {
          "line": 42,
          "column": 42
        }
      ]
    }
  ]
}