graphiql 0.1.0

creates a simple html to open up a graphiql instance
Documentation
const TEMPLATE: &'static str = r#"
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="robots" content="noindex">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="referrer" content="origin">

    <title>GraphiQL IDE</title>

    <style>
      body {
        height: 100%;
        margin: 0;
        width: 100%;
        overflow: hidden;
      }

      #graphiql {
        height: 100vh;
      }
    </style>
    <script
      crossorigin

      src="https://cdn.jsdelivr.net/npm/react@17.0.2/umd/react.development.min.js"
    ></script>
    <script
      crossorigin

      src="https://cdn.jsdelivr.net/npm/react-dom@17.0.2/umd/react-dom.development.js"
    ></script>
    <link rel="icon" href="https://graphql.org/favicon.ico">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/graphiql@3.8.3/graphiql.min.css" />
  </head>

  <body>
    <div id="graphiql">Loading...</div>
    <script
      src="https://cdn.jsdelivr.net/npm/graphiql@3.8.3/graphiql.min.js"
      type="application/javascript"
    ></script>
    <script>
      customFetch = (url, opts = {}) => {
        return fetch(url, {...opts, credentials: 'same-origin'})
      }


      ReactDOM.render(
        React.createElement(GraphiQL, {
          fetcher: GraphiQL.createFetcher({
            url: 'GRAPHQL_URL',
            fetch: customFetch,
            subscriptionUrl: GRAPHQL_SUBSCRIPTION_URL,
          }),
          defaultEditorToolsVisibility: true,
        }),
        document.getElementById("graphiql")
      );
    </script>
  </body>
</html>"#;

pub struct GraphiqlOptions {
    pub endpoint: String,
    pub subscription_endpoint: Option<String>,
}

pub fn graphiql_body(options: GraphiqlOptions) -> String {
    TEMPLATE.replace("GRAPHQL_URL", &options.endpoint).replace(
        "GRAPHQL_SUBSCRIPTION_URL",
        &options
            .subscription_endpoint
            .map(|endpoint| format!("'{endpoint}'"))
            .unwrap_or("null".to_owned()),
    )
}