Skip to content

Commit e2ddc40

Browse files
committed
Add documentation
1 parent 3bbe886 commit e2ddc40

File tree

1 file changed

+30
-45
lines changed

1 file changed

+30
-45
lines changed

README.md

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,16 @@ Your data file should be an object where the keys are the entity types. The valu
2020
```json
2121
{
2222
"posts": [
23-
{
24-
"id": 1,
25-
"title": "Lorem Ipsum",
26-
"views": 254,
27-
"user_id": 123,
28-
"tag_id": "foo"
29-
},
30-
{
31-
"id": 2,
32-
"title": "Sic Dolor amet",
33-
"views": 65,
34-
"user_id": 456,
35-
"tag_id": "bar"
36-
},
23+
{ "id": 1, "title": "Lorem Ipsum", "views": 254, "user_id": 123 },
24+
{ "id": 2, "title": "Sic Dolor amet", "views": 65, "user_id": 456 },
3725
],
3826
"users": [
39-
{
40-
"id": 123,
41-
"name": "John Doe"
42-
},
43-
{
44-
"id": 456,
45-
"name": "Jane Doe"
46-
}
27+
{ "id": 123, "name": "John Doe" },
28+
{ "id": 456, "name": "Jane Doe" }
4729
],
48-
"tags": [
49-
{
50-
"id": "foo",
51-
"name": "Foo"
52-
},
53-
{
54-
"id": "bar",
55-
"name": "Bar"
56-
}
30+
"comments": [
31+
{ "id": 987, "post_id": 1, "body": "Consectetur adipiscing elit" },
32+
{ "id": 995, "post_id": 1, "body": "Nam molestie pellentesque dui" }
5733
]
5834
}
5935
```
@@ -67,16 +43,22 @@ json-graphql-server db.json
6743
Now you can query your data in graphql. For instance, to issue the following query:
6844

6945
```graphql
70-
query {
71-
Customer(id: 1) {
46+
{
47+
Post(id: 1) {
7248
id
73-
first_name
74-
last_name
49+
title
50+
views
51+
User {
52+
name
53+
}
54+
Comments {
55+
body
56+
}
7557
}
7658
}
7759
```
7860

79-
Go to http://localhost:3000/?query=query%20%7B%20Post(id%3A%201)%20%7Bid%20title%20views%20%7D%7D. You'll get the following result:
61+
Go to http://localhost:3000/?query=%7B%20Post%28id%3A%201%29%20%7B%20id%20title%20views%20User%20%7B%20name%20%7D%20Comments%20%7B%20body%20%7D%20%7D%20%7D. You'll get the following result:
8062

8163
```json
8264
{
@@ -85,12 +67,19 @@ Go to http://localhost:3000/?query=query%20%7B%20Post(id%3A%201)%20%7Bid%20title
8567
"id": "1",
8668
"title": "Lorem Ipsum",
8769
"views": 254,
70+
"User": {
71+
"name": "John Doe"
72+
},
73+
"Comments": [
74+
{ "body": "Consectetur adipiscing elit" },
75+
{ "body": "Nam molestie pellentesque dui" },
76+
]
8877
}
8978
}
9079
}
9180
```
9281

93-
The json-graphql-server accepts queries in GET and POST. Under the hood, it uses [Apollo's `graphql-server` module](http://dev.apollodata.com/tools/graphql-server/requests.html). Please refer to their documentations for details about passing variables, etc.
82+
The json-graphql-server accepts queries in GET and POST. Under the hood, it uses [the `express-graphql` module](https://github.com/graphql/express-graphql). Please refer to their documentations for details about passing variables, etc.
9483

9584
Note that the server is [GraphiQL](https://github.com/skevy/graphiql-app/releases) enabled, so you can query your server using a full-featured graphical user interface, providing autosuggest, history, etc.
9685

@@ -112,7 +101,8 @@ type Post {
112101
title: String!
113102
views: Int
114103
user_id: ID
115-
tag_id: ID
104+
User: User
105+
Comments: [Comment]
116106
}
117107
type Query {
118108
Post(id: ID!): Post
@@ -173,7 +163,6 @@ Here is how you can use the queries and mutations generated for your data, using
173163
title
174164
views
175165
user_id
176-
tag_id
177166
}
178167
}
179168
</pre>
@@ -186,8 +175,7 @@ Here is how you can use the queries and mutations generated for your data, using
186175
"id": 1,
187176
"title": "Lorem Ipsum",
188177
"views": 254,
189-
"user_id": 123,
190-
"tag_id": "foo"
178+
"user_id": 123
191179
}
192180
}
193181
}
@@ -246,7 +234,7 @@ Deploy with Heroku or Next.js.
246234

247235
## Roadmap
248236

249-
* Handle relationships
237+
* Filtering in the `all*` queries
250238
* Client-side mocking (à la [FakeRest](https://github.com/marmelab/FakeRest))
251239
* CLI options (port, https, watch, delay, custom schema)
252240

@@ -265,6 +253,3 @@ make format
265253
## License
266254

267255
Admin-on-rest is licensed under the [MIT Licence](https://github.com/marmelab/json-graphql-server/blob/master/LICENSE.md), sponsored and supported by [marmelab](http://marmelab.com).
268-
269-
270-

0 commit comments

Comments
 (0)