Skip to content

Commit b43b516

Browse files
authored
Make it minimal
1 parent 9a584b6 commit b43b516

File tree

1 file changed

+5
-64
lines changed

1 file changed

+5
-64
lines changed

README.md

Lines changed: 5 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# json-graphql-server
22

3-
Get a full fake GraphQL API with zero coding in less than 30 seconds. Works on the browser and on the server.
3+
Get a full fake GraphQL API with zero coding in less than 30 seconds.
44

55
## Motivation
66

@@ -11,20 +11,6 @@ Start playing with GraphQL right away with `json-graphql-server`, a testing and
1111

1212
## Usage
1313

14-
* In the browser
15-
16-
```js
17-
<script src="https://cdnjs.cloudflare.com/ajax/libs/json-graphql-server/1.0.0/json-graphql-server.min.js"></script>
18-
<script>
19-
var data = {
20-
// ... your data
21-
};
22-
GraphQLClientServer(data); // starts a GraphQL Server in your browser
23-
// now every call to http://localhost:3000/graphql will be intercepted
24-
// and served with your data in GraphQL
25-
</script>
26-
```
27-
2814
* CLI
2915

3016
```sh
@@ -36,14 +22,14 @@ json-graphql-server path/to/data.js
3622

3723
```js
3824
import express from 'express';
39-
import { GraphQlServer } from 'json-graphql-server';
25+
import { jsonGraphqlExpress } from 'json-graphql-server';
4026

4127
const PORT = 3000;
4228
const app = express();
4329
const data = {
4430
// ... your data
4531
};
46-
app.use('/graphql', GraphQLServer(data));
32+
app.use('/graphql', jsonGraphqlExpress(data));
4733
app.listen(PORT);
4834
```
4935

@@ -186,58 +172,13 @@ Here is how you can use the queries and mutations generated for your data, using
186172
</tr>
187173
</table>
188174

189-
## Options
190-
191-
You can access the json-graphql-server from anywhere - CORS are configures to accept all inbound requests. Also, content is compressed using GZip.
192-
193-
### Browser Options
194-
195-
You can override the GraphQL endpoint and port using the second parameter:
196-
197-
```js
198-
<script>
199-
var data = {
200-
// ... your data
201-
};
202-
GraphQLClientServer(data, 'http://localhost:8080/graphql');
203-
// now every call to http://localhost:8080/graphql will be intercepted
204-
// and served with your data in GraphQL
205-
</script>
206-
```
207-
208-
### CLI Options
209-
210-
You can override the GraphQL server port using the `--port` (or `-p`) option:
211-
212-
```sh
213-
json-graphql-server --port 8080 path/to/data.js
214-
```
215-
216-
You can force a server restart every time the source JSON file changes using the `--watch` option:
217-
218-
```sh
219-
json-graphql-server --watch path/to/data.js
220-
```
221-
222-
You can start a https server instead of an http one using the `--https` (or `-s`) option:
223-
224-
```sh
225-
json-graphql-server --https path/to/data.js
226-
```
227-
228-
You can add a random delay to responses by specifying a maximum delay (in ms) using the `--delay` (or `-d`) option:
229-
230-
```sh
231-
json-graphql-server --delay 1000 path/to/data.js
232-
```
233-
234175
## Adding Authentication, Custom Routes, etc.
235176

236177
`json-graphql-server` doesn't deal with authentication or custom routes. But you can use your favorite middleware with Express:
237178

238179
```js
239180
import express from 'express';
240-
import { GraphQlServer } from 'json-graphql-server';
181+
import { jsonGraphqlExpress } from 'json-graphql-server';
241182

242183
import OAuthSecurityMiddleWare from './path/to/OAuthSecurityMiddleWare';
243184

@@ -247,7 +188,7 @@ const data = {
247188
// ... your data
248189
};
249190
app.use(OAuthSecurityMiddleWare());
250-
app.use('/graphql', GraphQLServer(data));
191+
app.use('/graphql', jsonGraphqlExpress(data));
251192
app.listen(PORT);
252193
```
253194

0 commit comments

Comments
 (0)