Skip to content

Commit d2b0444

Browse files
authored
Improve usage instructions
1 parent 2094c6b commit d2b0444

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,15 @@ Get a full fake GraphQL API with zero coding in less than 30 seconds.
88
> I'd love to learn GraphQL, but it seems that I first have to read a book about GraphQL Types and Queries, then install a gazillion npm packages.
99
> - About every developer
1010
11-
Start playing with GraphQL right away with `json-graphql-server`, a testing and mocking tool for GraphQL. All it takes is a JSON of your data.
11+
Start playing with GraphQL right away with `json-graphql-server`, a testing and mocking tool for GraphQL written in Node.js. All it takes is a JSON of your data.
1212

1313
Inspired by the excellent [json-server](https://github.com/typicode/json-server).
1414

15-
## Example
16-
17-
Follow the guide below starting from scratch, or see the example live on StackBlitz:
15+
## Usage
1816

1917
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/json-graphql-server)
2018

21-
22-
Create a `db.js` file.
23-
24-
Your data file should export an object where the keys are the entity types. The values should be lists of entities, i.e. arrays of value objects with at least an `id` key. For instance:
19+
Create a `db.js` file that exports an object where the keys are the entity types. The values should be lists of entities, i.e. arrays of value objects with at least an `id` key. For instance:
2520

2621
```js
2722
module.exports = {
@@ -40,14 +35,23 @@ module.exports = {
4035
}
4136
```
4237

43-
Start the GraphQL server on localhost, port 3000.
38+
Use the `npx json-graphql-server <db_file_name>` command to start the GraphQL server on localhost, port 3000.
4439

4540
```sh
46-
json-graphql-server db.js
41+
npx json-graphql-server db.js
4742
```
4843

49-
To use a port other than 3000, you can run `json-graphql-server db.js --p <your port here>`
50-
To use a host other than localhost, you can run `json-graphql-server db.js -h <your host here>` or `--host <your host here>`
44+
To use a different port, use the `--port` or `-p` option:
45+
46+
```
47+
npx json-graphql-server db.js --p 8080
48+
```
49+
50+
To use a different host, use the `--host` or `-h` option:
51+
52+
```
53+
npx json-graphql-server db.js -h 127.0.0.1
54+
```
5155

5256
Now you can query your data in graphql. For instance, to issue the following query:
5357

@@ -98,7 +102,7 @@ Note that the server is [GraphiQL](https://github.com/graphql/graphiql) enabled,
98102
## Install
99103

100104
```sh
101-
npm install -g json-graphql-server
105+
npm install json-graphql-server
102106
```
103107

104108
## Generated Types and Queries

0 commit comments

Comments
 (0)