diff --git a/src/http/playground_source.rs b/src/http/playground_source.rs
index 59aa2b31..7223c5ff 100644
--- a/src/http/playground_source.rs
+++ b/src/http/playground_source.rs
@@ -14,6 +14,7 @@ use crate::Value;
/// playground_source(GraphQLPlaygroundConfig::new("http://localhost:8000"));
/// ```
pub fn playground_source(config: GraphQLPlaygroundConfig) -> String {
+ let title = config.title.unwrap_or("GraphQL Playground");
r##"
@@ -22,7 +23,7 @@ pub fn playground_source(config: GraphQLPlaygroundConfig) -> String {
- GraphQL Playground
+ %GRAPHQL_PLAYGROUND_TITLE%
@@ -557,6 +558,7 @@ pub fn playground_source(config: GraphQLPlaygroundConfig) -> String {
Ok(str) => str,
Err(_) => "{}".to_string()
})
+ .replace("%GRAPHQL_PLAYGROUND_TITLE%", title)
}
/// Config for GraphQL Playground
@@ -567,6 +569,7 @@ pub struct GraphQLPlaygroundConfig<'a> {
subscription_endpoint: Option<&'a str>,
headers: Option>,
settings: Option>,
+ title: Option<&'a str>,
}
impl<'a> GraphQLPlaygroundConfig<'a> {
@@ -577,6 +580,7 @@ impl<'a> GraphQLPlaygroundConfig<'a> {
subscription_endpoint: None,
headers: Default::default(),
settings: Default::default(),
+ title: Default::default(),
}
}
@@ -600,6 +604,13 @@ impl<'a> GraphQLPlaygroundConfig<'a> {
self
}
+ /// Set the html document title.
+ #[must_use]
+ pub fn title(mut self, title: &'a str) -> Self {
+ self.title = Some(title);
+ self
+ }
+
/// Set Playground setting for per query.
///
/// ```