Skip to content

Commit

Permalink
update playground to include #1319
Browse files Browse the repository at this point in the history
  • Loading branch information
evans committed Jul 13, 2018
1 parent 2775eeb commit fbf6c6b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 74 deletions.
49 changes: 28 additions & 21 deletions docs/source/features/graphql-playground.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,45 @@ In development, Apollo Server enables GraphQL Playground on the same URL as the
![GraphQL Playground](../images/graphql-playground.png)
</div>

## Enabling GraphQL Playground in production

To enable GraphQL Playground in production, an integration package must be installed to provide more control over the middlewares used. The following example uses the express integration:

```bash
npm install --save apollo-server-express@rc graphql
## Configuring Playground

The Apollo Server constructor contains the ability to configure GraphQL Playground with the `playground` configuration option. The options can be found on GraphQL Playground's [documentation](https://github.com/prismagraphql/graphql-playground/#usage)

```js
new ApolloServer({
typeDefs,
resolvers,
playground: {
settings: {
'editor.theme': 'light',
},
tabs: [
{
endpoint,
query: defaultQuery,
},
],
},
});
```

Introspection and the GUI can be enabled explicitly in the following manner.
## Enabling GraphQL Playground in production

To enable GraphQL Playground in production, introspection and the playground can be enabled explicitly in the following manner.

```js line=8,16
const { ApolloServer } = require('apollo-server-express');
const express = require('express');
```js line=7-8
const { ApolloServer } = require('apollo-server');
const { typeDefs, resolvers } = require('./schema');

const server = new ApolloServer({
typeDefs,
resolvers,
introspection: true,
playground: true,
});

const app = express();

// `gui` accepts a GraphQL Playground configuration
server.applyMiddleware({
app,
gui: true,
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});

app.listen({ port: 4000 }, () =>
console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`),
);
```

> Note: When using the `apollo-server-express` package, the `apollo-server` package can be uninstalled.
53 changes: 0 additions & 53 deletions docs/source/features/playground.md

This file was deleted.

0 comments on commit fbf6c6b

Please sign in to comment.