Skip to content

Commit eca003f

Browse files
authored
Move ApolloServerPluginLandingPageGraphQLPlayground to new package (#6817)
GraphQL Playground was unmaintained when we released Apollo Server 3, and the Apollo Server team has had to put significant work into fixing security issues in GraphQL Playground. While we will still publish a landing page plugin to enable folks upgrading from AS2 to not have to immediately retrain their users on how to use Apollo Sandbox or another interface, we remove it from the main `@apollo/server` package and move it to its own `@apollo/server-plugin-landing-page-graphql-playground` package. This lets us remove the Playground HTML package's dependencies (like `xss`) from Apollo Server's main package. Fixes #6109.
1 parent b40f836 commit eca003f

File tree

19 files changed

+131
-28
lines changed

19 files changed

+131
-28
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@apollo/server-plugin-landing-page-graphql-playground": major
3+
"@apollo/server-integration-testsuite": patch
4+
"@apollo/server": patch
5+
---
6+
7+
Move ApolloServerPluginGraphQLPlayground into its own package.

docs/source/migration.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@ In Apollo Server 3, the `apollo-server-core` package exports built-in plugins, l
300300

301301
In Apollo Server 4, these built-in plugins are part of the main `@apollo/server` package, which also imports the `ApolloServer` class. The `@apollo/server` package exports these built-in plugins with deep exports. This means you use deep imports for each built-in plugin, enabling you to evaluate only the plugin you use in your app and making it easier for bundlers to eliminate unused code.
302302

303-
The `@apollo/server` package exports the following plugins:
303+
There's one exception: the plugin `ApolloServerPluginLandingPageGraphQLPlayground` has been moved to its own package `@apollo/server-plugin-landing-page-graphql-playground` which must be installed separately. (This plugin installs the [unmaintained](https://github.com/graphql/graphql-playground/issues/1143) project GraphQL Playground as a landing page, and is provided for compatibility with Apollo Server 2. We encourage you to switch to the [default landing page](/apollo-server/v3/api/plugin/landing-pages), which installs the similar but the actively maintained Apollo Sandbox instead.)
304+
305+
Apollo Server exports the following plugins:
304306

305307
| Plugin | Import path |
306308
|--------|-------------|
@@ -310,7 +312,7 @@ In Apollo Server 4, these built-in plugins are part of the main `@apollo/server`
310312
| `ApolloServerPluginInlineTrace` | `@apollo/server/plugin/inlineTrace` |
311313
| `ApolloServerPluginInlineTraceDisabled` | `@apollo/server/plugin/disabled` |
312314
| `ApolloServerPluginLandingPageDisabled` | `@apollo/server/plugin/disabled` |
313-
| `ApolloServerPluginLandingPageGraphQLPlayground` | `@apollo/server/plugin/landingPage/graphqlPlayground` |
315+
| `ApolloServerPluginLandingPageGraphQLPlayground` | `@apollo/server-plugin-landing-page-graphql-playground` |
314316
| `ApolloServerPluginLandingPageLocalDefault` | `@apollo/server/plugin/landingPage/default` |
315317
| `ApolloServerPluginLandingPageProductionDefault` | `@apollo/server/plugin/landingPage/default` |
316318
| `ApolloServerPluginSchemaReporting` | `@apollo/server/plugin/schemaReporting` |

package-lock.json

Lines changed: 26 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/integration-testsuite/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"dependencies": {
3030
"@apollo/cache-control-types": "^1.0.2",
3131
"@apollo/client": "^3.6.9",
32+
"@apollo/server-plugin-landing-page-graphql-playground": "3.0.0",
3233
"@apollo/utils.keyvaluecache": "^1.0.1",
3334
"@apollo/utils.createhash": "^1.1.0",
3435
"@apollo/usage-reporting-protobuf": "^4.0.0-alpha.1",

packages/integration-testsuite/src/apolloServerTests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import {
5757
ApolloServerPluginUsageReportingDisabled,
5858
} from '@apollo/server/plugin/disabled';
5959
import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default';
60-
import { ApolloServerPluginLandingPageGraphQLPlayground } from '@apollo/server/plugin/landingPage/graphqlPlayground';
60+
import { ApolloServerPluginLandingPageGraphQLPlayground } from '@apollo/server-plugin-landing-page-graphql-playground';
6161
import {
6262
jest,
6363
describe,

packages/integration-testsuite/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"include": ["src/**/*"],
1111
"references": [
12+
{ "path": "../plugin-landing-page-graphql-playground" },
1213
{ "path": "../server" },
1314
],
1415
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# GraphQL Playground plugin
2+
3+
This is a plugin for Apollo Server 4 that makes your GraphQL server serve the [GraphQL Playground IDE](https://github.com/graphql/graphql-playground) as a landing page.
4+
5+
GraphQL Playground was the only landing page available for Apollo Server 2. The GraphQL Playground project is officially [retired](https://github.com/graphql/graphql-playground/issues/1143) and we do not recommend its continued use. We recommend Apollo Server 4's default landing page, which serves the similar but actively maintained [Apollo Sandbox](https://www.apollographql.com/docs/studio/explorer/sandbox/), or a custom landing page.
6+
7+
To help developers migrating from Apollo Server 2, we do still provide a landing page plugin that allows you to use GraphQL Playground with Apollo Server. In Apollo Server 3, that plugin is distributed as part of the `apollo-server-core` package. In Apollo Server 4, that plugin is distributed separately in this package.
8+
9+
To use GraphQL Playground with Apollo Server 4, first `npm install @apollo/server-plugin-landing-page-graphql-playground`, and then:
10+
11+
```ts
12+
import { ApolloServer } from '@apollo/server';
13+
import { ApolloServerPluginLandingPageGraphQLPlayground } from '@apollo/server-plugin-landing-page-graphql-playground';
14+
15+
const server = new ApolloServer({
16+
plugins: [ApolloServerPluginLandingPageGraphQLPlayground()],
17+
// ... other options ...
18+
});
19+
```
20+
21+
Note that this will serve GraphQL Playground unconditionally. If you would prefer to only serve it when not in production, you can use `process.env.NODE_ENV` to determine whether to include the plugin in the `plugins` option yourself.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "@apollo/server-plugin-landing-page-graphql-playground",
3+
"version": "3.0.0",
4+
"description": "Apollo Server landing page plugin for GraphQL Playground",
5+
"type": "module",
6+
"main": "dist/cjs/index.js",
7+
"module": "dist/esm/index.js",
8+
"types": "dist/esm/index.d.ts",
9+
"exports": {
10+
".": {
11+
"types": "./dist/esm/index.d.ts",
12+
"import": "./dist/esm/index.js",
13+
"require": "./dist/cjs/index.js"
14+
}
15+
},
16+
"repository": {
17+
"type": "git",
18+
"url": "https://github.com/apollographql/apollo-server",
19+
"directory": "packages/plugin-landing-page-graphql-playground"
20+
},
21+
"keywords": [],
22+
"author": "Apollo <[email protected]>",
23+
"license": "MIT",
24+
"bugs": {
25+
"url": "https://github.com/apollographql/apollo-server/issues"
26+
},
27+
"homepage": "https://github.com/apollographql/apollo-server#readme",
28+
"engines": {
29+
"node": ">=14.0"
30+
},
31+
"dependencies": {
32+
"@apollographql/graphql-playground-html": "1.6.29"
33+
},
34+
"peerDependencies": {
35+
"@apollo/server": "^4.0.0-alpha.6"
36+
}
37+
}

packages/server/src/plugin/landingPage/graphqlPlayground/index.ts renamed to packages/plugin-landing-page-graphql-playground/src/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
// specifying `version` when installing the plugin.
66

77
import { renderPlaygroundPage } from '@apollographql/graphql-playground-html';
8-
import type {
9-
ApolloServerPlugin,
10-
GraphQLServerListener,
11-
} from '../../../externalTypes';
8+
import type { ApolloServerPlugin, GraphQLServerListener } from '@apollo/server';
129

1310
// This specifies the React version of our fork of GraphQL Playground,
1411
// `@apollographql/graphql-playground-react`. It is related to, but not to
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": ".",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"outDir": "./dist/cjs",
6+
// We delete the CJS .d.ts files in postcompile so we don't need to
7+
// ever make their maps. (We can't disable creating the files because
8+
// this is a composite project.)
9+
"declarationMap": false,
10+
},
11+
}

0 commit comments

Comments
 (0)