Merge pull request #135 from nm-infy/nm-infy-patch-3
Correct spellings and grammar in define_complex_object.md
This commit is contained in:
commit
fd2c39292a
@ -4,11 +4,11 @@ Different from `SimpleObject`, `Object` must have Resolve defined for each field
|
|||||||
|
|
||||||
**A resolver function has to be asynchronous. The first argument has to be `&self`, second being optional `Context` and followed by field arguments.**
|
**A resolver function has to be asynchronous. The first argument has to be `&self`, second being optional `Context` and followed by field arguments.**
|
||||||
|
|
||||||
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.
|
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 occurs an error message will be sent to query result.
|
||||||
|
|
||||||
When querying a database, you may need a global data base connection pool.
|
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.
|
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`.
|
The following `value_from_db` function showed how to retrieve a database connection from `Context`.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use async_graphql::*;
|
use async_graphql::*;
|
||||||
@ -32,4 +32,4 @@ impl MyObject {
|
|||||||
Ok(conn.query_something(id)?.name)
|
Ok(conn.query_something(id)?.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user