Atlas App Services has reached its end-of-life status and is no longer actively supported by MongoDB. Triggers remain available in the Atlas UI. Refer to the deprecation page for details.
Overview
You can access your App's Atlas GraphQL API through a terminal or command line interface. GraphQL operates over HTTP, so the CLI can be a standard HTTP client, like curl
, or a specialized GraphQL CLI, like graphqurl.
To send GraphQL requests to your app, you'll need the following:
Your App ID.
A valid user access token. For details on how to get an access token, see Authenticate GraphQL Requests.
Run a Query
gq https://services.cloud.mongodb.com/api/client/v2.0/app/<Your App ID>/graphql \ -H 'Authorization: Bearer <Valid Access Token>' \ -q 'query AllMoviesFromYear($year: Int!) { movies(query: { year: $year }) { title year runtime } }' \ -v 'year=2000'
curl https://services.cloud.mongodb.com/api/client/v2.0/app/<Your App ID>/graphql \ -X POST \ -H 'Authorization: Bearer <Valid Access Token>' \ -d '{ "query": "query AllMoviesFromYear($year: Int!) { movies(query: { year: $year }) { title year runtime } }", "variables": { "year": 2000 } }'
Run a Mutation
gq https://services.cloud.mongodb.com/api/client/v2.0/app/<Your App ID>/graphql \ -H 'Authorization: Bearer <Valid Access Token>' \ -q 'mutation UpdateMovieTitle($oldTitle: String!, $newTitle: String!) { updateOneMovie(query: { title: $oldTitle } set: { title: $newTitle }) { title year } }' -v 'oldTitle=The Matrix Reloaded' -v 'newTitle=The Matrix 2'
curl https://services.cloud.mongodb.com/api/client/v2.0/app/<Your App ID>/graphql \ -X POST \ -H 'Authorization: Bearer <Valid Access Token>' \ -d '{ "query": "mutation UpdateMovieTitle($oldTitle: String!, $newTitle: String!) { updateOneMovie(query: { title: $oldTitle } set: { title: $newTitle }) { title year } }", "variables": { "oldTitle": "The Matrix Reloaded", "newTitle": "The Matrix 2" } }'