Skip to content

Commit

Permalink
renderPlaygroundPage - cdnUrl config option (#845)
Browse files Browse the repository at this point in the history
* renderPlaygroundPage - cdnUrl config option

Allow the cdn url to be passed in to renderPlaygroundPage as an option. This is to support graphql-playground being used offline by tools such as Apollo Server. See apollographql/apollo-server#1421

* don't insert @ in cdn url if no version given

If version is not passed then don't append @ to the cdn url.

This is to aid serving from localhost from a folder with no given version number. See #845
  • Loading branch information
penx authored and huv1k committed Oct 15, 2018
1 parent f57bb5c commit 706dadd
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/graphql-playground-html/src/render-playground-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface IntrospectionResult {

export interface RenderPageOptions extends MiddlewareOptions {
version: string
cdnUrl?: string
env?: any
}

Expand All @@ -67,15 +68,15 @@ export interface Tab {

const loading = getLoadingMarkup()

const getCdnMarkup = options => `
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/graphql-playground-react@${
options.version
const getCdnMarkup = ({version, cdnUrl = '//cdn.jsdelivr.net/npm'}) => `
<link rel="stylesheet" href="${cdnUrl}/graphql-playground-react${
version ? `@${version}` : ''
}/build/static/css/index.css" />
<link rel="shortcut icon" href="//cdn.jsdelivr.net/npm/graphql-playground-react@${
options.version
<link rel="shortcut icon" href="${cdnUrl}/graphql-playground-react${
version ? `@${version}` : ''
}/build/favicon.png" />
<script src="//cdn.jsdelivr.net/npm/graphql-playground-react@${
options.version
<script src="${cdnUrl}/graphql-playground-react${
version ? `@${version}` : ''
}/build/static/js/middleware.js"></script>
`

Expand Down

0 comments on commit 706dadd

Please sign in to comment.