Run a query or mutation

POST /groups/{groupId}/apps/{appId}/graphql

Run a query or mutation as a system user that bypasses authentication and data access rules. You can access metadata about your API, including its schema, with an introspection query.

Path parameters

application/json

Body

  • query string Required

    A stringified .graphql file that contains one or more valid GraphQL operations for your API. If more than one operation is defined, you must specify which operation to run in operationName.

  • variables string

    A stringified JSON object where each field name maps a value to a variable in the specified operation.

  • operationName string

    The name of the GraphQL operation specified in query to run.

Responses

  • 200 application/json

    OK

    Hide response attributes Show response attributes object
    • data object | null Required

      The result of a successful operation. If null, the operation had errors.

    • errors array[object]

      A list of errors encountered while running an operation.

      An error encountered while running an operation.

      At least 1 element.

      Hide errors attributes Show errors attributes object
      • message string Required

        A message that describes the error.

      • locations array[object] Required

        A list of one or more locations in the operation that caused the error.

        The operation line and column numbers that caused an error.

        Hide locations attributes Show locations attributes object
        • line integer Required
        • column integer Required
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"}'
Request examples
{
  "query": "query AllTasks { tasks(query: { status: $status }) { _id owner } }",
  "variables": "{ \"status\": \"complete\" }",
  "operationName": "AllTasks"
}
Response examples (200)
{
  "data": {},
  "errors": [
    {
      "message": "string",
      "locations": [
        {
          "line": 42,
          "column": 42
        }
      ]
    }
  ]
}