Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playground cannot be used offline #82

Open
pnboot opened this issue Jun 28, 2020 · 0 comments
Open

playground cannot be used offline #82

pnboot opened this issue Jun 28, 2020 · 0 comments

Comments

@pnboot
Copy link

pnboot commented Jun 28, 2020

Hello !
thanks for this library.

Limited to CDN files cannot be accessed offline

https://github.com/leangen/graphql-spqr-spring-boot-starter/blob/master/graphql-spqr-spring-boot-autoconfigure/src/main/resources/playground.html

<head>
    <meta charset=utf-8/>
    <meta name="viewport" content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui">
    <title>${pageTitle}</title>
    <link rel="stylesheet" href="/cdn.jsdelivr.net/npm/graphql-playground-react/build/static/css/index.css" />
    <link rel="shortcut icon" href="//cdn.jsdelivr.net/npm/graphql-playground-react/build/favicon.png" />
    <script src="//cdn.jsdelivr.net/npm/graphql-playground-react/build/static/js/middleware.js"></script>
</head>
  1. download static files
curl -s https://raw.githubusercontent.com/leangen/graphql-spqr-spring-boot-starter/master/graphql-spqr-spring-boot-autoconfigure/src/main/resources/playground.html | \
 grep -oP "cdn.*?[\"|\']" | \
 sed "s,['|\"],," | \
 while read url ; 
    do 
      mkdir -p $url ; 
      rm -rf $url ; 
      wget -O $url  $url ;
   done
  1. replace url path
public String gui() throws IOException {
        String playgroundHtml = StreamUtils.copyToString(new ClassPathResource("playground.html")
                .getInputStream(), StandardCharsets.UTF_8)
                .replace("${pageTitle}", config.getGui().getPageTitle())
                .replace("${graphQLEndpoint}", config.getGui().getTargetEndpoint())
                .replace("${webSocketEndpoint}", config.getGui().getTargetWsEndpoint());

        return config.getGui().getOffline() ? playgroundHtml.replace("//", "/")
                : playgroundHtml;
    }
pnboot added a commit to pnboot/graphql-spqr-spring-boot-starter that referenced this issue Jun 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant