Docs Menu
Docs Home
/ /
Atlas Device SDKs
/ /

Atlas GraphQL API

On this page

  • Run Queries and Mutations
  • Run a Query
  • Run a Mutation

The Atlas GraphQL API is deprecated. For more details, including information about migrating to another provider, refer to Migrate Static Hosting and GraphQL From App Services.

Run queries and mutations with the Atlas GraphQL API from the client.

To learn more about available operations, refer to the following App Services documentation:

You can also find your entire schema and explore it with test operations in the GraphQL section of the App Services UI.

You can query the Atlas GraphQL API schema with query resolvers generated when you define your schema. To learn more about the generated queries and the inputs they accept, refer to Query Resolvers in the App Services documentation.

final query = """
query {
plants(limit: 5) {
_id
name
color
}
}
""";
final queryOptions = QueryOptions(
document: gql(query),
);
final queryRes = await client.query(queryOptions);

You can run mutation against the Atlas GraphQL API schema with mutation resolvers generated when you define your schema. To learn more about the generated mutations and the inputs they accept, refer to Mutation Resolvers in the App Services documentation.

final mutation = """
mutation AddPlant( \$_id: ObjectId!, \$name: String!, \$color: String) {
insertOnePlant(data: {
_id: \$_id
name: \$name
color: \$color
}) {
_id
name
color
}
}
""";
final mutationOptions = MutationOptions(
document: gql(mutation),
variables: {
'_id': ObjectId().toString(),
'name': 'lily',
'color': 'white'
});
final mutationRes = await client.mutate(mutationOptions);

Back

Connect to App Services

Next

Call an Atlas Function