diff --git a/src/http/graphiql_v2_source.rs b/src/http/graphiql_v2_source.rs index 3f4cb8b3..2253517b 100644 --- a/src/http/graphiql_v2_source.rs +++ b/src/http/graphiql_v2_source.rs @@ -18,6 +18,7 @@ pub struct GraphiQLSource<'a> { endpoint: &'a str, subscription_endpoint: Option<&'a str>, headers: Option>, + title: Option<&'a str>, } impl<'a> GraphiQLSource<'a> { @@ -53,6 +54,14 @@ impl<'a> GraphiQLSource<'a> { } } + /// Sets the html document title. + pub fn title(self, title: &'a str) -> GraphiQLSource<'a> { + GraphiQLSource { + title: Some(title), + ..self + } + } + /// Returns a GraphiQL (v2) HTML page. pub fn finish(self) -> String { let graphiql_url = format!("'{}'", self.endpoint); @@ -64,6 +73,7 @@ impl<'a> GraphiQLSource<'a> { Some(headers) => serde_json::to_string(&headers).unwrap(), None => "undefined".into(), }; + let graphiql_title = self.title.unwrap_or("GraphiQL IDE"); r#" @@ -74,7 +84,7 @@ impl<'a> GraphiQLSource<'a> { - GraphiQL IDE + %GRAPHIQL_TITLE%