mirror of
https://github.com/actix/examples
synced 2024-11-27 16:02:57 +01:00
Update async-graphql-demo for async-graphql v2.0.0
(#378)
This commit is contained in:
parent
0e9203d319
commit
66d27bbe61
897
Cargo.lock
generated
897
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -6,8 +6,6 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "3.0.0"
|
||||
|
||||
async-graphql = "=2.0.0-alpha.13"
|
||||
async-graphql-actix-web = "=2.0.0-alpha.13"
|
||||
|
||||
async-graphql = "2.0.0"
|
||||
async-graphql-actix-web = "2.0.0"
|
||||
slab = "0.4.2"
|
||||
|
@ -3,10 +3,10 @@ mod starwars;
|
||||
use actix_web::{guard, web, App, HttpResponse, HttpServer, Result};
|
||||
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
|
||||
use async_graphql::{EmptyMutation, EmptySubscription, Schema};
|
||||
use async_graphql_actix_web::{GQLRequest, GQLResponse};
|
||||
use async_graphql_actix_web::{Request, Response};
|
||||
use starwars::{QueryRoot, StarWars, StarWarsSchema};
|
||||
|
||||
async fn index(schema: web::Data<StarWarsSchema>, req: GQLRequest) -> GQLResponse {
|
||||
async fn index(schema: web::Data<StarWarsSchema>, req: Request) -> Response {
|
||||
schema.execute(req.into_inner()).await.into()
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ impl QueryRoot {
|
||||
async fn hero(
|
||||
&self,
|
||||
ctx: &Context<'_>,
|
||||
#[arg(
|
||||
#[graphql(
|
||||
desc = "If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode."
|
||||
)]
|
||||
episode: Episode,
|
||||
@ -107,7 +107,7 @@ impl QueryRoot {
|
||||
async fn human(
|
||||
&self,
|
||||
ctx: &Context<'_>,
|
||||
#[arg(desc = "id of the human")] id: String,
|
||||
#[graphql(desc = "id of the human")] id: String,
|
||||
) -> Option<Human> {
|
||||
ctx.data_unchecked::<StarWars>().human(&id).map(Human)
|
||||
}
|
||||
@ -134,7 +134,7 @@ impl QueryRoot {
|
||||
async fn droid(
|
||||
&self,
|
||||
ctx: &Context<'_>,
|
||||
#[arg(desc = "id of the droid")] id: String,
|
||||
#[graphql(desc = "id of the droid")] id: String,
|
||||
) -> Option<Droid> {
|
||||
ctx.data_unchecked::<StarWars>().droid(&id).map(Droid)
|
||||
}
|
||||
@ -161,10 +161,10 @@ impl QueryRoot {
|
||||
|
||||
#[derive(Interface)]
|
||||
#[graphql(
|
||||
field(name = "id", type = "&str", context),
|
||||
field(name = "name", type = "&str", context),
|
||||
field(name = "friends", type = "Vec<Character>", context),
|
||||
field(name = "appears_in", type = "&'ctx [Episode]", context)
|
||||
field(name = "id", type = "&str"),
|
||||
field(name = "name", type = "&str"),
|
||||
field(name = "friends", type = "Vec<Character>"),
|
||||
field(name = "appears_in", type = "&'ctx [Episode]")
|
||||
)]
|
||||
pub enum Character {
|
||||
Human(Human),
|
||||
|
Loading…
Reference in New Issue
Block a user