docs(merging_objects): add missing structs in example
This commit is contained in:
parent
526452b494
commit
e2ca31e1e8
|
@ -25,6 +25,9 @@ Instead, the `#[derive(MergedObject)]` macro allows you to split an object's res
|
|||
**Note:** This works for queries and mutations. For subscriptions, see "Merging Subscriptions" below.
|
||||
|
||||
```rust
|
||||
#[derive(Default)]
|
||||
struct UserQuery;
|
||||
|
||||
#[Object]
|
||||
impl UserQuery {
|
||||
async fn users(&self) -> Vec<User> {
|
||||
|
@ -32,6 +35,9 @@ impl UserQuery {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct MovieQuery;
|
||||
|
||||
#[Object]
|
||||
impl MovieQuery {
|
||||
async fn movies(&self) -> Vec<Movie> {
|
||||
|
|
|
@ -25,6 +25,9 @@ impl MyObject {
|
|||
**提示:** 每个`#[Object]`需要一个唯一的名称,即使在一个`MergedObject`内,所以确保每个对象有单独的名称。
|
||||
|
||||
```rust
|
||||
#[derive(Default)]
|
||||
struct UserQuery;
|
||||
|
||||
#[Object]
|
||||
impl UserQuery {
|
||||
async fn users(&self) -> Vec<User> {
|
||||
|
@ -32,6 +35,9 @@ impl UserQuery {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct MovieQuery;
|
||||
|
||||
#[Object]
|
||||
impl MovieQuery {
|
||||
async fn movies(&self) -> Vec<Movie> {
|
||||
|
|
Loading…
Reference in New Issue