Merge pull request #1042 from onx2/onx2/dataloader-docs
Update Dataloader docs
This commit is contained in:
commit
3ae4c7ca7a
|
@ -7,7 +7,13 @@ Have you noticed some GraphQL queries end can make hundreds of database queries,
|
|||
Imagine if you have a simple query like this:
|
||||
|
||||
```graphql
|
||||
query { todos { users { name } } }
|
||||
query {
|
||||
todos {
|
||||
users {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
and `User` resolver is like this:
|
||||
|
@ -90,11 +96,13 @@ impl Loader<u64> for UserNameLoader {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(SimpleObject)]
|
||||
#[graphql(complex)]
|
||||
struct User {
|
||||
id: u64,
|
||||
}
|
||||
|
||||
#[Object]
|
||||
#[ComplexObject]
|
||||
impl User {
|
||||
async fn name(&self, ctx: &Context<'_>) -> Result<String> {
|
||||
let loader = ctx.data_unchecked::<DataLoader<UserNameLoader>>();
|
||||
|
|
Loading…
Reference in New Issue
Block a user