-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a wider diversity of `gui` options Although I know we want to remain less tied to the GraphQL Playground GUI options, we definitely want to support a wider variety of options to be passed in. This adds support for specifying partial options either statically or dynamically for the gui, which can be extended to allow for a wider array of guis than only GraphQL playground. * Add boolean option and configuration for tabs * move gui setting into ApolloServer Constructor * document playground configuration in the constructor * update playground types and fixed micro + koa integrations * change gui to playground * docs: change gui to playground * fix logic for playground creation
- Loading branch information
Showing
15 changed files
with
232 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { | ||
RenderPageOptions as PlaygroundRenderPageOptions, | ||
Theme, | ||
} from '@apollographql/graphql-playground-html/dist/render-playground-page'; | ||
export { | ||
RenderPageOptions as PlaygroundRenderPageOptions, | ||
} from '@apollographql/graphql-playground-html/dist/render-playground-page'; | ||
|
||
// This specifies the version of GraphQL Playground that will be served | ||
// from graphql-playground-html, and is passed to renderPlaygroundPage | ||
// by the integration subclasses | ||
const playgroundVersion = '1.7.2'; | ||
|
||
export type PlaygroundConfig = Partial<PlaygroundRenderPageOptions> | boolean; | ||
|
||
export const defaultPlaygroundOptions = { | ||
version: playgroundVersion, | ||
settings: { | ||
'general.betaUpdates': false, | ||
'editor.theme': 'dark' as Theme, | ||
'editor.reuseHeaders': true, | ||
'tracing.hideTracingResponse': true, | ||
'editor.fontSize': 14, | ||
'editor.fontFamily': `'Source Code Pro', 'Consolas', 'Inconsolata', 'Droid Sans Mono', 'Monaco', monospace`, | ||
'request.credentials': 'omit', | ||
}, | ||
}; | ||
|
||
export function createPlaygroundOptions( | ||
playground: PlaygroundConfig = {}, | ||
): PlaygroundRenderPageOptions | undefined { | ||
const isDev = process.env.NODE_ENV !== 'production'; | ||
const enabled: boolean = typeof playground === 'boolean' ? playground : isDev; | ||
|
||
if (!enabled) { | ||
return undefined; | ||
} | ||
|
||
const playgroundOverrides = | ||
typeof playground === 'boolean' ? {} : playground || {}; | ||
|
||
const playgroundOptions: PlaygroundRenderPageOptions = { | ||
...defaultPlaygroundOptions, | ||
...playgroundOverrides, | ||
settings: { | ||
...defaultPlaygroundOptions.settings, | ||
...playgroundOverrides.settings, | ||
}, | ||
}; | ||
|
||
return playgroundOptions; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.