Support subscriptions for GraphiQL and Playground. (#859)
* Support subscriptions for GraphiQL and Playground. Add support for subscriptions for GraphiQL and Playground in `juniper_rocket_async`. * Update example. Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
This commit is contained in:
parent
3b6c3f9c0f
commit
52483718ed
2 changed files with 11 additions and 5 deletions
|
@ -8,7 +8,7 @@ type Schema = RootNode<'static, Query, EmptyMutation<Database>, EmptySubscriptio
|
|||
|
||||
#[rocket::get("/")]
|
||||
fn graphiql() -> content::Html<String> {
|
||||
juniper_rocket_async::graphiql_source("/graphql")
|
||||
juniper_rocket_async::graphiql_source("/graphql", None)
|
||||
}
|
||||
|
||||
#[rocket::get("/graphql?<request>")]
|
||||
|
|
|
@ -69,18 +69,24 @@ where
|
|||
pub struct GraphQLResponse(pub Status, pub String);
|
||||
|
||||
/// Generate an HTML page containing GraphiQL
|
||||
pub fn graphiql_source(graphql_endpoint_url: &str) -> content::Html<String> {
|
||||
pub fn graphiql_source(
|
||||
graphql_endpoint_url: &str,
|
||||
subscriptions_endpoint_url: Option<&str>,
|
||||
) -> content::Html<String> {
|
||||
content::Html(juniper::http::graphiql::graphiql_source(
|
||||
graphql_endpoint_url,
|
||||
None,
|
||||
subscriptions_endpoint_url,
|
||||
))
|
||||
}
|
||||
|
||||
/// Generate an HTML page containing GraphQL Playground
|
||||
pub fn playground_source(graphql_endpoint_url: &str) -> content::Html<String> {
|
||||
pub fn playground_source(
|
||||
graphql_endpoint_url: &str,
|
||||
subscriptions_endpoint_url: Option<&str>,
|
||||
) -> content::Html<String> {
|
||||
content::Html(juniper::http::playground::playground_source(
|
||||
graphql_endpoint_url,
|
||||
None,
|
||||
subscriptions_endpoint_url,
|
||||
))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue