Navigation

Run GraphQL Operations from a CLI

You can access your app's exposed 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:

gq https://realm.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'
gq https://realm.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'
Give Feedback