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

docs: Follow-up editorial for GraphQL Playground doc. (#1270). #1319

Merged
merged 2 commits into from
Jul 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sidebar_categories:
- features/data-sources
- features/subscriptions
- features/metrics
- features/playground
- features/graphql-playground
- features/scalars-enums
- features/unions-interfaces
- features/directives
Expand Down
48 changes: 48 additions & 0 deletions docs/source/features/graphql-playground.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: GraphQL Playground
description: Visually exploring an Apollo Server
---

[GraphQL Playground](https://github.com/prismagraphql/graphql-playground) is a graphical, interactive, in-browser GraphQL IDE, created by [Prisma](https://www.prisma.io/) and based on [GraphiQL](https://github.com/graphql/graphiql).

In development, Apollo Server enables GraphQL Playground on the same URL as the GraphQL server itself (e.g. `http://localhost:4000/graphql`) and automatically serves the GUI to web browsers. When `NODE_ENV` is set to `production`, GraphQL Playground (as well as introspection) is disabled as a production best-practice.

<div align="center">
![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
```

Introspection and the GUI can be enabled explicitly in the following manner.

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

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

const app = express();

// `gui` accepts a GraphQL Playground configuration
server.applyMiddleware({
app,
gui: true,
});

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.
46 changes: 0 additions & 46 deletions docs/source/features/playground.md

This file was deleted.