Atlas GraphQL API
Atlas Device SDK 已弃用。 有关详细信息,请参阅弃用页面。
GraphQL已弃用。 了解详情。
Atlas GraphQL API 已弃用。 有关更多详细信息,包括有关迁移到其他提供商的信息,请参阅 从 迁移静态托管和GraphQLAtlas App Services 。
运行查询和变更
使用 Atlas GraphQL API 从客户端运行查询和更改。
要了解有关可用操作的更多信息,请参阅以下 App Services 文档:
您还可以找到整个模式,并在Atlas App Services用户界面的 GraphQL 部分中通过测试操作进行探索。
运行查询
您可以使用定义模式时生成的查询解析程序来查询 Atlas GraphQL API 模式。 要了解有关生成的查询及其接受的输入的更多信息,请参阅 Atlas App Services文档中的 查询解析 程序。
final query = """ query { plants(limit: 5) { _id name color } } """; final queryOptions = QueryOptions( document: gql(query), ); final queryRes = await client.query(queryOptions);
运行修改
您可以使用定义模式时生成的变更解析程序,针对 Atlas GraphQL API 模式运行变更。 要了解有关生成的更改及其接受的输入的更多信息,请参阅 Atlas App Services文档中的更改 解析 程序。
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);