Skip to content

Commit

Permalink
Update model.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed May 2, 2022
1 parent 22bc2e5 commit d359d0e
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions models/starwars/src/model.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(clippy::needless_lifetimes)]

use async_graphql::{
connection::{query, Connection, DefaultConnectionName, DefaultEdgeName, Edge, EmptyFields},
connection::{query, Connection, Edge},
Context, Enum, Error, Interface, Object, OutputType, Result,
};

Expand Down Expand Up @@ -145,16 +145,7 @@ impl QueryRoot {
before: Option<String>,
first: Option<i32>,
last: Option<i32>,
) -> Result<
Connection<
DefaultConnectionName,
DefaultEdgeName,
usize,
Human<'a>,
EmptyFields,
EmptyFields,
>,
> {
) -> Result<Connection<usize, Human<'a>>> {
let humans = ctx.data_unchecked::<StarWars>().humans().to_vec();
query_characters(after, before, first, last, &humans, Human).await
}
Expand All @@ -174,16 +165,7 @@ impl QueryRoot {
before: Option<String>,
first: Option<i32>,
last: Option<i32>,
) -> Result<
Connection<
DefaultConnectionName,
DefaultEdgeName,
usize,
Droid<'a>,
EmptyFields,
EmptyFields,
>,
> {
) -> Result<Connection<usize, Droid<'a>>> {
let droids = ctx.data_unchecked::<StarWars>().droids().to_vec();
query_characters(after, before, first, last, &droids, Droid).await
}
Expand All @@ -208,7 +190,7 @@ async fn query_characters<'a, F, T>(
last: Option<i32>,
characters: &[&'a StarWarsChar],
map_to: F,
) -> Result<Connection<DefaultConnectionName, DefaultEdgeName, usize, T, EmptyFields, EmptyFields>>
) -> Result<Connection<usize, T>>
where
F: Fn(&'a StarWarsChar) -> T,
T: OutputType,
Expand Down

0 comments on commit d359d0e

Please sign in to comment.