async-graphql/docs/zh-CN/src/extensions_available.md
Edward Rudd 3b7ed74d11 correct doc examples so they compile
- examples to fix still
  - error_extensions.md ResultExt example does not compile!
     - trait ErrorExtensions is not implemented for ParseIntError
  - dataloader
     - requires sqlx to work. So we either "stub" it OR we rewrite them simpler to use a  simple "faux" db library
2022-06-02 17:32:12 -04:00

2.6 KiB
Raw Blame History

可用的扩展列表

async-graphql 中有很多可用的扩展用于增强你的 GraphQL 服务器。

Analyzer

Available in the repository

Analyzer 扩展将在每个响应的扩展中输出 complexitydepth 字段。

Apollo Persisted Queries

Available in the repository

要提高大型查询的性能你可以启用此扩展每个查询语句都将与一个唯一ID相关联因此客户端可以直接发送此ID查询以减少请求的大小。

这个扩展不会强迫你使用一些缓存策略,你可以选择你想要的缓存策略,你只需要实现 CacheStorage trait

# extern crate async_graphql;
# use async_graphql::*;
#[async_trait::async_trait]
pub trait CacheStorage: Send + Sync + Clone + 'static {
    /// Load the query by `key`.
    async fn get(&self, key: String) -> Option<String>;
    /// Save the query by `key`.
    async fn set(&self, key: String, query: String);
}

References: Apollo doc - Persisted Queries

Apollo Tracing

Available in the repository

Apollo Tracing 扩展用于在响应中包含此查询分析数据。 此扩展程序遵循旧的且现已弃用的 Apollo Tracing Spec 。 如果你想支持更新的 Apollo Reporting Protocol推荐使用 async-graphql Apollo studio extension

Apollo Studio

Available at async-graphql/async_graphql_apollo_studio_extension

async-graphql 提供了实现官方 Apollo Specification 的扩展,位于 async-graphql-extension- apollo-tracingcrates.io

Logger

Available in the repository

Logger 是一个简单的扩展,允许你向 async-graphql 添加一些日志记录功能。这也是学习如何创建自己的扩展的一个很好的例子。

OpenTelemetry

Available in the repository

OpenTelemetry 扩展提供 opentelemetry crate 的集成,以允许你的应用程序从 async-graphql 捕获分布式跟踪和指标。

Tracing

Available in the repository

Tracing 扩展提供 tracing crate 的集成,允许您向 async-graphql 添加一些跟踪功能,有点像Logger 扩展。