Skip to content

Commit 841bd26

Browse files
penxhuv1k
authored andcommitted
renderPlaygroundPage - cdnUrl config option (#845)
* 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
1 parent 4d1a0b8 commit 841bd26

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/graphql-playground-html/src/render-playground-page.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface IntrospectionResult {
5454

5555
export interface RenderPageOptions extends MiddlewareOptions {
5656
version: string
57+
cdnUrl?: string
5758
env?: any
5859
}
5960

@@ -67,15 +68,15 @@ export interface Tab {
6768

6869
const loading = getLoadingMarkup()
6970

70-
const getCdnMarkup = options => `
71-
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/graphql-playground-react@${
72-
options.version
71+
const getCdnMarkup = ({version, cdnUrl = '//cdn.jsdelivr.net/npm'}) => `
72+
<link rel="stylesheet" href="${cdnUrl}/graphql-playground-react${
73+
version ? `@${version}` : ''
7374
}/build/static/css/index.css" />
74-
<link rel="shortcut icon" href="//cdn.jsdelivr.net/npm/graphql-playground-react@${
75-
options.version
75+
<link rel="shortcut icon" href="${cdnUrl}/graphql-playground-react${
76+
version ? `@${version}` : ''
7677
}/build/favicon.png" />
77-
<script src="//cdn.jsdelivr.net/npm/graphql-playground-react@${
78-
options.version
78+
<script src="${cdnUrl}/graphql-playground-react${
79+
version ? `@${version}` : ''
7980
}/build/static/js/middleware.js"></script>
8081
`
8182

0 commit comments

Comments
 (0)