diff --git a/docs/en/src/define_complex_object.md b/docs/en/src/define_complex_object.md index ff6158e6..505b3eca 100644 --- a/docs/en/src/define_complex_object.md +++ b/docs/en/src/define_complex_object.md @@ -6,8 +6,9 @@ Different from `SimpleObject`, `Object` must have Resolve defined for each field Resolve is used to get the value of the field. You can query a database and return the result. **The return type of the function is the type of the field.** You can also return a `async_graphql::FieldResult` so to return an error if it occrs and error message will be send to query result. - -When querying a database, you may need a global data base connection pool, you can use `Schema::data` to attach a global data when creating Schema, the following `value_from_db` function showed how to retrive a database connection from `Context`. +When querying a database, you may need a global data base connection pool. +When creating `Schema`, you can use `SchemaBuilder::data` to setup `Schema` data, and `Context::data` to setup `Context`data. +The following `value_from_db` function showed how to retrive a database connection from `Context`. ```rust use async_graphql::*; diff --git a/docs/en/src/error_handling.md b/docs/en/src/error_handling.md index 8cbed094..5b28b5fb 100644 --- a/docs/en/src/error_handling.md +++ b/docs/en/src/error_handling.md @@ -6,7 +6,6 @@ Resolve can return a `FieldResult`, following is the definition: type FieldResult = std::result::Result; ``` - Any `Error` can be converted to `FieldError` and you can extend error message. Following example shows how to parse an input string to integer. When parsing failed, it would return error and attach error message. diff --git a/docs/zh-CN/src/define_complex_object.md b/docs/zh-CN/src/define_complex_object.md index d41d9297..b5d409df 100644 --- a/docs/zh-CN/src/define_complex_object.md +++ b/docs/zh-CN/src/define_complex_object.md @@ -6,7 +6,7 @@ Resolve函数用于计算字段的值,你可以执行一个数据库查询,并返回查询结果。**函数的返回值是字段的类型**,你也可以返回一个`async_graphql::FieldResult`类型,这样能够返回一个错误,这个错误信息将输出到查询结果中。 -在查询数据库时,你可能需要一个数据库连接池对象,这个对象是个全局的,你可以在创建Schema的时候,用`Schema::data`函数附加一个全局类型的数据,下面的`value_from_db`字段展示了如何从`Context`中获取一个数据库连接。 +在查询数据库时,你可能需要一个数据库连接池对象,这个对象是个全局的,你可以在创建Schema的时候,用`SchemaBuilder::data`函数设置`Schema`数据, 用`Context::data`函数设置`Context`数据。下面的`value_from_db`字段展示了如何从`Context`中获取一个数据库连接。 ```rust use async_graphql::*; diff --git a/docs/zh-CN/src/error_handling.md b/docs/zh-CN/src/error_handling.md index 38ddaa77..d2e54022 100644 --- a/docs/zh-CN/src/error_handling.md +++ b/docs/zh-CN/src/error_handling.md @@ -6,7 +6,7 @@ Resolve函数可以返回一个FieldResult类型,以下是FieldResult的定义 type FieldResult = std::result::Result; ``` -任何错误都能够被转换为`FieldError`,并且你还能扩展标准的错误输出。 +任何错误都能够被转换为`FieldError`,并且你还能扩展标准的错误信息。 下面是一个例子,解析一个输入的字符串到整数,当解析失败时返回错误,并且附加额外的错误信息。