Run a query or mutation
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
-
An Atlas Project/Group ID.
-
The ObjectID of your application. The App Services API Project and Application IDs section demonstrates how to find this value.
Body
-
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 inoperationName
. -
A stringified JSON object where each field name maps a value to a variable in the specified operation.
-
The name of the GraphQL operation specified in
query
to run.
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
}
]
}
]
}