Skip to content

Commit

Permalink
Merge pull request #64 from bvanneerven/master
Browse files Browse the repository at this point in the history
Update examples to include GraphiQL v2 changes
  • Loading branch information
sunli829 committed Dec 23, 2022
2 parents f86120e + 861e6ff commit 1492794
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 69 deletions.
6 changes: 1 addition & 5 deletions actix-web/error-extensions/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,7 @@ async fn index(
async fn gql_playgound() -> HttpResponse {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.finish(),
)
.body(GraphiQLSource::build().endpoint("/").finish())
}

#[actix_web::main]
Expand Down
6 changes: 1 addition & 5 deletions actix-web/starwars/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ async fn index(schema: web::Data<StarWarsSchema>, req: GraphQLRequest) -> GraphQ
async fn index_graphiql() -> Result<HttpResponse> {
Ok(HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.finish(),
))
.body(GraphiQLSource::build().endpoint("/").finish()))
}

#[actix_web::main]
Expand Down
4 changes: 2 additions & 2 deletions actix-web/subscription/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ async fn index_graphiql() -> Result<HttpResponse> {
.content_type("text/html; charset=utf-8")
.body(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.subscription_endpoint("ws://localhost:8000")
.endpoint("/")
.subscription_endpoint("/")
.finish(),
))
}
Expand Down
4 changes: 2 additions & 2 deletions actix-web/token-from-header/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ async fn graphiql() -> HttpResponse {
.content_type("text/html; charset=utf-8")
.body(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.subscription_endpoint("ws://localhost:8000/ws")
.endpoint("/")
.subscription_endpoint("/ws")
.finish(),
)
}
Expand Down
6 changes: 1 addition & 5 deletions actix-web/upload/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ async fn index(schema: web::Data<FilesSchema>, req: GraphQLRequest) -> GraphQLRe
async fn gql_playgound() -> HttpResponse {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.finish(),
)
.body(GraphiQLSource::build().endpoint("/").finish())
}

#[actix_web::main]
Expand Down
6 changes: 1 addition & 5 deletions axum/starwars/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ async fn graphql_handler(
}

async fn graphiql() -> impl IntoResponse {
response::Html(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.finish(),
)
response::Html(GraphiQLSource::build().endpoint("/").finish())
}

#[tokio::main]
Expand Down
4 changes: 2 additions & 2 deletions axum/subscription/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ async fn graphql_handler(schema: Extension<BooksSchema>, req: GraphQLRequest) ->
async fn graphiql() -> impl IntoResponse {
response::Html(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.subscription_endpoint("ws://localhost:8000/ws")
.endpoint("/")
.subscription_endpoint("/ws")
.finish(),
)
}
Expand Down
6 changes: 1 addition & 5 deletions axum/upload/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ async fn graphql_handler(schema: Extension<FilesSchema>, req: GraphQLRequest) ->
}

async fn graphiql() -> impl IntoResponse {
Html(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.finish(),
)
Html(GraphiQLSource::build().endpoint("/").finish())
}

#[tokio::main]
Expand Down
6 changes: 1 addition & 5 deletions poem/dynamic-starwars/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ use poem::{get, handler, listener::TcpListener, web::Html, IntoResponse, Route,

#[handler]
async fn graphiql() -> impl IntoResponse {
Html(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.finish(),
)
Html(GraphiQLSource::build().endpoint("/").finish())
}

#[tokio::main]
Expand Down
6 changes: 1 addition & 5 deletions poem/starwars/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ use starwars::{QueryRoot, StarWars};

#[handler]
async fn graphiql() -> impl IntoResponse {
Html(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.finish(),
)
Html(GraphiQLSource::build().endpoint("/").finish())
}

#[tokio::main]
Expand Down
4 changes: 2 additions & 2 deletions poem/subscription-redis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ impl SubscriptionRoot {
async fn graphiql() -> impl IntoResponse {
Html(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.subscription_endpoint("ws://localhost:8000/ws")
.endpoint("/")
.subscription_endpoint("/ws")
.finish(),
)
}
Expand Down
4 changes: 2 additions & 2 deletions poem/subscription/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use poem::{get, handler, listener::TcpListener, web::Html, IntoResponse, Route,
async fn graphiql() -> impl IntoResponse {
Html(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.subscription_endpoint("ws://localhost:8000/ws")
.endpoint("/")
.subscription_endpoint("/ws")
.finish(),
)
}
Expand Down
4 changes: 2 additions & 2 deletions poem/token-from-header/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ fn get_token_from_headers(headers: &HeaderMap) -> Option<Token> {
async fn graphiql() -> impl IntoResponse {
Html(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.subscription_endpoint("ws://localhost:8000/ws")
.endpoint("/")
.subscription_endpoint("/ws")
.finish(),
)
}
Expand Down
6 changes: 1 addition & 5 deletions poem/upload/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ async fn index(schema: Data<&FilesSchema>, req: GraphQLRequest) -> GraphQLRespon

#[handler]
async fn graphiql() -> impl IntoResponse {
Html(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.finish(),
)
Html(GraphiQLSource::build().endpoint("/").finish())
}

#[tokio::main]
Expand Down
4 changes: 1 addition & 3 deletions tide/dataloader-postgres/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ async fn run() -> Result<()> {
app.at("/").get(|_| async move {
let mut resp = Response::new(StatusCode::Ok);
resp.set_body(Body::from_string(
GraphiQLSource::build()
.endpoint("http://localhost:8000/graphql")
.finish(),
GraphiQLSource::build().endpoint("/graphql").finish(),
));
resp.set_content_type(mime::HTML);
Ok(resp)
Expand Down
4 changes: 1 addition & 3 deletions tide/dataloader/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ async fn run() -> Result<()> {
app.at("/").get(|_| async move {
let mut resp = Response::new(StatusCode::Ok);
resp.set_body(Body::from_string(
GraphiQLSource::build()
.endpoint("http://localhost:8000/graphql")
.finish(),
GraphiQLSource::build().endpoint("/graphql").finish(),
));
resp.set_content_type(mime::HTML);
Ok(resp)
Expand Down
4 changes: 2 additions & 2 deletions tide/subscription/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ async fn run() -> Result<()> {
let mut resp = Response::new(StatusCode::Ok);
resp.set_body(Body::from_string(
GraphiQLSource::build()
.endpoint("http://localhost:8000/graphql")
.subscription_endpoint("ws://localhost:8000/graphql")
.endpoint("/graphql")
.subscription_endpoint("/graphql")
.finish(),
));
resp.set_content_type(mime::HTML);
Expand Down
6 changes: 1 addition & 5 deletions warp/starwars/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ async fn main() {
let graphiql = warp::path::end().and(warp::get()).map(|| {
HttpResponse::builder()
.header("content-type", "text/html")
.body(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.finish(),
)
.body(GraphiQLSource::build().endpoint("/").finish())
});

let routes = graphiql
Expand Down
4 changes: 2 additions & 2 deletions warp/subscription/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ async fn main() {
.header("content-type", "text/html")
.body(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.subscription_endpoint("ws://localhost:8000")
.endpoint("/")
.subscription_endpoint("/")
.finish(),
)
});
Expand Down
4 changes: 2 additions & 2 deletions warp/token-from-header/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ async fn main() {
.header("content-type", "text/html")
.body(
GraphiQLSource::build()
.endpoint("http://localhost:8000")
.subscription_endpoint("ws://localhost:8000/ws")
.endpoint("/")
.subscription_endpoint("/ws")
.finish(),
)
});
Expand Down

0 comments on commit 1492794

Please sign in to comment.