Skip to content

Commit 5248371

Browse files
alvraLegNeato
andauthored
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 <[email protected]>
1 parent 3b6c3f9 commit 5248371

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

juniper_rocket_async/examples/rocket_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type Schema = RootNode<'static, Query, EmptyMutation<Database>, EmptySubscriptio
88

99
#[rocket::get("/")]
1010
fn graphiql() -> content::Html<String> {
11-
juniper_rocket_async::graphiql_source("/graphql")
11+
juniper_rocket_async::graphiql_source("/graphql", None)
1212
}
1313

1414
#[rocket::get("/graphql?<request>")]

juniper_rocket_async/src/lib.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,24 @@ where
6969
pub struct GraphQLResponse(pub Status, pub String);
7070

7171
/// Generate an HTML page containing GraphiQL
72-
pub fn graphiql_source(graphql_endpoint_url: &str) -> content::Html<String> {
72+
pub fn graphiql_source(
73+
graphql_endpoint_url: &str,
74+
subscriptions_endpoint_url: Option<&str>,
75+
) -> content::Html<String> {
7376
content::Html(juniper::http::graphiql::graphiql_source(
7477
graphql_endpoint_url,
75-
None,
78+
subscriptions_endpoint_url,
7679
))
7780
}
7881

7982
/// Generate an HTML page containing GraphQL Playground
80-
pub fn playground_source(graphql_endpoint_url: &str) -> content::Html<String> {
83+
pub fn playground_source(
84+
graphql_endpoint_url: &str,
85+
subscriptions_endpoint_url: Option<&str>,
86+
) -> content::Html<String> {
8187
content::Html(juniper::http::playground::playground_source(
8288
graphql_endpoint_url,
83-
None,
89+
subscriptions_endpoint_url,
8490
))
8591
}
8692

0 commit comments

Comments
 (0)