You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/graphql-playground/README.md
+81-77Lines changed: 81 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,112 +44,116 @@ You can easily share your Playgrounds with others by clicking on the "Share" but
44
44
45
45
## Usage
46
46
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:
48
49
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.
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
51
54
52
-
```
55
+
### As React Component
56
+
57
+
#### Install
58
+
```sh
53
59
yarn add graphql-playground
54
60
```
55
61
56
-
### As React Component
62
+
#### Use
63
+
GraphQL Playground provides a React component responsible for rendering the UI and Session management.
64
+
There are **3 dependencies** needed in order to run the `graphql-playground` React component.
65
+
1._Open Sans_ and _Source Code Pro_ fonts
66
+
2. Including `graphql-playground/playground.css`
67
+
3. Rendering the `<Playground />` component
57
68
58
-
GraphQL Playground provides a React component responsible for rendering the UI, which should be provided with a function for fetching from GraphQL, we recommend using the [fetch](https://fetch.spec.whatwg.org/) standard API.
yarn add graphql-playground-middleware-express # for Express or Connect
92
+
yarn add graphql-playground-middleware-hapi
93
+
yarn add graphql-playground-middleware-koa
94
+
yarn add graphql-playground-middleware-lambda
95
95
```
96
96
97
-
###As Hapi Middleware
97
+
#### Usage with example
98
98
99
-
#### Properties
100
-
Hapi middleware supports the following properties:
99
+
We have a full example for each of the frameworks below:
101
100
102
-
+`options`
103
-
+`path`[`string`] - the Playground middleware url
104
-
+`playgroundOptions`
105
-
+`endpoint`[`string`] - the GraphQL endpoint url.
106
-
+`subscriptionEndpoint`[`string`] - the GraphQL subscription endpoint url.
101
+
-**Express:** See [packages/graphql-playground-middleware-express/examples/basic](https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-middleware-express/examples/basic)
-**Hapi:** See [packages/graphql-playground-middleware/examples/hapi](https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-middleware/examples/hapi)
112
104
113
-
constserver=newHapi.Server()
105
+
-**Koa:** See [packages/graphql-playground-middleware/examples/koa](https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-middleware/examples/koa)
114
106
115
-
server.connection({
116
-
port:3001
117
-
})
107
+
-**Lambda (as serverless handler):** See [serverless-graphql-apollo](https://github.com/serverless/serverless-graphql-apollo) or a quick example below.
118
108
119
-
server.register({
120
-
register: playground,
121
-
options: {
122
-
path:'/playground',
123
-
endpoint:'/graphql'
124
-
}
125
-
},() =>server.start())
109
+
### As serverless handler
110
+
#### Install
111
+
```sh
112
+
yarn add graphql-playground-middleware-lambda
126
113
```
127
114
128
-
### As Koa Middleware
129
-
130
-
#### Properties
131
-
Koa middleware supports the following properties:
132
-
133
-
+`options`
134
-
+`endpoint`[`string`] - the GraphQL endpoint url.
135
-
+`subscriptionEndpoint`[`string`] - the GraphQL subscription endpoint url.
[localhost:3000/middleware.html?endpoint=https://api.graph.cool/simple/v1/swapi](http://localhost:3000/middleware.html?endpoint=https://api.graph.cool/simple/v1/swapi) for local development!
0 commit comments