mirror of
https://github.com/actix/examples
synced 2025-06-26 17:17:42 +02:00
refactor: use graduated Html responder
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
use actix_cors::Cors;
|
||||
use actix_web::{get, middleware::Logger, route, web, App, HttpServer, Responder};
|
||||
use actix_web_lab::respond::Html;
|
||||
use async_graphql::{
|
||||
http::{playground_source, GraphQLPlaygroundConfig},
|
||||
EmptyMutation, EmptySubscription, Schema,
|
||||
@ -19,7 +18,7 @@ async fn graphql(schema: web::Data<StarWarsSchema>, req: GraphQLRequest) -> Grap
|
||||
/// GraphiQL playground UI
|
||||
#[get("/graphiql")]
|
||||
async fn graphql_playground() -> impl Responder {
|
||||
Html(playground_source(
|
||||
web::Html::new(playground_source(
|
||||
GraphQLPlaygroundConfig::new("/graphql").subscription_endpoint("/graphql"),
|
||||
))
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
use actix_web::{get, route, web, Error, HttpResponse, Responder};
|
||||
use actix_web_lab::respond::Html;
|
||||
use juniper::http::{graphiql::graphiql_source, GraphQLRequest};
|
||||
|
||||
use crate::{
|
||||
@ -26,7 +25,7 @@ pub async fn graphql(
|
||||
/// GraphiQL UI
|
||||
#[get("/graphiql")]
|
||||
async fn graphql_playground() -> impl Responder {
|
||||
Html(graphiql_source("/graphql", None))
|
||||
web::Html::new(graphiql_source("/graphql", None))
|
||||
}
|
||||
|
||||
pub fn register(config: &mut web::ServiceConfig) {
|
||||
|
@ -10,7 +10,6 @@ use actix_web::{
|
||||
web::{self, Data},
|
||||
App, HttpResponse, HttpServer, Responder,
|
||||
};
|
||||
use actix_web_lab::respond::Html;
|
||||
use juniper::http::{graphiql::graphiql_source, GraphQLRequest};
|
||||
|
||||
mod schema;
|
||||
@ -20,7 +19,7 @@ use crate::schema::{create_schema, Schema};
|
||||
/// GraphiQL playground UI
|
||||
#[get("/graphiql")]
|
||||
async fn graphql_playground() -> impl Responder {
|
||||
Html(graphiql_source("/graphql", None))
|
||||
web::Html::new(graphiql_source("/graphql", None))
|
||||
}
|
||||
|
||||
/// GraphQL endpoint
|
||||
|
Reference in New Issue
Block a user