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

use playground default settings when possible #1516

Merged
merged 9 commits into from
Sep 1, 2018
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ All of the packages in the `apollo-server` repo are released with the same versi
- express, koa: remove next after playground [#1436](https://github.com/apollographql/apollo-server/pull/1436)
- Hapi: Pass the response toolkit to the context function. [#1407](https://github.com/apollographql/apollo-server/pull/1407)
- update apollo-engine-reporting-protobuf to non-beta [#1429](https://github.com/apollographql/apollo-server/pull/1429)
- playground would use its own settings as default [#1516](https://github.com/apollographql/apollo-server/pull/1516)
- Lambda: Look in event.path first when picking endpoint for GraphQL Playground [#1527](https://github.com/apollographql/apollo-server/pull/1527)
- Fix to allow enabling GraphQL Playground in production with custom config [#1495](https://github.com/apollographql/apollo-server/pull/1495)

Expand Down
14 changes: 10 additions & 4 deletions packages/apollo-server-core/src/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,19 @@ export function createPlaygroundOptions(
const playgroundOverrides =
typeof playground === 'boolean' ? {} : playground || {};

const settingsOverrides = playgroundOverrides.hasOwnProperty('settings')
? {
settings: {
...defaultPlaygroundOptions.settings,
...playgroundOverrides.settings,
},
}
: { settings: undefined };

const playgroundOptions: PlaygroundRenderPageOptions = {
...defaultPlaygroundOptions,
...playgroundOverrides,
settings: {
...defaultPlaygroundOptions.settings,
...playgroundOverrides.settings,
},
...settingsOverrides,
};

return playgroundOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ describe('apollo-server-express', () => {
reject(error);
} else {
expect(body).toMatch('GraphQLPlayground');
expect(body).not.toMatch('settings');
expect(response.statusCode).toEqual(200);
resolve();
}
Expand Down