Skip to content

Commit b5da2d8

Browse files
authored
Update README.md
1 parent 6c9503f commit b5da2d8

File tree

1 file changed

+31
-44
lines changed

1 file changed

+31
-44
lines changed

README.md

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,22 @@ You can easily share your Playgrounds with others by clicking on the "Share" but
4444

4545
## Usage
4646

47-
[examples/latest.html](https://github.com/graphcool/graphql-playground/blob/master/packages/graphql-playground/examples/latest.html) contains a simple example on how to use the latest playground in your application.
47+
### Properties
48+
All interfaces, the React component `<Playground />` and all middlewares expose the same set of options:
4849

49-
You also can use the latest playground based on the npm package.
50-
In order to do that, first you need to install `graphql-playground` via NPM. Then choose one of the following options to use the Playground in your own app/server.
51-
52-
```
53-
yarn add graphql-playground
54-
```
50+
+ `properties`
51+
+ `endpoint` [`string`] - the GraphQL endpoint url.
52+
+ `subscriptionEndpoint` [`string`] - the GraphQL subscriptions endpoint url.
53+
+ `setTitle` [`boolean`] - reflect the current endpoint in the page title
5554

5655
### As React Component
5756

58-
#### Usage
59-
57+
#### Install
58+
```sh
59+
yarn add graphql-playground
60+
```
61+
62+
#### Use
6063
GraphQL Playground provides a React component responsible for rendering the UI and Session management.
6164
There are **3 dependencies** needed in order to run the `graphql-playground` React component.
6265
1. _Open Sans_ and _Source Code Pro_ fonts
@@ -65,12 +68,12 @@ There are **3 dependencies** needed in order to run the `graphql-playground` Rea
6568

6669
The GraphQL Playground requires **React 16**.
6770

68-
Including Fonts (1.)
71+
Including Fonts (`1.`)
6972
```html
7073
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700|Source+Code+Pro:400,700" rel="stylesheet">
7174
```
7275

73-
Including stylesheet and the component (2., 3.)
76+
Including stylesheet and the component (`2., 3.`)
7477
```js
7578
import React from 'react'
7679
import ReactDOM from 'react-dom'
@@ -80,27 +83,17 @@ import 'graphql-playground/playground.css'
8083
ReactDOM.render(<Playground endpoint="https://api.graph.cool/simple/v1/swapi" />, document.body)
8184
```
8285

83-
#### `<Playground />` Props
84-
```ts
85-
interface PlaygroundProps {
86-
endpoint?: string // endpoint url (e.g. https://api.graph.cool/simple/v1/swapi)
87-
subscriptionEndpoint?: string // subscriptions url (e.g. wss://subscriptions.graph.cool/v1/swapi)
88-
setTitle?: boolean // reflect the current endpoint in the page title
89-
}
90-
```
91-
9286
### As Express Middleware
9387

94-
#### Properties
95-
Express middleware supports the following properties:
96-
97-
+ `options`
98-
+ `endpoint` [`string`] - the GraphQL endpoint url.
88+
#### Install
89+
```sh
90+
yarn add graphql-playground-middleware
91+
```
9992

100-
#### Usage
93+
#### Use
10194
```js
10295
import express from 'express'
103-
import { express as playground } from 'graphql-playground/middleware'
96+
import { express as playground } from 'graphql-playground-middleware'
10497

10598
const app = express()
10699

@@ -111,19 +104,15 @@ app.listen(3000)
111104

112105
### As Hapi Middleware
113106

114-
#### Properties
115-
Hapi middleware supports the following properties:
116-
117-
+ `options`
118-
+ `path` [`string`] - the Playground middleware url
119-
+ `playgroundOptions`
120-
+ `endpoint` [`string`] - the GraphQL endpoint url.
121-
+ `subscriptionEndpoint` [`string`] - the GraphQL subscription endpoint url.
107+
#### Install
108+
```sh
109+
yarn add graphql-playground-middleware
110+
```
122111

123-
#### Usage
112+
#### Use
124113
```js
125114
import hapi from 'hapi'
126-
import { hapi as playground } from 'graphql-playground/middleware'
115+
import { hapi as playground } from 'graphql-playground-middleware'
127116

128117
const server = new Hapi.Server()
129118

@@ -142,14 +131,12 @@ server.register({
142131

143132
### As Koa Middleware
144133

145-
#### Properties
146-
Koa middleware supports the following properties:
147-
148-
+ `options`
149-
+ `endpoint` [`string`] - the GraphQL endpoint url.
150-
+ `subscriptionEndpoint` [`string`] - the GraphQL subscription endpoint url.
134+
#### Install
135+
```sh
136+
yarn add graphql-playground-middleware
137+
```
151138

152-
#### Usage
139+
#### Use
153140
```js
154141
import Koa from 'koa'
155142
import KoaRouter from 'koa-router'

0 commit comments

Comments
 (0)